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(); }
private void client_UidRegistered(PRoConLayerClient sender) { foreach (PRoConLayerClient clcClient in new List <PRoConLayerClient>(this.LayerClients)) { clcClient.OnRegisteredUid(sender.ProconEventsUid, sender.Username); } }
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) { } } }
private void client_LayerClientQuit(PRoConLayerClient sender) { if (this.LayerClients.Contains(sender.IPPort) == true) { this.LayerClients.Remove(sender.IPPort); this.SendAccountLogout(sender.Username); } }
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); }
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); } }
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); }
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; } } }
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; } }
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; } } }
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; } }
void Layer_ClientConnected(PRoConLayerClient client) { client.Login += new PRoConLayerClient.LayerClientHandler(client_LayerClientLogin); client.Logout += new PRoConLayerClient.LayerClientHandler(client_LayerClientLogout); }
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)); } } }
private void client_LayerClientLogout(PRoConLayerClient sender) { this.SendAccountLogout(sender.Username); }