예제 #1
0
        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());
            }
        }
예제 #2
0
파일: MasterForm.cs 프로젝트: ewin66/Forge
        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();
            }
        }
예제 #3
0
파일: MasterForm.cs 프로젝트: ewin66/Forge
        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();
                }
            }
        }
예제 #4
0
        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();
            }
        }