コード例 #1
0
        internal static void Route(JamServerConnection serverConnection, JamPacket packet)
        {
            JamServer server    = serverConnection.Server;
            Guid      recipient = packet.Header.Receipient;

            if (recipient == Guid.Empty)
            {
                InternalServerInterpreter.Interpret(serverConnection, packet);
                return;
            }

            JamServerConnection recipientConnection = server.GetConnection(recipient);

            if (recipientConnection == null)
            {
                server.OnUndelieveredMessageReceived(new JamServer.MessageReceivedEventArgs()
                {
                    ServerConnection = serverConnection, Packet = packet
                });
            }
            else
            {
                recipientConnection.Send(packet);
            }
        }
コード例 #2
0
        public JamServerConnection(TcpClient client, SslStream stream, JamServer server)
        {
            const int DISCONNECT_POLL_FREQUENCY = 500;

            Server     = server;
            Serializer = server.Serializer;

            Client      = client;
            this.stream = stream;
            alive       = true;

            Task.Run(() => Listen());
            Task.Run(() => SendPacketsFromQueue());
            Task.Run(() => PollConnection(DISCONNECT_POLL_FREQUENCY));

            Server.OnClientConnected(new JamServer.ConnectionEventArgs()
            {
                ServerConnection = this, RemoteEndPoint = Client.Client.RemoteEndPoint
            });
        }