diff --git a/storage/IStorage.go b/storage/IStorage.go index df29e81..121747b 100644 --- a/storage/IStorage.go +++ b/storage/IStorage.go @@ -18,7 +18,7 @@ type IConnection interface { // Store 存储 Store(ctx *context.WSContext) // Del 移除 - Del(ctx *context.WSContext) + Del(ctx *context.WSContext, message string) // GetCtxList 获取连接列表 GetCtxList(cidList ...string) []*context.WSContext // Clear 清空连接 diff --git a/storage/connection.go b/storage/connection.go index 6fe7bc5..0bda9d1 100644 --- a/storage/connection.go +++ b/storage/connection.go @@ -31,7 +31,11 @@ func (c *connection) Store(ctx *context.WSContext) { c.table.Set(ctx.ConnectionID, ctx) } -func (c *connection) Del(ctx *context.WSContext) { +func (c *connection) Del(ctx *context.WSContext, message string) { + if len(message) > 0 { + _ = ctx.Session.Write([]byte(message)) + _ = ctx.Session.Close() + } c.table.Del(ctx.ConnectionID) }