Beispiel #1
0
        /// <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);
        }
Beispiel #2
0
        /// <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;
        }
Beispiel #3
0
        /// <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;
        }