This commit is contained in:
aozhiwei 2023-08-11 13:04:27 +08:00
parent 6674f3e8f8
commit 4a063bd14e

View File

@ -138,22 +138,18 @@ func (this *WSPListener_) parseNetPkt() {
func (this *WSPListener_) sendProxyMsg(conn net.Conn, socketHandle uint16, msg proto.Message) {
netMsg := msg.(f5.NetMsg)
msgId := netMsg.GetNetMsgId()
msgData, err := proto.Marshal(msg)
if err != nil {
return
}
buff := make([]byte, len(msgData) + 16)
buff[0] = byte(len(msgData) & 0xFF)
buff[1] = byte((len(msgData) & 0xFFFF) >> 8)
buff[2] = byte(msgId & 0xFF)
buff[3] = byte((msgId & 0xFFFF) >> 8)
buff[8] = byte('K')
buff[9] = byte('S')
msgHead := f5.WSProxyPackHead_S{}
msgHead.PackLen = uint16(len(msgData))
msgHead.MsgId = netMsg.GetNetMsgId()
msgHead.MagicCode = f5.NET_MSG_MAGIC_CODE
msgHead.SocketHandle = socketHandle
buff[12] = byte(socketHandle & 0xFF)
buff[13] = byte((socketHandle & 0xFFFF) >> 8)
copy(buff[16:], msgData[:])
buff := make([]byte, len(msgData) + f5.WSPROXYPACKHEAD_S_SIZE)
msgHead.Write(buff, 0);
copy(buff[f5.WSPROXYPACKHEAD_S_SIZE:], msgData[:])
conn.Write(buff)
}