Documentation ¶
Overview ¶
Package websocket 提供WebSocket服务
Index ¶
- Constants
- Variables
- type Connection
- func (conn *Connection) AppID() string
- func (conn *Connection) Close(force bool) error
- func (conn *Connection) DeviceID() string
- func (conn *Connection) ID() string
- func (conn *Connection) IsLogin() bool
- func (conn *Connection) LoginSuccess(appID, userID, deviceID, defaultVersion string)
- func (conn *Connection) ReadCommand() (cmd *protocol.Command, err error)
- func (conn *Connection) Send(cmd *protocol.Command) error
- func (conn *Connection) String() string
- func (conn *Connection) UserID() string
- type Server
- func (srv *Server) Close(timeout time.Duration) (err error)
- func (srv *Server) HandleDebug(w http.ResponseWriter, r *http.Request)
- func (srv *Server) HandleWebSocket(w http.ResponseWriter, r *http.Request)
- func (srv *Server) Run(ctx context.Context) (err error)
- func (srv *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
- type WSParameter
Constants ¶
View Source
const (
// ServerName 服务名
ServerName = "websocket"
)
Variables ¶
View Source
var ( // HeartBeatCommand 心跳命令 HeartBeatCommand = &protocol.Command{ Name: protocol.HeartBeat, } // HeartBeatResponseCommand 心跳响应命令 HeartBeatResponseCommand = &protocol.Command{ Name: protocol.HeartBeatResponse, } )
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection 连接
func (*Connection) Close ¶
func (conn *Connection) Close(force bool) error
Close 关闭链接(define::Connection接口函数)
func (*Connection) LoginSuccess ¶
func (conn *Connection) LoginSuccess(appID, userID, deviceID, defaultVersion string)
LoginSuccess 登入成功
func (*Connection) ReadCommand ¶
func (conn *Connection) ReadCommand() (cmd *protocol.Command, err error)
ReadCommand 读取命令
func (*Connection) String ¶
func (conn *Connection) String() string
ToString 字符串输出(define::Connection接口函数)
type Server ¶
type Server struct { // WSParameter WebSocket服务构造参数 WSParameter // contains filtered or unexported fields }
Server WebSocket服务
func NewServer ¶
func NewServer(serverHandler define.ServerHandler) (srv *Server, err error)
NewServer 新建一个WebSocket服务实例
func (*Server) HandleDebug ¶
func (srv *Server) HandleDebug(w http.ResponseWriter, r *http.Request)
HandleDebug 处理HTTP链接
func (*Server) HandleWebSocket ¶
func (srv *Server) HandleWebSocket(w http.ResponseWriter, r *http.Request)
HandleWebSocket 处理HTTP链接
Click to show internal directories.
Click to hide internal directories.