完成基本的server启动以及example

This commit is contained in:
2021-03-28 16:04:42 +08:00
parent b0814c443a
commit c41a7c4671
7 changed files with 342 additions and 28 deletions

View File

@ -19,8 +19,10 @@ import (
// Date : 7:03 下午 2021/3/27
type WSContext struct {
ConnectionID string // 请求ID
Flag string // 长连接模块
GinCtx *gin.Context // 基于gin实现websocket, gin的上下文
Session *melody.Session // 长连接的会话
Server *melody.Melody // ws server
}
// NewContext 生成上下文信息
@ -28,10 +30,12 @@ type WSContext struct {
// Author : go_developer@163.com<张德满>
//
// Date : 7:15 下午 2021/3/27
func NewContext(ginCtx *gin.Context, session *melody.Session) *WSContext {
func NewContext(ginCtx *gin.Context, flag string, session *melody.Session) *WSContext {
return &WSContext{
ConnectionID: "",
Flag: flag,
GinCtx: ginCtx,
Session: session,
Server: melody.New(),
}
}