Exemplo n.º 1
0
        private void Listen()
        {
            listener.Start();

            Log.Notice("Channel Server listening for clients on {0}", listener.LocalEndpoint);

            while (true)
            {
                // blocks until a client has connected to the server
                TcpClient client = this.listener.AcceptTcpClient();

                Log.Notice("Client {0} connected to Channel Server", client.Client.RemoteEndPoint);

                int   timestamp = Environment.TickCount - ticks;
                ulong key       = ((ulong)count << 32) + (ulong)timestamp;
                var   c         = new ClientHandler(client, packets, events);
                c.Metadata["timestamp"] = (uint)timestamp;
                c.Metadata["count"]     = (ushort)count++;
                c.Metadata["magic"]     = key;
                c.Metadata["proxy"]     = proxy;
                c.Metadata["database"]  = database;
                c.Metadata["clients"]   = clients;
                c.Metadata["server"]    = server;
                c.Start();
                clients.Add(key, c);
            }
        }
Exemplo n.º 2
0
        void Listen()
        {
            listener.Start();

            Log.Notice("Login Server listening for clients on {0}", listener.LocalEndpoint);

            while (true)
            {
                // Waits for a client to connect to the server
                var client = listener.AcceptTcpClient();

                Log.Notice("Client {0} connected to Login Server", client.Client.RemoteEndPoint);

                string[] url = { Configuration.CashURL, Configuration.CashChargeURL, Configuration.GuildURL };
                int[]    ver = { Configuration.ClientVersion, Configuration.NormalMagicKey, Configuration.IgnoreClientVersion };

                var timestamp = Environment.TickCount - ticks;
                var key       = ((ulong)count << 32) + (ulong)timestamp;
                var c         = new ClientHandler(client, packets, events);
                c.Metadata["timestamp"]  = (uint)timestamp;
                c.Metadata["count"]      = (ushort)count++;
                c.Metadata["magic"]      = key;
                c.Metadata["url"]        = url;
                c.Metadata["version"]    = ver;
                c.Metadata["syncServer"] = syncServer;
                c.Start();
                clients.Add(c);
            }
        }
Exemplo n.º 3
0
        void Listen()
        {
            listener.Start();

            Log.Notice("Channel Server listening for clients on {0}", listener.LocalEndpoint);

            while (true)
            {
                // blocks until a client has connected to the server
                TcpClient client = this.listener.AcceptTcpClient();

                Log.Notice("Client {0} connected to Channel Server", client.Client.RemoteEndPoint);

                int   timestamp = Environment.TickCount - ticks;
                ulong key       = ((ulong)count << 32) + (ulong)timestamp;
                var   c         = new ClientHandler(client, packets, events);
                c.Metadata["timestamp"]  = (uint)timestamp;
                c.Metadata["count"]      = (ushort)count++;
                c.Metadata["magic"]      = key;
                c.Metadata["clients"]    = clients;
                c.Metadata["server"]     = server;
                c.Metadata["channel"]    = channel;
                c.Metadata["syncServer"] = syncServer;
                c.Metadata["chServer"]   = this;
                c.Start();


                if (clients.Count > 0)
                {
                    ClientHandler[] clientarr = new ClientHandler[clients.Values.Count];
                    clients.Values.CopyTo(clientarr, 0);
                    ClientHandler d      = clientarr[clientarr.Length - 1];
                    var           oldVal = d.RemoteEndPoint as System.Net.IPEndPoint;
                    var           newVal = c.RemoteEndPoint as System.Net.IPEndPoint;
                    if (!oldVal.Address.Equals(newVal.Address))
                    {
                        clients.Add(key, c);
                    }
                }
                else
                {
                    clients.Add(key, c);
                }

                /*
                 * foreach (var item in clients.Values)
                 * {
                 *  bool alive = (bool)item.Metadata["alive"];
                 *  if (!alive)
                 *  {
                 *      item.Disconnect();
                 *  }
                 * }*/
            }
        }
Exemplo n.º 4
0
        void Listen()
        {
            listener.Start();
            Log.Notice("Login Server listening for clients on {0}", listener.LocalEndpoint);

            while (true)
            {
                // waits for a client to connect to the server
                var client   = listener.AcceptTcpClient();
                var endPoint = client.Client.RemoteEndPoint as IPEndPoint;

                if (conf.WhiteList)
                {
                    string ip = endPoint.Address.ToString();

                    if (!conf.WhiteIps.Contains(ip))
                    {
                        Log.Warning("Client {0} is trying to connect. Disconnecting client...", endPoint);
                        client.Close();

                        continue;
                    }
                }

                Log.Notice("Client {0} connected to Login Server", endPoint);

                if (clients.Count >= conf.MaxUsers)
                {
                    Log.Warning("Server is full: {0} clients connected. Disconnecting client...", clients.Count);

                    client.Close();
                    continue;
                }

                var timestamp = Environment.TickCount - ticks;
                var key       = ((ulong)count << 32) + (ulong)timestamp;
                var c         = new ClientHandler(client, packets, events);

                c.Metadata["timestamp"]  = (uint)timestamp;
                c.Metadata["count"]      = (ushort)count++;
                c.Metadata["magic"]      = key;
                c.Metadata["conf"]       = conf;
                c.Metadata["syncServer"] = syncServer;
                c.Start();

                clients.Add(c);

                /* temporary disabled
                 * // i'm not sure how this works
                 * // client just connected(not logged in yet)
                 * // it won't represent a real client account id(c.AccountID)
                 * Authentication.UpdateOnline(syncServer, c.AccountID, true);*/
            }
        }
Exemplo n.º 5
0
        void Listen()
        {
            listener.Start();

            Log.Notice("Chat Server listening for clients on {0}", listener.LocalEndpoint);

            while (true)
            {
                // Waits for a client to connect to the server
                TcpClient client = this.listener.AcceptTcpClient();

                Log.Notice("Client {0} connected to Chat Server", client.Client.RemoteEndPoint);

                var c = new ClientHandler(client, packets, events);
                c.Metadata["proxy"]    = proxy;
                c.Metadata["database"] = database;
                c.Start();
                clients.Add(c);
            }
        }
Exemplo n.º 6
0
        void Listen()
        {
            listener.Start();

            Log.Notice("Login Server listening for clients on {0}", listener.LocalEndpoint);

            while (true)
            {
                // Waits for a client to connect to the server
                TcpClient client = this.listener.AcceptTcpClient();

                Log.Notice("Client {0} connected to Login Server", client.Client.RemoteEndPoint);

                var c = new ClientHandler(client, packets, events);
                c.Metadata["proxy"]    = proxy;
                c.Metadata["database"] = database;
                c.Metadata["wan"]      = BitConverter.ToUInt32(Configuration.IP.GetAddressBytes(), 0);
                c.Metadata["lan"]      = lan;
                c.Start();
                clients.Add(c);
            }
        }