package f5 import ( "q5" "net" ) const ( WSPROXYPACKHEAD_C_SIZE = 20 WSPROXYPACKHEAD_S_SIZE = 16 NET_MSG_MAGIC_CODE = uint16('K') + uint16('S') << 8 ) type MsgNode struct { } type IMMsgNode struct { msgId int16 params q5.Args next *IMMsgNode } type HandlerFunc func(*Context) type middleware struct { middlewareType int32 handlerFunc HandlerFunc entry q5.ListHead } type MsgHdr struct { MsgId uint16 SeqId uint32 SocketHandle uint16 IpSaddr uint32 Conn net.Conn Data []byte Msg interface{} Entry q5.ListHead } type NetMsg interface { GetNetMsgId() uint16 } /* struct WSProxyPackHead_C { unsigned short packlen; unsigned short msgid; unsigned int seqid; unsigned short magic_code; unsigned short socket_handle; unsigned long ip_saddr; }; */ type WSProxyPackHead_C struct { PackLen uint16 MsgId uint16 SeqId uint32 MagicCode uint16 SocketHandle uint16 IpSaddr uint64 } /* struct WSProxyPackHead_S { unsigned short packlen; unsigned short msgid; unsigned int seqid; unsigned short magic_code; unsigned short rpc_error_code; unsigned short socket_handle; unsigned short ext_len; }; */ type WSProxyPackHead_S struct { PackLen uint16 MsgId uint16 SeqId uint32 MagicCode uint16 RpcErrCode uint16 SocketHandle uint16 ExtLen uint16 } func (this *WSProxyPackHead_C) Read(data []byte, offset int) { this.PackLen = q5.MkUInt16(data[offset + 0], data[offset + 1]) this.MsgId = q5.MkUInt16(data[offset + 2], data[offset + 3]) this.SeqId = q5.MkUInt32(data[offset + 4], data[offset + 5], data[offset + 6], data[offset + 7]) this.MagicCode = q5.MkUInt16(data[offset + 8], data[offset + 9]) this.SocketHandle = q5.MkUInt16(data[offset + 10], data[offset + 11]) } func (this *WSProxyPackHead_S) Write(data []byte, offset int) { data[offset + 0] = byte(this.PackLen & 0xFF) data[offset + 1] = byte(this.PackLen >> 8) data[offset + 2] = byte(this.MsgId & 0xFF) data[offset + 3] = byte(this.MsgId >> 8) data[offset + 8] = byte('K') data[offset + 9] = byte('S') data[offset + 12] = byte(this.SocketHandle & 0xFF) data[offset + 13] = byte(this.SocketHandle >> 8) }