websocket/abstract/IWebsocket.go

71 lines
1.8 KiB
Go
Raw Permalink Normal View History

2021-03-27 19:24:08 +08:00
// Package abstract...
//
// Description : 长连接模块的基础约束
//
2021-06-05 22:13:09 +08:00
// Author : go_developer@163.com<白茶清欢>
2021-03-27 19:24:08 +08:00
//
// Date : 2021-03-27 6:32 下午
package abstract
import (
"git.zhangdeman.cn/zhangdeman/websocket/config"
"git.zhangdeman.cn/zhangdeman/websocket/context"
)
2021-03-27 19:24:08 +08:00
// IWebsocket 接口约束
//
2021-06-05 22:13:09 +08:00
// Author : go_developer@163.com<白茶清欢>
2021-03-27 19:24:08 +08:00
//
// Date : 6:35 下午 2021/3/27
type IWebsocket interface {
// Connect 建立连接时,处理的方法
//
2021-06-05 22:13:09 +08:00
// Author : go_developer@163.com<白茶清欢>
2021-03-27 19:24:08 +08:00
//
// Date : 6:39 下午 2021/3/27
2021-04-09 15:13:22 +08:00
Connect(ctx *context.WSContext) error
2021-03-27 19:24:08 +08:00
// Disconnect 断开连接时处理的方法
//
2021-06-05 22:13:09 +08:00
// Author : go_developer@163.com<白茶清欢>
2021-03-27 19:24:08 +08:00
//
// Date : 6:40 下午 2021/3/27
Disconnect(ctx *context.WSContext)
// Close 关闭连接
2021-03-27 19:24:08 +08:00
//
2021-06-05 22:13:09 +08:00
// Author : go_developer@163.com<白茶清欢>
2021-03-27 19:24:08 +08:00
//
// Date : 8:43 下午 2021/3/27
Close(ctx *context.WSContext, code int, message string) error
2021-03-27 19:24:08 +08:00
// HandshakeURL 注册的websocket路由
//
2021-06-05 22:13:09 +08:00
// Author : go_developer@163.com<白茶清欢>
2021-03-27 19:24:08 +08:00
//
// Date : 6:45 下午 2021/3/27
HandshakeURL() []string
// GetCommandList 注册长连接模块支持的命令
2021-03-27 19:24:08 +08:00
//
2021-06-05 22:13:09 +08:00
// Author : go_developer@163.com<白茶清欢>
2021-03-27 19:24:08 +08:00
//
// Date : 6:48 下午 2021/3/27
GetCommandList() []ICommand
2021-03-27 19:24:08 +08:00
// GetModuleFlag 获取模块标识,全局唯一
//
2021-06-05 22:13:09 +08:00
// Author : go_developer@163.com<白茶清欢>
2021-03-27 19:24:08 +08:00
//
// Date : 6:50 下午 2021/3/27
GetModuleFlag() string
// GetServerPort 获取长连接监听的端口,多个模块可监听不同的端口
//
2021-06-05 22:13:09 +08:00
// Author : go_developer@163.com<白茶清欢>
2021-03-27 19:24:08 +08:00
//
// Date : 6:55 下午 2021/3/27
GetServerPort() int
2021-04-17 19:41:02 +08:00
// GetWSServerConfig 获取WS-Server的配置
//
2021-06-05 22:13:09 +08:00
// Author : go_developer@163.com<白茶清欢>
2021-04-17 19:41:02 +08:00
//
// Date : 7:01 下午 2021/4/17
2021-04-17 21:41:40 +08:00
GetWSServerConfig() []config.SetWSServerConfig
2021-03-27 19:24:08 +08:00
}