コード例 #1
0
ファイル: ConnectionManager.cs プロジェクト: Amitkapadi/WISP
        /// <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);
        }
コード例 #2
0
ファイル: ConnectionManager.cs プロジェクト: Amitkapadi/WISP
        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);
        }
コード例 #3
0
ファイル: GameLobbyServerTB.cs プロジェクト: Amitkapadi/WISP
        /// <summary>
        /// Override from ServerBase, to make sure we create the proper connection object for inbound connections.
        /// If we don't override this method, a generic InboundConnection class will be instantiated.
        /// </summary>
        protected override InboundConnection CreateInboundConnection(Socket s, ServerBase server, int serviceID, bool isBlocking)
        {
            InboundConnection con = null;

            // ServiceIDs represents the type connection that is being requested.
            // these IDs are set in the App.Config of the initiating server and are any arbitrarily agreed upon integers
            switch (serviceID)
            {
            case 7:
                con           = new ZeusInboundConnection(s, server, isBlocking);
                con.ServiceID = serviceID;
                break;

            case 1:     // central server
                con           = new GSTurnedLobbyInboundCentralConnection(s, server, isBlocking);
                con.ServiceID = serviceID;
                GameManager.Instance.CentralServer = con as GSInboundServerConnection;
                break;

            default:     // assume player client
                con           = new GSTurnedLobbyInboundPlayerConnection(s, server, isBlocking);
                con.ServiceID = serviceID;
                break;
            }

#if DEBUG
            if (con == null)
            {
                throw new ArgumentOutOfRangeException("ServiceID " + serviceID.ToString() + " is unknown to CreateInboundConnection.  Cannot process connection.");
            }
#endif
            return(con);
        }
コード例 #4
0
ファイル: ConnectionManager.cs プロジェクト: Amitkapadi/WISP
 static void ParentConnection_Disconnected(InboundConnection con, string msg)
 {
     ParentConnections.Remove(con.ServerUser.AccountName.ToLower());
     if (ParentDisconnected != null)
     {
         ParentDisconnected(con, msg);
     }
 }
コード例 #5
0
ファイル: ConnectionManager.cs プロジェクト: Amitkapadi/WISP
        /// <summary>
        /// Grabs the parent connection, given a specific server account name.
        /// </summary>
        /// <param name="accountName"></param>
        /// <returns></returns>
        public static InboundConnection GetParentConnection(string accountName)
        {
            InboundConnection con = null;

            if (ParentConnections.TryGetValue(accountName.ToLower(), out con))
            {
                return(con);
            }
            return(null);
        }
コード例 #6
0
ファイル: ConnectionManager.cs プロジェクト: Amitkapadi/WISP
        /// <summary>
        /// Checks if a given parent server is alive and can receive communications from us
        /// </summary>
        /// <param name="serverAccountName">the account name of the parent server</param>
        /// <returns>true if the server can be communicated with</returns>
        public static bool IsParentServerConnected(string serverAccountName)
        {
            InboundConnection con = null;

            if (ParentConnections.TryGetValue(serverAccountName.ToLower(), out con))
            {
                return(con.IsAlive);
            }

            return(false);
        }
コード例 #7
0
ファイル: ConnectionManager.cs プロジェクト: Amitkapadi/WISP
        /// <summary>
        /// Each server in the cluster can have one parent.  Whenever the parent connects, we call this method.
        /// </summary>
        public static void AddParentConnection(InboundConnection client, ServerUser su)
        {
            InboundConnection con = null;

            if (ParentConnections.TryGetValue(client.ServerUser.AccountName.ToLower(), out con))
            {
                con.KillConnection("Parent server logging in again from different connection.");
                con.Disconnected -= new InboundConnection.DisconnectedDelegate(ParentConnection_Disconnected);
                ParentConnections.Remove(con.ServerUser.AccountName.ToLower());
            }

            ParentConnections.Add(client.ServerUser.AccountName.ToLower(), client);
            client.Disconnected += new InboundConnection.DisconnectedDelegate(ParentConnection_Disconnected);
        }
コード例 #8
0
ファイル: ConnectionManager.cs プロジェクト: kamilion/WISP
 static void ParentConnection_Disconnected(InboundConnection con, string msg)
 {
     ParentConnections.Remove(con.ServerUser.AccountName.ToLower());
     if (ParentDisconnected != null)
     {
         ParentDisconnected(con, msg);
     }
 }
コード例 #9
0
ファイル: ConnectionManager.cs プロジェクト: kamilion/WISP
        /// <summary>
        /// Each server in the cluster can have one parent.  Whenever the parent connects, we call this method.
        /// </summary>
        public static void AddParentConnection(InboundConnection client, ServerUser su)
        {
            InboundConnection con = null;
            if (ParentConnections.TryGetValue(client.ServerUser.AccountName.ToLower(), out con))
            {
                con.KillConnection("Parent server logging in again from different connection.");
                con.Disconnected -= new InboundConnection.DisconnectedDelegate(ParentConnection_Disconnected);
                ParentConnections.Remove(con.ServerUser.AccountName.ToLower());
            }

            ParentConnections.Add(client.ServerUser.AccountName.ToLower(), client);
            client.Disconnected += new InboundConnection.DisconnectedDelegate(ParentConnection_Disconnected);
        }
コード例 #10
0
ファイル: ServerBase.cs プロジェクト: kamilion/WISP
        /// <summary>
        /// Create a connection object for an incoming connections.  Should be overridden.
        /// </summary>
        protected virtual InboundConnection CreateInboundConnection(Socket s, ServerBase server, int serviceID, bool isBlocking)
        {
            if (serviceID == 7) // 7eus
            {
                ZeusInboundConnection zcon = new ZeusInboundConnection(s, server, isBlocking);
                return zcon;
            }

            InboundConnection newClient = new InboundConnection(s, server, isBlocking);
            return newClient;
        }
コード例 #11
0
ファイル: GameLobbyServer.cs プロジェクト: kamilion/WISP
 static void InboundConnectionManager_ParentDisconnected(InboundConnection con, string msg)
 {
     Log.LogMsg("Incoming server connection lost.  " + ((InboundServerConnection)con).ServerUser.AccountName + ". " + msg);
 }
コード例 #12
0
ファイル: GameLobbyServer.cs プロジェクト: Amitkapadi/WISP
 static void InboundConnectionManager_ParentDisconnected(InboundConnection con, string msg)
 {
     Log.LogMsg("Incoming server connection lost.  " + ((InboundServerConnection)con).ServerUser.AccountName + ". " + msg);
 }