Esempio n. 1
0
        public void OnRegisterClusterRequestSuccesful(RequestSuccesfulEventArgs args)
        {
            LoginConnector.OnClusterRequestSuccesful -= OnRegisterClusterRequestSuccesful;

            if (args.Accepted)
            {
                RegisterNewChannelRequest newChannelRequest = new RegisterNewChannelRequest(args.Id, (string)Config.GetSetting("ClusterAuthorizationPassword"), "SharpFly Channel", 0, 50, LoginConnector.PublisherSocket);
                LoginConnector.OnNewChannelRequestSuccesful += new LoginConnector.RequestSuccesfulHandler(OnRegisterNewChannelSuccesful);

                this.m_PlayerSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                this.m_PlayerSocket.Bind(new IPEndPoint(IPAddress.Any, 28000));
                this.m_PlayerSocket.Listen(100);

                PlayerManager = new PlayerManager();

                Thread acceptPlayerThread = new Thread(() => PlayerManager.AcceptPlayers(this.m_PlayerSocket));
                acceptPlayerThread.Start();

                Thread processPlayerThread = new Thread(() => PlayerManager.ProcessPlayers());
                processPlayerThread.Start();

                Console.WriteLine("Cluster request succesful!");
            }
            else
            {
                Console.WriteLine("Cluster request wasn't succesful!");
            }
        }