Documentation ¶
Index ¶
- Constants
- Variables
- func MiopBindAckStream(appId, r string, version int16, opCode int16) ([]byte, error)
- func RegisterRpcTypeForValue(value interface{})
- type HttpClient
- func (this *HttpClient) Close() error
- func (this *HttpClient) ConnectTo(address string, timeout time.Duration) error
- func (this *HttpClient) Dial(localAddress string, remoteAddress string, timeout time.Duration) error
- func (this *HttpClient) Get(uri string, readTimeout time.Duration, writeTimeout time.Duration) (*HttpResponse, error)
- func (this *HttpClient) Post(uri string, posts map[string]string, readTimeout time.Duration, ...) (*HttpResponse, error)
- func (this *HttpClient) Recv(readTimeout time.Duration) (*HttpResponse, error)
- func (this *HttpClient) Send(request *HttpRequest, writeTimeout time.Duration) error
- func (this *HttpClient) SetDebug(debug bool)
- type HttpConnection
- func (this *HttpConnection) FinishChunk() error
- func (this *HttpConnection) ReadRequest(timeout time.Duration) (*HttpRequest, error)
- func (this *HttpConnection) ReadResponse(timeout time.Duration) (*HttpResponse, error)
- func (this *HttpConnection) ReadToRequest(request *HttpRequest, timeout time.Duration) (*HttpRequest, error)
- func (this *HttpConnection) SendChunk(s string) error
- func (this *HttpConnection) WriteChunkedHeader(response *HttpResponse, timeout time.Duration) error
- func (this *HttpConnection) WriteRequest(request *HttpRequest, timeout time.Duration) error
- func (this *HttpConnection) WriteResponse(response *HttpResponse, timeout time.Duration) error
- func (this *HttpConnection) WriteResponseStream(stream []byte, timeout time.Duration) error
- type HttpMessage
- type HttpRequest
- func (this *HttpRequest) Chas(key string) bool
- func (this *HttpRequest) Cint(key string) int
- func (this *HttpRequest) Cookies() map[string]string
- func (this *HttpRequest) Cstr(key string) string
- func (this *HttpRequest) GetRemoteIp() string
- func (this *HttpRequest) Gets() map[string]string
- func (this *HttpRequest) Ghas(key string) bool
- func (this *HttpRequest) Gint(key string) int
- func (this *HttpRequest) Gstr(key string) string
- func (this *HttpRequest) Header(key string) string
- func (this *HttpRequest) IsDelete() bool
- func (this *HttpRequest) IsGet() bool
- func (this *HttpRequest) IsKeepAlive() bool
- func (this *HttpRequest) IsPost() bool
- func (this *HttpRequest) IsPut() bool
- func (this *HttpRequest) Method() string
- func (this *HttpRequest) PathInfo() string
- func (this *HttpRequest) Phas(key string) bool
- func (this *HttpRequest) Pint(key string) int
- func (this *HttpRequest) Posts() map[string]string
- func (this *HttpRequest) Pstr(key string) string
- func (this *HttpRequest) Rint(key string) int
- func (this *HttpRequest) Rstr(key string) string
- func (this *HttpRequest) SetHeader(key string, value string)
- func (this *HttpRequest) SetMethod(method string)
- func (this *HttpRequest) SetPosts(posts map[string]string)
- func (this *HttpRequest) SetPstr(key, value string)
- func (this *HttpRequest) SetRemoteIp(ip string)
- func (this *HttpRequest) SetUri(uri string)
- func (this *HttpRequest) SetVar(key string, value interface{})
- func (this *HttpRequest) SetVersion(version string)
- func (this *HttpRequest) Stream() []byte
- func (this *HttpRequest) String() string
- func (this *HttpRequest) Uri() string
- func (this *HttpRequest) Var(key string) interface{}
- func (this *HttpRequest) Version() string
- type HttpResponse
- func (this *HttpResponse) BodyStream() []byte
- func (this *HttpResponse) BodyString() string
- func (this *HttpResponse) ChunkedStream() []byte
- func (this *HttpResponse) Code() int
- func (this *HttpResponse) Header(key string) string
- func (this *HttpResponse) IsConnectionClose() bool
- func (this *HttpResponse) Putb(stream []byte)
- func (this *HttpResponse) Puts(content string)
- func (this *HttpResponse) SetBodyStream(bodyStream []byte)
- func (this *HttpResponse) SetBodyString(bodyString string)
- func (this *HttpResponse) SetCode(code int)
- func (this *HttpResponse) SetHeader(key string, value string)
- func (this *HttpResponse) SetHeaderWithChunkedMode()
- func (this *HttpResponse) SetHeaderWithContentLength(length string)
- func (this *HttpResponse) SetStatus(code int, phrase string)
- func (this *HttpResponse) SetVersion(version string)
- func (this *HttpResponse) Status() (int, string)
- func (this *HttpResponse) Stream() []byte
- func (this *HttpResponse) String() string
- func (this *HttpResponse) Version() string
- type INetwork
- type MiopBuffer
- func (this *MiopBuffer) HasProp(key string) bool
- func (this *MiopBuffer) IsAckMessage() bool
- func (this *MiopBuffer) IsEmpty() bool
- func (this *MiopBuffer) IsKickMessage() bool
- func (this *MiopBuffer) IsMessage() bool
- func (this *MiopBuffer) IsMigrateMessage() bool
- func (this *MiopBuffer) IsPongMessage() bool
- func (this *MiopBuffer) ReadFrom(tcpConnection *TcpConnection, timeout time.Duration) error
- func (this *MiopBuffer) ReadUpdateData(offset int) (string, int, error)
- func (this *MiopBuffer) Reset() error
- func (this *MiopBuffer) Stream() []byte
- func (this *MiopBuffer) StreamMiop() []byte
- func (this *MiopBuffer) StreamMiop5() []byte
- func (this *MiopBuffer) WriteTo(tcpConnection *TcpConnection, timeout time.Duration) error
- type RpcRequest
- type RpcResponse
- type TLSConnection
- func (c *TLSConnection) IsHTTPProto() bool
- func (c *TLSConnection) Read(b []byte) (int, error)
- func (c *TLSConnection) ReadStream(b []byte, n int) error
- func (c *TLSConnection) RemoteIp() string
- func (c *TLSConnection) Type() string
- func (c *TLSConnection) WriteBytes(b []byte, timeout time.Duration) (int, error)
- type TcpConnection
- func (this *TcpConnection) IsCrossDomain() bool
- func (this *TcpConnection) IsHttpProto() bool
- func (this *TcpConnection) IsMiopV3() bool
- func (this *TcpConnection) IsMiopV5() bool
- func (this *TcpConnection) IsMiopV6() bool
- func (this *TcpConnection) IsTLSProto() bool
- func (this *TcpConnection) IsXimpProto() bool
- func (this *TcpConnection) Read(p []byte) (n int, err error)
- func (this *TcpConnection) ReadProtoBuffer() error
- func (this *TcpConnection) ReadRpcRequest(timeout time.Duration) (*RpcRequest, error)
- func (this *TcpConnection) ReadStream(stream []byte, count int) error
- func (this *TcpConnection) RemoteIp() string
- func (this *TcpConnection) RemotePort() string
- func (this *TcpConnection) Rpc(request *RpcRequest, readTimeout time.Duration, writeTimeout time.Duration) (*RpcResponse, error)
- func (this *TcpConnection) Type() string
- func (this *TcpConnection) WriteBytes(p []byte, timeout time.Duration) (int, error)
- func (this *TcpConnection) WriteRpcResponse(response *RpcResponse, timeout time.Duration) error
- type TcpListener
- type WebSocketConnection
- func (w *WebSocketConnection) Read(b []byte) (n int, err error)
- func (w *WebSocketConnection) ReadStream(stream []byte, count int) error
- func (w *WebSocketConnection) RemoteIp() string
- func (w *WebSocketConnection) SetDeadline(t time.Time) error
- func (w *WebSocketConnection) Type() string
- func (w *WebSocketConnection) Write(b []byte) (n int, err error)
- func (w *WebSocketConnection) WriteBytes(b []byte, t time.Duration) (int, error)
- type WebSocketSecureConnection
- func (w *WebSocketSecureConnection) Read(b []byte) (n int, err error)
- func (w *WebSocketSecureConnection) ReadStream(stream []byte, count int) error
- func (w *WebSocketSecureConnection) RemoteIp() string
- func (w *WebSocketSecureConnection) SetDeadline(t time.Time) error
- func (w *WebSocketSecureConnection) Type() string
- func (w *WebSocketSecureConnection) Write(b []byte) (n int, err error)
- func (w *WebSocketSecureConnection) WriteBytes(b []byte, t time.Duration) (int, error)
- type XimpBuffer
- func (this *XimpBuffer) Decrypt(rkey []byte) error
- func (this *XimpBuffer) Encode() ([]byte, error)
- func (this *XimpBuffer) Encrypt(rkey []byte) error
- func (this *XimpBuffer) ReadFrom(isClient bool, conn INetwork, timeout time.Duration) error
- func (this *XimpBuffer) String() string
- func (this *XimpBuffer) WriteTo(tcpConnection *TcpConnection, timeout time.Duration) error
Constants ¶
View Source
const ( OpcodePing = 0 OpcodePong = 1 OpcodeBind = 2 OpcodeMsg = 3 OpcodeMsgAck = 4 OpcodeUnbind = 5 OpcodeBindAck = 6 OpcodeUnbindAck = 7 OpcodeKick = 8 // 踢掉用户 OpcodeMigrate = 9 // 迁移用户到给定room OpcodeRebind = 10 OpcodeRebindAck = 11 OpcodeOfflineNotify = 12 // miop5离线补偿,走execcmd OpcodeUploadData = 13 //上行数据 OpcodeUploadDataAck = 14 //上行数据ack OpcodeHandshake = 15 //握手协商 )
View Source
const ( MIOP_MAX_DATA_LENGTH int32 = 1024 * 1024 MiopBindAckMapMax int = 150000 //map最大值,大于此值,返回错误,记录日志 )
View Source
const ( TcpNetwork = "tcp" WebSocketNetwork = "web" TLSNetwork = "tls" WebSocketSecureNetwork = "wss" )
View Source
const (
MAX_UPLOAD_SIZE = 1024 * 1024
)
Variables ¶
View Source
var Miop5PongStream = func() []byte { miopBuf := NewMiopBuffer() miopBuf.Version = 5 miopBuf.OpCode = OpcodePong return miopBuf.Stream() }()
View Source
var Miop6PongStream = func() []byte { miopBuf := NewMiopBuffer() miopBuf.Version = 6 miopBuf.OpCode = OpcodePong return miopBuf.Stream() }()
View Source
var MiopBindAckMap map[string][]byte
View Source
var MiopBindAckMapLock sync.RWMutex
Functions ¶
func MiopBindAckStream ¶
此处bind和unbind的ACK公用一个map,不过要做区分
Types ¶
type HttpClient ¶
type HttpClient struct {
// contains filtered or unexported fields
}
func NewHttpClient ¶
func NewHttpClient() *HttpClient
func (*HttpClient) Close ¶
func (this *HttpClient) Close() error
func (*HttpClient) ConnectTo ¶
func (this *HttpClient) ConnectTo(address string, timeout time.Duration) error
func (*HttpClient) Get ¶
func (this *HttpClient) Get(uri string, readTimeout time.Duration, writeTimeout time.Duration) (*HttpResponse, error)
func (*HttpClient) Post ¶
func (this *HttpClient) Post(uri string, posts map[string]string, readTimeout time.Duration, writeTimeout time.Duration) (*HttpResponse, error)
func (*HttpClient) Recv ¶
func (this *HttpClient) Recv(readTimeout time.Duration) (*HttpResponse, error)
func (*HttpClient) Send ¶
func (this *HttpClient) Send(request *HttpRequest, writeTimeout time.Duration) error
func (*HttpClient) SetDebug ¶
func (this *HttpClient) SetDebug(debug bool)
type HttpConnection ¶
type HttpConnection struct { *TcpConnection // 内嵌 *TcpConnection // contains filtered or unexported fields }
func NewHttpConnection ¶
func NewHttpConnection(tcpConnection *TcpConnection) *HttpConnection
func (*HttpConnection) FinishChunk ¶
func (this *HttpConnection) FinishChunk() error
func (*HttpConnection) ReadRequest ¶
func (this *HttpConnection) ReadRequest(timeout time.Duration) (*HttpRequest, error)
func (*HttpConnection) ReadResponse ¶
func (this *HttpConnection) ReadResponse(timeout time.Duration) (*HttpResponse, error)
func (*HttpConnection) ReadToRequest ¶
func (this *HttpConnection) ReadToRequest(request *HttpRequest, timeout time.Duration) (*HttpRequest, error)
func (*HttpConnection) SendChunk ¶
func (this *HttpConnection) SendChunk(s string) error
func (*HttpConnection) WriteChunkedHeader ¶
func (this *HttpConnection) WriteChunkedHeader(response *HttpResponse, timeout time.Duration) error
func (*HttpConnection) WriteRequest ¶
func (this *HttpConnection) WriteRequest(request *HttpRequest, timeout time.Duration) error
func (*HttpConnection) WriteResponse ¶
func (this *HttpConnection) WriteResponse(response *HttpResponse, timeout time.Duration) error
func (*HttpConnection) WriteResponseStream ¶
func (this *HttpConnection) WriteResponseStream(stream []byte, timeout time.Duration) error
type HttpMessage ¶
type HttpRequest ¶
type HttpRequest struct {
// contains filtered or unexported fields
}
func NewHttpRequest ¶
func NewHttpRequest() *HttpRequest
func (*HttpRequest) Chas ¶
func (this *HttpRequest) Chas(key string) bool
func (*HttpRequest) Cint ¶
func (this *HttpRequest) Cint(key string) int
func (*HttpRequest) Cookies ¶
func (this *HttpRequest) Cookies() map[string]string
func (*HttpRequest) Cstr ¶
func (this *HttpRequest) Cstr(key string) string
func (*HttpRequest) GetRemoteIp ¶
func (this *HttpRequest) GetRemoteIp() string
func (*HttpRequest) Gets ¶
func (this *HttpRequest) Gets() map[string]string
func (*HttpRequest) Ghas ¶
func (this *HttpRequest) Ghas(key string) bool
func (*HttpRequest) Gint ¶
func (this *HttpRequest) Gint(key string) int
func (*HttpRequest) Gstr ¶
func (this *HttpRequest) Gstr(key string) string
func (*HttpRequest) Header ¶
func (this *HttpRequest) Header(key string) string
func (*HttpRequest) IsDelete ¶
func (this *HttpRequest) IsDelete() bool
func (*HttpRequest) IsGet ¶
func (this *HttpRequest) IsGet() bool
func (*HttpRequest) IsKeepAlive ¶
func (this *HttpRequest) IsKeepAlive() bool
func (*HttpRequest) IsPost ¶
func (this *HttpRequest) IsPost() bool
func (*HttpRequest) IsPut ¶
func (this *HttpRequest) IsPut() bool
func (*HttpRequest) Method ¶
func (this *HttpRequest) Method() string
func (*HttpRequest) PathInfo ¶
func (this *HttpRequest) PathInfo() string
func (*HttpRequest) Phas ¶
func (this *HttpRequest) Phas(key string) bool
func (*HttpRequest) Pint ¶
func (this *HttpRequest) Pint(key string) int
func (*HttpRequest) Posts ¶
func (this *HttpRequest) Posts() map[string]string
func (*HttpRequest) Pstr ¶
func (this *HttpRequest) Pstr(key string) string
func (*HttpRequest) Rint ¶
func (this *HttpRequest) Rint(key string) int
func (*HttpRequest) Rstr ¶
func (this *HttpRequest) Rstr(key string) string
func (*HttpRequest) SetHeader ¶
func (this *HttpRequest) SetHeader(key string, value string)
func (*HttpRequest) SetMethod ¶
func (this *HttpRequest) SetMethod(method string)
func (*HttpRequest) SetPosts ¶
func (this *HttpRequest) SetPosts(posts map[string]string)
func (*HttpRequest) SetPstr ¶
func (this *HttpRequest) SetPstr(key, value string)
func (*HttpRequest) SetRemoteIp ¶
func (this *HttpRequest) SetRemoteIp(ip string)
func (*HttpRequest) SetUri ¶
func (this *HttpRequest) SetUri(uri string)
func (*HttpRequest) SetVar ¶
func (this *HttpRequest) SetVar(key string, value interface{})
func (*HttpRequest) SetVersion ¶
func (this *HttpRequest) SetVersion(version string)
func (*HttpRequest) Stream ¶
func (this *HttpRequest) Stream() []byte
func (*HttpRequest) String ¶
func (this *HttpRequest) String() string
func (*HttpRequest) Uri ¶
func (this *HttpRequest) Uri() string
func (*HttpRequest) Var ¶
func (this *HttpRequest) Var(key string) interface{}
func (*HttpRequest) Version ¶
func (this *HttpRequest) Version() string
type HttpResponse ¶
type HttpResponse struct {
// contains filtered or unexported fields
}
func NewHttpResponse ¶
func NewHttpResponse() *HttpResponse
func (*HttpResponse) BodyStream ¶
func (this *HttpResponse) BodyStream() []byte
func (*HttpResponse) BodyString ¶
func (this *HttpResponse) BodyString() string
func (*HttpResponse) ChunkedStream ¶
func (this *HttpResponse) ChunkedStream() []byte
func (*HttpResponse) Code ¶
func (this *HttpResponse) Code() int
func (*HttpResponse) Header ¶
func (this *HttpResponse) Header(key string) string
func (*HttpResponse) IsConnectionClose ¶
func (this *HttpResponse) IsConnectionClose() bool
func (*HttpResponse) Putb ¶
func (this *HttpResponse) Putb(stream []byte)
func (*HttpResponse) Puts ¶
func (this *HttpResponse) Puts(content string)
func (*HttpResponse) SetBodyStream ¶
func (this *HttpResponse) SetBodyStream(bodyStream []byte)
func (*HttpResponse) SetBodyString ¶
func (this *HttpResponse) SetBodyString(bodyString string)
func (*HttpResponse) SetCode ¶
func (this *HttpResponse) SetCode(code int)
func (*HttpResponse) SetHeader ¶
func (this *HttpResponse) SetHeader(key string, value string)
func (*HttpResponse) SetHeaderWithChunkedMode ¶
func (this *HttpResponse) SetHeaderWithChunkedMode()
func (*HttpResponse) SetHeaderWithContentLength ¶
func (this *HttpResponse) SetHeaderWithContentLength(length string)
func (*HttpResponse) SetStatus ¶
func (this *HttpResponse) SetStatus(code int, phrase string)
func (*HttpResponse) SetVersion ¶
func (this *HttpResponse) SetVersion(version string)
func (*HttpResponse) Status ¶
func (this *HttpResponse) Status() (int, string)
func (*HttpResponse) Stream ¶
func (this *HttpResponse) Stream() []byte
func (*HttpResponse) String ¶
func (this *HttpResponse) String() string
func (*HttpResponse) Version ¶
func (this *HttpResponse) Version() string
type INetwork ¶
type INetwork interface { net.Conn // network type: tcp, websocket or ... Type() string // read specified length from the network interface ReadStream(b []byte, n int) error // write bytes to the network interface WriteBytes(b []byte, t time.Duration) (int, error) // get remote ip RemoteIp() string }
type MiopBuffer ¶
type MiopBuffer struct { Version int16 OpCode int16 PropLen int16 DataLen int32 Prop map[string]string Data []byte }
*
- 已定义的 Prop 下标有: *
- t:300
- u:hello@world
- k:0 (kick, 缺省是1)
- d:0 (durable, 缺省是1)
- c:1 (缺省不带该key)
- OpCode只在version=5时存在
func NewMiopBuffer ¶
func NewMiopBuffer() *MiopBuffer
func (*MiopBuffer) HasProp ¶
func (this *MiopBuffer) HasProp(key string) bool
func (*MiopBuffer) IsEmpty ¶
func (this *MiopBuffer) IsEmpty() bool
func (*MiopBuffer) IsMessage ¶
func (this *MiopBuffer) IsMessage() bool
func (*MiopBuffer) ReadFrom ¶
func (this *MiopBuffer) ReadFrom(tcpConnection *TcpConnection, timeout time.Duration) error
func (*MiopBuffer) ReadUpdateData ¶
func (this *MiopBuffer) ReadUpdateData(offset int) (string, int, error)
获取上行数据的data字段,返回data,本次解析到的offset
func (*MiopBuffer) Reset ¶
func (this *MiopBuffer) Reset() error
func (*MiopBuffer) Stream ¶
func (this *MiopBuffer) Stream() []byte
func (*MiopBuffer) WriteTo ¶
func (this *MiopBuffer) WriteTo(tcpConnection *TcpConnection, timeout time.Duration) error
type RpcRequest ¶
func NewRpcRequest ¶
func NewRpcRequest() *RpcRequest
type RpcResponse ¶
type RpcResponse struct { Result bool Reason string Code int Args map[string]interface{} Data interface{} }
func NewRpcResponse ¶
func NewRpcResponse() *RpcResponse
type TLSConnection ¶
func ShakeTLS ¶
func ShakeTLS(tcpConn *TcpConnection) (*TLSConnection, error)
func (*TLSConnection) IsHTTPProto ¶
func (c *TLSConnection) IsHTTPProto() bool
func (*TLSConnection) ReadStream ¶
func (c *TLSConnection) ReadStream(b []byte, n int) error
func (*TLSConnection) RemoteIp ¶
func (c *TLSConnection) RemoteIp() string
func (*TLSConnection) Type ¶
func (c *TLSConnection) Type() string
func (*TLSConnection) WriteBytes ¶
type TcpConnection ¶
tcp 连接
func TcpConnect ¶
func TcpConnect(localAddress string, remoteAddress string, timeout time.Duration) (*TcpConnection, error)
连接一个 tcp 地址
func (*TcpConnection) IsCrossDomain ¶
func (this *TcpConnection) IsCrossDomain() bool
func (*TcpConnection) IsHttpProto ¶
func (this *TcpConnection) IsHttpProto() bool
func (*TcpConnection) IsXimpProto ¶
func (this *TcpConnection) IsXimpProto() bool
func (*TcpConnection) ReadProtoBuffer ¶
func (this *TcpConnection) ReadProtoBuffer() error
func (*TcpConnection) ReadRpcRequest ¶
func (this *TcpConnection) ReadRpcRequest(timeout time.Duration) (*RpcRequest, error)
func (*TcpConnection) ReadStream ¶
func (this *TcpConnection) ReadStream(stream []byte, count int) error
func (*TcpConnection) Rpc ¶
func (this *TcpConnection) Rpc(request *RpcRequest, readTimeout time.Duration, writeTimeout time.Duration) (*RpcResponse, error)
func (*TcpConnection) Type ¶
func (this *TcpConnection) Type() string
func (*TcpConnection) WriteBytes ¶
func (*TcpConnection) WriteRpcResponse ¶
func (this *TcpConnection) WriteRpcResponse(response *RpcResponse, timeout time.Duration) error
type TcpListener ¶
type TcpListener struct {
*net.TCPListener
}
tcp 监听器
func (*TcpListener) Accept ¶
func (this *TcpListener) Accept() (*TcpConnection, error)
type WebSocketConnection ¶
type WebSocketConnection struct { *websocket.Conn ReadBuffer []byte // contains filtered or unexported fields }
func ShakeWebSocket ¶
func ShakeWebSocket(tcp *TcpConnection, req *http.Request) (*WebSocketConnection, error)
func (*WebSocketConnection) ReadStream ¶
func (w *WebSocketConnection) ReadStream(stream []byte, count int) error
func (*WebSocketConnection) RemoteIp ¶
func (w *WebSocketConnection) RemoteIp() string
func (*WebSocketConnection) SetDeadline ¶
func (w *WebSocketConnection) SetDeadline(t time.Time) error
func (*WebSocketConnection) Type ¶
func (w *WebSocketConnection) Type() string
func (*WebSocketConnection) Write ¶
func (w *WebSocketConnection) Write(b []byte) (n int, err error)
func (*WebSocketConnection) WriteBytes ¶
type WebSocketSecureConnection ¶
type WebSocketSecureConnection struct { *websocket.Conn ReadBuffer []byte // contains filtered or unexported fields }
func ShakeWebSocketSecure ¶
func ShakeWebSocketSecure(tls *TLSConnection, req *http.Request) (*WebSocketSecureConnection, error)
func (*WebSocketSecureConnection) Read ¶
func (w *WebSocketSecureConnection) Read(b []byte) (n int, err error)
func (*WebSocketSecureConnection) ReadStream ¶
func (w *WebSocketSecureConnection) ReadStream(stream []byte, count int) error
func (*WebSocketSecureConnection) RemoteIp ¶
func (w *WebSocketSecureConnection) RemoteIp() string
func (*WebSocketSecureConnection) SetDeadline ¶
func (w *WebSocketSecureConnection) SetDeadline(t time.Time) error
func (*WebSocketSecureConnection) Type ¶
func (w *WebSocketSecureConnection) Type() string
func (*WebSocketSecureConnection) Write ¶
func (w *WebSocketSecureConnection) Write(b []byte) (n int, err error)
func (*WebSocketSecureConnection) WriteBytes ¶
type XimpBuffer ¶
type XimpBuffer struct { IsHeartbeat bool // 是否是心跳包 IsDecrypt bool // 是否已经解密,false时是加密, IsClient bool // 是否是客户端发上来的包 HasHeader bool // 是否有magic或者flag Version uint16 // 协议版本, 4个bit CVersion uint16 // 客户端版本,12个bit Appid uint16 // 2字节 Reserved [6]byte // 6个字节的保留字段 DataStream []byte // proto数据 // 业务相关 TimeStamp int64 // 用于chatroom发送消息时的延迟统计 TraceId string // 客户端发上来的跟踪ID }
客户端与服务端的第一次回包
func NewXimpBuffer ¶
func NewXimpBuffer() *XimpBuffer
func (*XimpBuffer) Decrypt ¶
func (this *XimpBuffer) Decrypt(rkey []byte) error
func (*XimpBuffer) Encrypt ¶
func (this *XimpBuffer) Encrypt(rkey []byte) error
func (*XimpBuffer) String ¶
func (this *XimpBuffer) String() string
func (*XimpBuffer) WriteTo ¶
func (this *XimpBuffer) WriteTo(tcpConnection *TcpConnection, timeout time.Duration) error
Click to show internal directories.
Click to hide internal directories.