public static BinaryMessage CreateBinary(byte[] content) { var binary = new BinaryMessage(); const int intLen = sizeof(int); if (content.Length < intLen) { Debug.LogError($"== Change Error == len:[{content.Length}]"); return(binary); } var proctorId = BitConverter.ToInt32(content, 0); binary.ProtocolId = proctorId; if (content.Length == intLen) { return(binary); } var messageLen = content.Length - intLen; var message_array = new byte[messageLen]; Array.Copy(content, intLen, message_array, 0, messageLen); binary.SetReceiveBuffer(message_array); return(binary); }
public static void StockNetMessage(byte[] ctx) { var message = BinaryMessage.CreateBinary(ctx); // if (message.ProtocolId != 87) // { // Debug.LogWarning($"<-- Dispatcher <-- Protocol ID:[{message.ProtocolId}]"); // } _netMessageQueue.Enqueue(message); }
public void Send(BinaryMessage binary, bool log = true) { if (!_tcpConnection.IsConnected || waitServerResponse) { Debug.LogError($"== Send == -- Net Disconnected -- ID: {binary.ProtocolId}"); _waitSend.Enqueue(binary); return; } if (log && binary.ProtocolId != 99) { Debug.Log($"~~~~~~~~~~~ Send Message ID:[{binary.ProtocolId}] ~~~~~~~~~~~"); } var buffLen = binary.GetSendBuffer().Length; if (buffLen > 8000) { Debug.LogError($"!!!!!!!!!!!!! Send Message too large: {buffLen}"); } Send(binary.GetSendBuffer()); }
public void SaveUserInfo(BinaryMessage binary) { _userInfo = binary; }