Exemplo n.º 1
0
        public SyncClient(SilverSocket socket)
            : base(socket)
        {
            this.ReceivedDatas += new ReceiveDatasHandler(this.PacketsReceived);
            this.DisconnectedSocket += new DisconnectedSocketHandler(this.Disconnected);

            _state = State.OnAuthentication;
            _packetLocker = new object();

            Server = null;

            Send("HCS");
        }
Exemplo n.º 2
0
        private void Authentication(int serverId, string serverIp, int serverPort)
        {
            if (Entities.Requests.ServersRequests.Cache.Any(x => x.ID == serverId && x.IP == serverIp && x.Port == serverPort && x.State == 0))
            {
                var requieredServer = Entities.Requests.ServersRequests.Cache.First(x => x.ID == serverId && x.IP == serverIp && x.Port == serverPort && x.State == 0);

                if (!myIp().Contains(serverIp))
                {
                    Disconnect();
                    return;
                }

                Server = requieredServer;

                Send("HCSS");
                ChangeState(SyncClient.State.OnConnected);

                Utilities.Loggers.InfosLogger.Write(string.Format("Sync <{0}> authentified !", this.myIp()));
            }
            else
                Disconnect();
        }
Exemplo n.º 3
0
        private void Authentication(string[] datas)
        {
            var serverId = 0;
            var serverPort = 0;

            if (datas.Length < 4 || !int.TryParse(datas[1], out serverId) || !int.TryParse(datas[3], out serverPort))
            {
                Disconnect();
                return;
            }

            var serverIp = datas[2];
            var pass = datas[4];

            if (Entities.Requests.ServersRequests.Cache.Any(x => x.ID == serverId && x.IP == serverIp && x.Port == serverPort && x.State == 0))
            {
                var requieredServer = Entities.Requests.ServersRequests.Cache.First(x => x.ID == serverId && x.IP == serverIp && x.Port == serverPort && x.State == 0);

                if (!IP.Contains(serverIp) || pass != requieredServer.PassKey)
                {
                    Disconnect();
                    return;
                }

                Server = requieredServer;
                Send(new Packets.PHelloConnectSuccess().GetPacket());

                ChangeState(SyncClient.State.OnConnected, true);
                Utilities.Loggers.Debug.Write(string.Format("Sync <{0}> authentified !", this.IP));
            }
            else
                Disconnect();
        }