Documentation ¶
Index ¶
Constants ¶
View Source
const ( // WriteWait Time allowed to write a message to the peer. WriteWait = 60 * time.Second // PongWait Time allowed to read the next pong message from the peer. PongWait = 60 * time.Second // HeartBeatStep Send pings to peer with this period. Must be less than pongWait. //PingPeriod = (PongWait * 9) / 10 HeartBeatStep = 10 * time.Second // MaxMessageSize Maximum message size allowed from peer. MaxMessageSize = 65535 MsgTimeout = 5 Stop = 1 PaddingPackageLength = 4 )
Variables ¶
View Source
var WSCloseCodes = []int{ websocket.CloseNormalClosure, websocket.CloseGoingAway, websocket.CloseProtocolError, websocket.CloseUnsupportedData, websocket.CloseNoStatusReceived, websocket.CloseAbnormalClosure, websocket.CloseInvalidFramePayloadData, websocket.ClosePolicyViolation, websocket.CloseMessageTooBig, websocket.CloseMandatoryExtension, websocket.CloseInternalServerErr, websocket.CloseServiceRestart, websocket.CloseTryAgainLater, websocket.CloseTLSHandshake, }
Functions ¶
func FindRemainder ¶
Types ¶
type Message ¶
type Message struct { Code WsCode `json:"code"` Data string `json:"data"` Message string `json:"message"` Timestamp int64 `json:"timestamp"` }
func PingMessage ¶
func PingMessage() *Message
type OperateMessage ¶
type OperateMessage struct { Operate int `json:"operate"` Data interface{} `json:"data"` }
type WsCode ¶
type WsCode int
const ( CodeHeartBeat WsCode = 100 // 心跳 CodeWsSuccess WsCode = 200 // 成功 CodeWsFailure WsCode = 400 // 失败 WsTimeOut WsCode = 4000 // timeout WsInvalidAccess WsCode = 4001 // invalid access WsServerClose WsCode = 4002 // server close WsInvalidOperateCode WsCode = 4003 // invalid operate WsPackageError WsCode = 4100 // 消息解析错误 WsPackageWrongPrefix WsCode = 4101 // 前缀不对 WsPackageWrongSignature WsCode = 4102 // 签名不对 WsPackageWrongLength WsCode = 4103 // 数据长度不对 WsPackageWrongTime WsCode = 4104 // 时间不对 OPCodeWsDownloadQuery WsCode = 6800 // 查询 OPCodeWsDownloading WsCode = 6801 // 下载 OPCodeWsDownloadCorrect WsCode = 6802 // 校正 OPCodeWsDownloadFinish WsCode = 6803 // 完成 OPCodeWsDownloadTimeout WsCode = 6804 // 超时未响应 )
Click to show internal directories.
Click to hide internal directories.