/// <summary>
 /// Server accept socket event, create a new session for the socket.
 /// </summary>
 /// <param name="socket"></param>
 public static void ServerOnAcceptSocketEvent(SilverSocket socket)
 {
     try
     {
         lobbyClient session = new lobbyClient(socket);
     }
     catch (Exception ex) { error(ex.ToString()); }
 }
Esempio n. 2
0
        /// <summary>
        /// Server accept socket event, create a new session for the socket.
        /// </summary>
        /// <param name="socket"></param>
        public static void ServerOnAcceptSocketEvent(SilverSocket socket)
        {
            try
            {
                StreamReader Reader = new StreamReader(AppDomain.CurrentDomain.BaseDirectory + "\\whitelist.txt");
                lock (Clients)
                {
                    string[] splitIP = socket.IP.Split(':');
                    if (Reader.ReadToEnd().Contains(splitIP[0]))
                    { // IP Whitelisted Check 1/1
                        lobbyClient _client = new lobbyClient(socket); // Add the connected socket to the client list
                        Clients.Add(_client);

                        // Repeat what we did with world server
                        var client = mmoServer.Clients.Find(x => x.info.ip == splitIP[0]); // Search the right client in the list by IP
                        if (client.info.sessionKey != null)
                        {// If client exists

                            // Switch client's data from world server to lobby server
                            _client.info.ip = client.info.ip;
                            _client.info.id = client.info.id;
                            _client.info.last_login = client.info.last_login;
                            _client.info.type = client.info.type;
                            _client.info.username = client.info.username;
                            _client.info.sessionKey = client.info.sessionKey;
                            _client.info.last_login = client.info.last_login;
                            _client.info.rank = client.info.rank;
                            _client.info.level = client.info.level;
                            _client.info.type = client.info.type;
                            _client.info.exp = client.info.exp;
                            _client.info.licence = client.info.licence;
                            _client.info.gpotatos = client.info.gpotatos;
                            _client.info.rupees = client.info.rupees;
                            _client.info.coins = client.info.coins;
                            _client.info.questpoints = client.info.questpoints;
                            _client.info.bio = client.info.bio;
                            _client.info.s_zone = client.info.s_zone;
                            _client.info.clan_id = client.info.clan_id;
                            _client.info.clan_name = client.info.clan_name;
                        }
                    }
                    else
                    {
                        Error.Invoke("'" + socket.IP + "', is not whitelisted yet.");
                    }
                }
            }
            catch (Exception ex)
            {
                Error.Invoke((ex.ToString()));
            }
        }