Пример #1
0
        public SOEProtocol(SOEServer server, string protocol)
        {
            // This components settings
            Server         = server;
            ProtocolString = protocol;

            // Make our protocol known
            MessageHandlers.MakeProtocol(protocol);

            // Log
            Log("Service constructed");
            Log("Using protocol -- {0}", ProtocolString);
        }
Пример #2
0
        public SOEServer(int port, string protocol = "SOE")
        {
            // Log
            Log("Initiating server on port: {0}", port);

            // UDP Listener
            UdpClient = new UdpClient(port);
            Port      = port;

            // Server components
            ConnectionManager = new SOEConnectionManager(this);
            Protocol          = new SOEProtocol(this, protocol);

            IncomingPackets  = new ConcurrentQueue <SOEPendingPacket>();
            IncomingMessages = new ConcurrentQueue <SOEPendingMessage>();

            // Initialize our message handlers
            Log("Initializing message handlers");
            MessageHandlers.Initialize();
            Log("Initiated server");
        }
Пример #3
0
        public void HandleMessage(SOEClient sender, SOEMessage message)
        {
            // Handlers
            if (MessageHandlers.HasHandler(ProtocolString, message.GetOpCode()))
            {
                // Log
                string messageName = MessageHandlers.Protocol2MessageName[ProtocolString][message.GetOpCode()];
                Log("Received 0x{0:X}, {1}_{2}!", message.GetOpCode(), Server.GAME_NAME, messageName);

                // Handle it
                MessageHandlers.GetHandler(ProtocolString, message.GetOpCode())(sender, message);
            }
            else
            {
                // Log
                Log("Received Unknown SOEMessage {0}!", message.GetOpCode());
                foreach (byte b in message.GetRaw())
                {
                    Console.Write("0x{0:X2} ", b);
                }
                Console.WriteLine();
            }
        }