Example #1
0
        /// <summary>
        ///     Writes the message header
        /// </summary>
        private void WriteHeader(PiranhaMessage message, byte[] packet, int encodingLength)
        {
            int messageType    = message.GetMessageType();
            int messageVersion = message.GetMessageVersion();

            packet[1] = (byte)(messageType);
            packet[0] = (byte)(messageType >> 8);
            packet[4] = (byte)(encodingLength);
            packet[3] = (byte)(encodingLength >> 8);
            packet[2] = (byte)(encodingLength >> 16);
            packet[6] = (byte)(messageVersion);
            packet[5] = (byte)(messageVersion >> 8);
        }
Example #2
0
 public void SendPiranhaMessage(PiranhaMessage message, int serverType)
 {
     if (message.GetByteStream().GetLength() == 0)
     {
         message.Encode();
     }
     this.SendMessage(new ForwardLogicMessage
     {
         MessageType    = message.GetMessageType(),
         MessageVersion = (short)message.GetMessageVersion(),
         MessageLength  = message.GetEncodingLength(),
         MessageBytes   = message.GetByteStream().GetByteArray()
     }, serverType);
 }
        private static ForwardLogicMessage CreateForwardLogicMessage(PiranhaMessage piranhaMessage, long sessionId)
        {
            if (piranhaMessage.GetEncodingLength() == 0)
            {
                piranhaMessage.Encode();
            }

            return(new ForwardLogicMessage
            {
                SessionId = sessionId,
                MessageType = piranhaMessage.GetMessageType(),
                MessageVersion = (short)piranhaMessage.GetMessageVersion(),
                MessageLength = piranhaMessage.GetEncodingLength(),
                MessageBytes = piranhaMessage.GetMessageBytes()
            });
        }
        public void SendPiranhaMessageToProxy(PiranhaMessage piranhaMessage)
        {
            if (piranhaMessage.GetEncodingLength() == 0)
            {
                piranhaMessage.Encode();
            }

            ServerMessageManager.SendMessage(new ForwardLogicMessage
            {
                SessionId      = this.SessionId,
                MessageType    = piranhaMessage.GetMessageType(),
                MessageVersion = (short)piranhaMessage.GetMessageVersion(),
                MessageLength  = piranhaMessage.GetEncodingLength(),
                MessageBytes   = piranhaMessage.GetMessageBytes()
            }, ServerManager.GetProxySocket(this.SessionId));
        }
        private static void WriteHeader(PiranhaMessage message, byte[] stream, int length)
        {
            int messageType    = message.GetMessageType();
            int messageVersion = message.GetMessageVersion();

            stream[0] = (byte)(messageType >> 8);
            stream[1] = (byte)(messageType);
            stream[2] = (byte)(length >> 16);
            stream[3] = (byte)(length >> 8);
            stream[4] = (byte)(length);
            stream[5] = (byte)(messageVersion >> 8);
            stream[6] = (byte)(messageVersion);

            if (length > 0xFFFFFF)
            {
                Debugger.Error("NetworkMessaging::writeHeader trying to send too big message, type " + messageType);
            }
        }
Example #6
0
        /// <summary>
        ///     Writes the message header to buffer.
        /// </summary>
        internal static void WriteHeader(PiranhaMessage message, byte[] buffer, int length)
        {
            int messageType    = message.GetMessageType();
            int messageVersion = message.GetMessageVersion();

            buffer[1] = (byte)messageType;
            buffer[0] = (byte)(messageType >> 8);
            buffer[4] = (byte)length;
            buffer[3] = (byte)(length >> 8);
            buffer[2] = (byte)(length >> 16);
            buffer[6] = (byte)messageVersion;
            buffer[5] = (byte)(messageVersion >> 8);

            if (length > 0xFFFFFF)
            {
                Debugger.Error("Trying to send too big message, type " + messageType);
            }
        }
        private void SendForwardLogicMessageRequestMessage(PiranhaMessage piranhaMessage, ServerSocket socket)
        {
            if (socket != null)
            {
                if (this.IsRequestPiranhaMessage(piranhaMessage) && !this.CanSendRequest(piranhaMessage.GetMessageType()))
                {
                    return;
                }

                ServerMessageManager.SendMessage(new ForwardLogicRequestMessage
                {
                    SessionId      = this.m_connection.Session.Id,
                    AccountId      = this.m_connection.Session.AccountId,
                    MessageType    = piranhaMessage.GetMessageType(),
                    MessageVersion = (short)piranhaMessage.GetMessageVersion(),
                    MessageLength  = piranhaMessage.GetEncodingLength(),
                    MessageBytes   = piranhaMessage.GetMessageBytes()
                }, socket);
            }
        }