Example #1
0
        public static bool RemoveConnection(Guid conId)
        {
            INetworkConnection con = null;

            if (!Clients.TryGetValue(conId, out con))
            {
                return(false);
            }

            if (con == null)
            {
                return(false);
            }

            InboundConnection inb = con as InboundConnection;

            if (inb != null && inb.ServerUser != null)
            {
                inb.ServerUser.MyConnection = null;
            }

            Log1.Logger("Server.Login").Info("Untracking socket " + conId.ToString());

            bool haveIt = false;

            if (Clients.ContainsKey(conId))
            {
                haveIt = true;
                PerfMon.IncrementCustomCounter("Live Connections", -1);
            }

            Clients.Remove(conId);
            return(haveIt);
        }
Example #2
0
        /// <summary>
        /// Adds a socket connection to be tracked by the server
        /// </summary>
        public static bool TrackUserSocket(INetworkConnection client, ref string msg)
        {
            msg = "";
            if (client == null || client.RemoteEndPoint == null)
            {
                return(false);
            }

            if (Clients.ContainsKey(client.RemoteEndPoint as IPEndPoint))
            {
                Clients[client.RemoteEndPoint as IPEndPoint].KillConnection("New connection being made from elsewhere...");
                RemoveConnection(client.RemoteEndPoint as IPEndPoint);
            }

            InboundConnection inb = client as InboundConnection;

            if (inb != null && Clients.Count + 1 > inb.MyServer.MaxInboundConnections)
            {
                msg = "Server is full.";
                return(false);
            }

            Clients.Add(client.UID, client);
            Clients.Associate(client.RemoteEndPoint as IPEndPoint, client.UID);
            PerfMon.IncrementCustomCounter("Live Connections", 1);
            return(true);
        }
Example #3
0
 protected override void OnPacketReceived()
 {
     PerfMon.IncrementCustomCounter("Packets In", 1);
 }
Example #4
0
 protected override void OnPacketSent()
 {
     PerfMon.IncrementCustomCounter("Packets Out", 1);
 }
Example #5
0
 protected override void OnBytesReceived(int amount)
 {
     PerfMon.IncrementCustomCounter("Bandwidth In", amount);
 }
Example #6
0
 protected override void OnBytesSent(int amount)
 {
     PerfMon.IncrementCustomCounter("Bandwidth Out", amount);
 }