增加建立以及断开连接时,移除连接

This commit is contained in:
2021-04-08 18:36:17 +08:00
parent cf11a23a9d
commit 9b826dfae7
4 changed files with 97 additions and 0 deletions

26
storage/IStorage.go Normal file
View File

@ -0,0 +1,26 @@
// Package storage ...
//
// Description : 各种内存数据的管理,基于接口,可自己重新实现管理实例
//
// Author : go_developer@163.com<张德满>
//
// Date : 2021-04-08 5:29 下午
package storage
import "github.com/go-developer/websocket/context"
// IConnection 连接管理接口定义
//
// Author : go_developer@163.com<张德满>
//
// Date : 5:30 下午 2021/4/8
type IConnection interface {
// Store 存储
Store(ctx *context.WSContext)
// Del 移除
Del(ctx *context.WSContext)
// GetCtxList 获取连接列表
GetCtxList(cidList ...string) []*context.WSContext
// Clear 清空连接
Clear(message string)
}

44
storage/connection.go Normal file
View File

@ -0,0 +1,44 @@
// Package storage ...
//
// Description : 在线连接的存储
//
// Author : go_developer@163.com<张德满>
//
// Date : 2021-04-08 5:46 下午
package storage
import (
"github.com/go-developer/gopkg/easymap"
"github.com/go-developer/websocket/context"
)
var (
// Connection 连接管理
Connection IConnection
)
func init() {
Connection = &connection{table: make([]easymap.EasyMap, 0)}
for i := 0; i < 4096; i++ {
}
}
type connection struct {
table []easymap.EasyMap
}
func (c *connection) Store(ctx *context.WSContext) {
panic("implement me")
}
func (c *connection) Del(ctx *context.WSContext) {
panic("implement me")
}
func (c *connection) GetCtxList(cidList ...string) []*context.WSContext {
panic("implement me")
}
func (c *connection) Clear(message string) {
panic("implement me")
}