增加基础的接口约束
This commit is contained in:
37
context/context.go
Normal file
37
context/context.go
Normal 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,
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user