public async void HandleClientPacket(INetworkConnection connection, Packet packet) { PacketStatisticsCruncher.RequestReceived(); try { if (packet == null) { //logger.WriteError("Client has been disconnected but HandleClientPacket was still called."); connection.Close(false); return; // user has been terminated } var id = packet.ReadId(); if (handlers.ContainsKey(id)) { await handlers[id](connection, packet); } else { await HandleUnknownPacketAsync(connection, packet); } } catch (Exception exc) { Logger.WriteError(exc.ToString()); } finally { Logger.SetTopic("Packets per seconds: " + PacketStatisticsCruncher.GetRequestsPerSeconds()); } }
private void btDisconnect_Click(object sender, EventArgs e) { string id = tcDomains.SelectedTab.Text; Wrapper wrapper = mWrapper[id]; ListView lv = mListViewNetworkConnections[id]; if (lv.SelectedIndices.Count > 0) { INetworkConnection c = (INetworkConnection)lv.SelectedItems[0].Tag; c.Close(); } }
private void btDisconnectActive_Click(object sender, EventArgs e) { string id = tcDomains.SelectedTab.Text; Wrapper wrapper = mWrapper[id]; TreeView tv = mTreeViewsById[id]; if (tv.SelectedNode != null && tv.SelectedNode.Parent != null) { INetworkPeerRemote peer = (INetworkPeerRemote)tv.SelectedNode.Tag; INetworkConnection c = peer.ActiveNetworkConnection; if (c != null) { c.Close(); } } }
public void Monitor() { while (true) { try { ProcessNextRequest(); } catch (Exception ex) { Console.WriteLine("Exception processing message: {0}\r\n{1}", ex.Message, ex.StackTrace.ToString()); } _serverConnection.Close(); } }