Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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());
        }
Esempio n. 4
0
 public void SaveUserInfo(BinaryMessage binary)
 {
     _userInfo = binary;
 }