示例#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);
        }
示例#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;
        }