示例#1
0
        public void ShutdownLayerListener()
        {
            if (this.m_tclLayerListener != null)
            {
                try {
                    PRoConLayerClient[] cplcShutdownClients = new PRoConLayerClient[this.LayerClients.Count];
                    this.LayerClients.CopyTo(cplcShutdownClients, 0);

                    foreach (PRoConLayerClient cplcShutdownClient in cplcShutdownClients)
                    {
                        cplcShutdownClient.OnShutdown();
                        cplcShutdownClient.Shutdown();
                    }

                    //if (this.m_tclLayerListener != null) {
                    this.m_tclLayerListener.Stop();
                    this.m_tclLayerListener = null;
                    //}
                }
                catch (Exception) { }

                if (this.LayerOffline != null)
                {
                    FrostbiteConnection.RaiseEvent(this.LayerOffline.GetInvocationList());
                }
            }
            //this.OnLayerServerOffline();
        }
示例#2
0
 private void client_UidRegistered(PRoConLayerClient sender)
 {
     foreach (PRoConLayerClient clcClient in new List <PRoConLayerClient>(this.LayerClients))
     {
         clcClient.OnRegisteredUid(sender.ProconEventsUid, sender.Username);
     }
 }
示例#3
0
        private static void ListenIncommingLayerConnections(IAsyncResult ar)
        {
            PRoConLayer plLayer = (PRoConLayer)ar.AsyncState;

            if (plLayer.m_tclLayerListener != null)
            {
                try {
                    TcpClient tcpNewConnection = plLayer.m_tclLayerListener.EndAcceptTcpClient(ar);

                    PRoConLayerClient cplcNewConnection = new PRoConLayerClient(new FrostbiteLayerConnection(tcpNewConnection), plLayer.m_praApplication, plLayer.m_prcClient);

                    plLayer.LayerClients.Add(cplcNewConnection);

                    if (plLayer.ClientConnected != null)
                    {
                        FrostbiteConnection.RaiseEvent(plLayer.ClientConnected.GetInvocationList(), cplcNewConnection);
                    }

                    plLayer.m_tclLayerListener.BeginAcceptTcpClient(plLayer.m_asyncAcceptCallback, plLayer);
                }
                catch (SocketException exception) {
                    if (plLayer.LayerSocketError != null)
                    {
                        FrostbiteConnection.RaiseEvent(plLayer.LayerSocketError.GetInvocationList(), exception);
                    }

                    plLayer.ShutdownLayerListener();

                    //cbfAccountsPanel.OnLayerServerSocketError(skeError);
                }
                catch (Exception) {
                }
            }
        }
示例#4
0
 private void client_LayerClientQuit(PRoConLayerClient sender)
 {
     if (this.LayerClients.Contains(sender.IPPort) == true)
     {
         this.LayerClients.Remove(sender.IPPort);
         this.SendAccountLogout(sender.Username);
     }
 }
示例#5
0
 private void PRoConLayer_ClientConnected(PRoConLayerClient client)
 {
     client.Login          += new PRoConLayerClient.LayerClientHandler(client_LayerClientLogin);
     client.Logout         += new PRoConLayerClient.LayerClientHandler(client_LayerClientLogout);
     client.Quit           += new PRoConLayerClient.LayerClientHandler(client_LayerClientQuit);
     client.ClientShutdown += new PRoConLayerClient.LayerClientHandler(client_LayerClientShutdown);
     client.UidRegistered  += new PRoConLayerClient.LayerClientHandler(client_UidRegistered);
 }
示例#6
0
        private void client_LayerClientLogin(PRoConLayerClient sender)
        {
            if (this.LayerClients.Contains(sender.Username) == true)
            {
                // List a logged in account
            }

            foreach (PRoConLayerClient clcClient in new List <PRoConLayerClient>(this.LayerClients))
            {
                clcClient.OnAccountLogin(sender.Username, sender.Privileges);
            }
        }
示例#7
0
        private void client_LayerClientShutdown(PRoConLayerClient sender)
        {
            sender.Login          -= new PRoConLayerClient.LayerClientHandler(client_LayerClientLogin);
            sender.Logout         -= new PRoConLayerClient.LayerClientHandler(client_LayerClientLogout);
            sender.Quit           -= new PRoConLayerClient.LayerClientHandler(client_LayerClientQuit);
            sender.ClientShutdown -= new PRoConLayerClient.LayerClientHandler(client_LayerClientShutdown);
            sender.UidRegistered  -= new PRoConLayerClient.LayerClientHandler(client_UidRegistered);

            this.LayerClients.Remove(sender);

            this.SendAccountLogout(sender.Username);
        }
示例#8
0
        private void client_LayerClientLogout(PRoConLayerClient sender)
        {
            if (this.lsvLayerAccounts.Items.ContainsKey(sender.Username) == true)
            {
                // TO DO: Change Icon
                // TODO: Fix
                //this.m_uscConnectionPanel.ThrowEvent(this, uscEventsPanel.CapturableEvents.AccountLogout, new string[] { strUsername });

                if (this.lsvLayerAccounts.Items[sender.Username].SubItems["ip"].Tag != null)
                {
                    ((List <string>) this.lsvLayerAccounts.Items[sender.Username].SubItems["ip"].Tag).Remove(sender.IPPort);

                    if (Math.Floor(((List <string>) this.lsvLayerAccounts.Items[sender.Username].SubItems["ip"].Tag).Count / 2.0) > 0)
                    {
                        this.lsvLayerAccounts.Items[sender.Username].SubItems["ip"].Text = String.Format("({0} CMD/EVNT) ", Math.Floor(((List <string>) this.lsvLayerAccounts.Items[sender.Username].SubItems["ip"].Tag).Count / 2.0));
                    }
                    else
                    {
                        this.lsvLayerAccounts.Items[sender.Username].ImageKey            = "status_offline.png";
                        this.lsvLayerAccounts.Items[sender.Username].SubItems["ip"].Text = String.Empty;
                    }

                    for (int i = 0; i < ((List <string>) this.lsvLayerAccounts.Items[sender.Username].SubItems["ip"].Tag).Count; i++)
                    {
                        if (i > 0)
                        {
                            this.lsvLayerAccounts.Items[sender.Username].SubItems["ip"].Text += ", ";
                        }

                        this.lsvLayerAccounts.Items[sender.Username].SubItems["ip"].Text += ((List <string>) this.lsvLayerAccounts.Items[sender.Username].SubItems["ip"].Tag)[i];
                    }
                }
                else
                {
                    this.lsvLayerAccounts.Items[sender.Username].SubItems["ip"].Text = String.Empty;
                }
            }
        }
示例#9
0
        void client_LayerClientLogin(PRoConLayerClient sender)
        {
            if (this.lsvLayerAccounts.Items.ContainsKey(sender.Username) == true)
            {
                // TO DO: Change Icon

                // TODO: Fix
                //this.m_uscConnectionPanel.ThrowEvent(this, uscEventsPanel.CapturableEvents.AccountLogin, new string[] { strUsername, sender.ClientIPPort });

                if (this.lsvLayerAccounts.Items[sender.Username].SubItems["ip"].Tag == null)
                {
                    this.lsvLayerAccounts.Items[sender.Username].SubItems["ip"].Tag = new List <string>()
                    {
                        sender.IPPort
                    };
                }
                else
                {
                    ((List <string>) this.lsvLayerAccounts.Items[sender.Username].SubItems["ip"].Tag).Add(sender.IPPort);
                }

                this.lsvLayerAccounts.Items[sender.Username].ImageKey = "status_online.png";

                this.lsvLayerAccounts.Items[sender.Username].SubItems["ip"].Text = String.Format("({0} CMD/EVNT) ", Math.Floor(((List <string>) this.lsvLayerAccounts.Items[sender.Username].SubItems["ip"].Tag).Count / 2.0));

                for (int i = 0; i < ((List <string>) this.lsvLayerAccounts.Items[sender.Username].SubItems["ip"].Tag).Count; i++)
                {
                    if (i > 0)
                    {
                        this.lsvLayerAccounts.Items[sender.Username].SubItems["ip"].Text += ", ";
                    }

                    this.lsvLayerAccounts.Items[sender.Username].SubItems["ip"].Text += ((List <string>) this.lsvLayerAccounts.Items[sender.Username].SubItems["ip"].Tag)[i];
                }

                //this.lsvLayerAccounts.Items[strUsername].SubItems["ip"].Text = sender.ClientIPPort;
            }
        }
示例#10
0
        private void client_LayerClientLogout(PRoConLayerClient sender) {

            if (this.lsvLayerAccounts.Items.ContainsKey(sender.Username) == true) {
                // TO DO: Change Icon
                // TODO: Fix
                //this.m_uscConnectionPanel.ThrowEvent(this, uscEventsPanel.CapturableEvents.AccountLogout, new string[] { strUsername });

                if (this.lsvLayerAccounts.Items[sender.Username].SubItems["ip"].Tag != null) {

                    ((List<string>)this.lsvLayerAccounts.Items[sender.Username].SubItems["ip"].Tag).Remove(sender.IPPort);

                    if (Math.Floor(((List<string>)this.lsvLayerAccounts.Items[sender.Username].SubItems["ip"].Tag).Count / 2.0) > 0) {
                        this.lsvLayerAccounts.Items[sender.Username].SubItems["ip"].Text = String.Format("({0} CMD/EVNT) ", Math.Floor(((List<string>)this.lsvLayerAccounts.Items[sender.Username].SubItems["ip"].Tag).Count / 2.0));
                    }
                    else {
                        this.lsvLayerAccounts.Items[sender.Username].ImageKey = "status_offline.png";
                        this.lsvLayerAccounts.Items[sender.Username].SubItems["ip"].Text = String.Empty;
                    }

                    for (int i = 0; i < ((List<string>)this.lsvLayerAccounts.Items[sender.Username].SubItems["ip"].Tag).Count; i++) {
                        if (i > 0) {
                            this.lsvLayerAccounts.Items[sender.Username].SubItems["ip"].Text += ", ";
                        }

                        this.lsvLayerAccounts.Items[sender.Username].SubItems["ip"].Text += ((List<string>)this.lsvLayerAccounts.Items[sender.Username].SubItems["ip"].Tag)[i];
                    }
                }
                else {
                    this.lsvLayerAccounts.Items[sender.Username].SubItems["ip"].Text = String.Empty;
                }
            }
        }
示例#11
0
        void client_LayerClientLogin(PRoConLayerClient sender) {

            if (this.lsvLayerAccounts.Items.ContainsKey(sender.Username) == true) {
                // TO DO: Change Icon

                // TODO: Fix
                //this.m_uscConnectionPanel.ThrowEvent(this, uscEventsPanel.CapturableEvents.AccountLogin, new string[] { strUsername, sender.ClientIPPort });

                if (this.lsvLayerAccounts.Items[sender.Username].SubItems["ip"].Tag == null) {
                    this.lsvLayerAccounts.Items[sender.Username].SubItems["ip"].Tag = new List<string>() { sender.IPPort };
                }
                else {
                    ((List<string>)this.lsvLayerAccounts.Items[sender.Username].SubItems["ip"].Tag).Add(sender.IPPort);
                }

                this.lsvLayerAccounts.Items[sender.Username].ImageKey = "status_online.png";

                this.lsvLayerAccounts.Items[sender.Username].SubItems["ip"].Text = String.Format("({0} CMD/EVNT) ", Math.Floor(((List<string>)this.lsvLayerAccounts.Items[sender.Username].SubItems["ip"].Tag).Count / 2.0));

                for (int i = 0; i < ((List<string>)this.lsvLayerAccounts.Items[sender.Username].SubItems["ip"].Tag).Count; i++) {
                    if (i > 0) {
                        this.lsvLayerAccounts.Items[sender.Username].SubItems["ip"].Text += ", ";
                    }

                    this.lsvLayerAccounts.Items[sender.Username].SubItems["ip"].Text += ((List<string>)this.lsvLayerAccounts.Items[sender.Username].SubItems["ip"].Tag)[i];
                }

                //this.lsvLayerAccounts.Items[strUsername].SubItems["ip"].Text = sender.ClientIPPort;
            }
        }
示例#12
0
 void Layer_ClientConnected(PRoConLayerClient client) {
     client.Login += new PRoConLayerClient.LayerClientHandler(client_LayerClientLogin);
     client.Logout += new PRoConLayerClient.LayerClientHandler(client_LayerClientLogout);
 }
示例#13
0
        public void SendProconLayerPacket(PRoConLayerClient sender, Packet cpPassOn) {

            lock (new object()) {
                UInt32 ui32MainConnSequence = this.Game.Connection.AcquireSequenceNumber;

                if (this.m_dicForwardedPackets.ContainsKey(ui32MainConnSequence) == false) {

                    SOriginalForwardedPacket spopForwardedPacket = new SOriginalForwardedPacket();
                    spopForwardedPacket.m_ui32OriginalSequence = cpPassOn.SequenceNumber;
                    spopForwardedPacket.m_sender = sender;
                    spopForwardedPacket.m_lstWords = new List<string>(cpPassOn.Words);

                    // Register the packet as forwared. 
                    this.m_dicForwardedPackets.Add(ui32MainConnSequence, spopForwardedPacket);

                    if (cpPassOn.Words.Count >= 5 && String.Compare(cpPassOn.Words[0], "procon.admin.yell") == 0) {

                        if (this.IsPRoConConnection == false) {
                            if (this.Game is MOHWClient) {
                                cpPassOn.Words.RemoveAt(3);
                            }
                            // Just yell it, we'll capture it and process the return in OnBeforePacketRecv
                            cpPassOn.Words.RemoveAt(1);
                            cpPassOn.Words[0] = "admin.yell";
                        }
                        // Else forward the packet as is so the layer above can append its username.
                    }
                    else if (cpPassOn.Words.Count >= 4 && String.Compare(cpPassOn.Words[0], "procon.admin.say") == 0) {

                        if (this.IsPRoConConnection == false) {
                            // Just yell it, we'll capture it and process the return in OnBeforePacketRecv
                            cpPassOn.Words.RemoveAt(1);
                            cpPassOn.Words[0] = "admin.say";
                        }
                        // Else forward the packet as is so the layer above can append its username.
                    }

                    // Now forward the packet.
                    this.SendPacket(new Packet(false, false, ui32MainConnSequence, cpPassOn.Words));
                }
            }
        }
示例#14
0
 void Layer_ClientConnected(PRoConLayerClient client)
 {
     client.Login  += new PRoConLayerClient.LayerClientHandler(client_LayerClientLogin);
     client.Logout += new PRoConLayerClient.LayerClientHandler(client_LayerClientLogout);
 }
示例#15
0
 private void client_LayerClientLogout(PRoConLayerClient sender)
 {
     this.SendAccountLogout(sender.Username);
 }