增加基础的接口约束

This commit is contained in:
2021-03-27 19:24:08 +08:00
parent bdee75b5f3
commit b0814c443a
8 changed files with 245 additions and 2 deletions

37
context/context.go Normal file
View File

@ -0,0 +1,37 @@
// Package context...
//
// Description : 上下文信息
//
// Author : go_developer@163.com<张德满>
//
// Date : 2021-03-27 6:53 下午
package context
import (
"github.com/gin-gonic/gin"
"gopkg.in/olahol/melody.v1"
)
// WSContext 请求上下文
//
// Author : go_developer@163.com<张德满>
//
// Date : 7:03 下午 2021/3/27
type WSContext struct {
ConnectionID string // 请求ID
GinCtx *gin.Context // 基于gin实现websocket, gin的上下文
Session *melody.Session // 长连接的会话
}
// NewContext 生成上下文信息
//
// Author : go_developer@163.com<张德满>
//
// Date : 7:15 下午 2021/3/27
func NewContext(ginCtx *gin.Context, session *melody.Session) *WSContext {
return &WSContext{
ConnectionID: "",
GinCtx: ginCtx,
Session: session,
}
}