diff --git a/server/websocket/internal/handler/routes.go b/server/websocket/internal/handler/routes.go index 8a2c5bd1..4eefa507 100644 --- a/server/websocket/internal/handler/routes.go +++ b/server/websocket/internal/handler/routes.go @@ -27,6 +27,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { Path: "/api/websocket/common_notify", Handler: CommonNotifyHandler(serverCtx), }, + { + Method: http.MethodPost, + Path: "/api/websocket/close_websocket", + Handler: CloseWebsocketHandler(serverCtx), + }, }, ) } diff --git a/server/websocket/internal/types/types.go b/server/websocket/internal/types/types.go index 1bcd95d5..316ac30d 100644 --- a/server/websocket/internal/types/types.go +++ b/server/websocket/internal/types/types.go @@ -25,6 +25,10 @@ type CommonNotifyReq struct { Data map[string]interface{} `json:"data"` //后端与前端约定好的数据 } +type CloseWebsocketReq struct { + Wid string `json:"wid"` +} + type Request struct { } diff --git a/server_api/websocket.api b/server_api/websocket.api index b3c38975..43a39910 100644 --- a/server_api/websocket.api +++ b/server_api/websocket.api @@ -18,6 +18,9 @@ service websocket { //通用回调接口 @handler CommonNotifyHandler post /api/websocket/common_notify(CommonNotifyReq) returns (response); + //关闭某个连接 + @handler CloseWebsocketHandler + post /api/websocket/close_websocket(CloseWebsocketReq) returns (response); } //websocket数据交互[ @@ -39,4 +42,8 @@ type CommonNotifyReq { UserId int64 `json:"user_id,optional"` //用户id GuestId int64 `json:"guest_id,optional"` //游客id Data map[string]interface{} `json:"data"` //后端与前端约定好的数据 +} +//关闭连接 +type CloseWebsocketReq { + Wid string `json:"wid"` } \ No newline at end of file