From 68a31236b37045f201c8437856aa1e487f933a50 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Tue, 17 Oct 2023 15:40:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E5=90=88=E7=9B=AE=E5=89=8D=E6=96=B0?= =?UTF-8?q?=E7=9A=84=E8=AF=A6=E6=83=85=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/websocket/internal/handler/routes.go | 5 +++++ server/websocket/internal/types/types.go | 4 ++++ server_api/websocket.api | 7 +++++++ 3 files changed, 16 insertions(+) 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