升级默认的连接管理的实现

This commit is contained in:
zhangdeman committed 2021-04-17 23:58:26 +08:00
1 parent 99f17f86ec
commit 854c9b0ad7
2 files changed
+6 -2

No files matched your search

+1 -1
View File
@@ -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 清空连接
+5 -1
View File
@@ -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)
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.