Beispiel #1
0
        // Notifies a peer with a command, no response expected
        internal void Reply(LevinPeer Peer, int CommandCode, byte[] Data, bool RequestSuccessul = false, bool ResponseRequired = false)
        {
            // Form message header
            BucketHead2 Header = new BucketHead2
            {
                Signature        = GlobalsConfig.LEVIN_SIGNATURE,
                ResponseRequired = ResponseRequired,
                PayloadSize      = (ulong)Data.Length,
                CommandCode      = (uint)CommandCode,
                ProtocolVersion  = GlobalsConfig.LEVIN_VERSION,
                Flags            = LEVIN_PACKET_RESPONSE,
                ReturnCode       = RequestSuccessul? LEVIN_RETCODE_SUCCESS : LEVIN_RETCODE_FAILURE
            };

            // Debug
            Logger?.Log(Level.DEBUG, "Sending header:");
            Logger?.Log(Level.DEBUG, " - Signature: {0}", Header.Signature);
            Logger?.Log(Level.DEBUG, " - Payload Size: {0}", Header.PayloadSize);
            Logger?.Log(Level.DEBUG, " - Response Required: {0}", Header.ResponseRequired);
            Logger?.Log(Level.DEBUG, " - Command Code: {0}", Header.CommandCode);
            Logger?.Log(Level.DEBUG, " - Return Code: {0}", Header.ReturnCode);
            Logger?.Log(Level.DEBUG, " - Flags: {0}", Header.Flags);
            Logger?.Log(Level.DEBUG, " - Protocol Version: {0}", Header.ProtocolVersion);

            // Send header packet
            if (Server.SendMessage(Peer.Connection, Header.Serialize()))
            {
                // Send body packet
                Server.SendMessage(Peer.Connection, Data);
            }
        }
Beispiel #2
0
        // Notifies a peer with a command, no response expected
        public void Reply(LevinPeer Peer, int CommandCode, byte[] Data, bool RequestSuccessul = false, bool ResponseRequired = false)
        {
            // Form message header
            BucketHead2 Header = new BucketHead2
            {
                Signature        = GlobalsConfig.LEVIN_SIGNATURE,
                ResponseRequired = ResponseRequired,
                PayloadSize      = (ulong)Data.Length,
                CommandCode      = (uint)CommandCode,
                ProtocolVersion  = GlobalsConfig.LEVIN_VERSION,
                Flags            = LEVIN_PACKET_RESPONSE,
                ReturnCode       = RequestSuccessul? LEVIN_RETCODE_SUCCESS : LEVIN_RETCODE_FAILURE
            };

            // Debug
            ConsoleMessage.WriteLine(ConsoleMessage.DefaultColor, "Sending header:", LogLevel.DEBUG);
            ConsoleMessage.WriteLine(ConsoleMessage.DefaultColor, " - Signature: " + Header.Signature, LogLevel.DEBUG);
            ConsoleMessage.WriteLine(ConsoleMessage.DefaultColor, " - Payload Size: " + Header.PayloadSize, LogLevel.DEBUG);
            ConsoleMessage.WriteLine(ConsoleMessage.DefaultColor, " - Response Required: " + Header.ResponseRequired, LogLevel.DEBUG);
            ConsoleMessage.WriteLine(ConsoleMessage.DefaultColor, " - Command Code: " + Header.CommandCode, LogLevel.DEBUG);
            ConsoleMessage.WriteLine(ConsoleMessage.DefaultColor, " - Return Code: " + Header.ReturnCode, LogLevel.DEBUG);
            ConsoleMessage.WriteLine(ConsoleMessage.DefaultColor, " - Flags: " + Header.Flags, LogLevel.DEBUG);
            ConsoleMessage.WriteLine(ConsoleMessage.DefaultColor, " - Protocol Version: " + Header.ProtocolVersion, LogLevel.DEBUG);

            // Send header packet
            if (Server.SendMessage(Peer.Connection, Header.Serialize()))
            {
                // Send body packet
                Server.SendMessage(Peer.Connection, Data);
            }
        }
Beispiel #3
0
        // Notifies all peers with a command, no response expected
        internal void NotifyAll(int CommandCode, byte[] Data)
        {
            // Form message header
            BucketHead2 Header = new BucketHead2
            {
                Signature        = GlobalsConfig.LEVIN_SIGNATURE,
                ResponseRequired = false,
                PayloadSize      = (ulong)Data.Length,
                CommandCode      = (uint)CommandCode,
                ProtocolVersion  = GlobalsConfig.LEVIN_VERSION,
                Flags            = LEVIN_PACKET_REQUEST
            };

            // Send header packet
            Server.Broadcast(Header.Serialize());

            // Send body packet
            Server.Broadcast(Data);
        }
Beispiel #4
0
        // Notifies a peer with a command, no response expected
        internal void Notify(PeerConnection Peer, int CommandCode, byte[] Data)
        {
            // Form message header
            BucketHead2 Header = new BucketHead2
            {
                Signature        = GlobalsConfig.LEVIN_SIGNATURE,
                ResponseRequired = false,
                PayloadSize      = (ulong)Data.Length,
                CommandCode      = (uint)CommandCode,
                ProtocolVersion  = LEVIN_PROTOCOL_VER_1,
                Flags            = LEVIN_PACKET_REQUEST
            };

            // Send header packet
            if (Server.SendMessage(Peer, Header.Serialize()))
            {
                // Send body packet
                Server.SendMessage(Peer, Data);
            }
        }