Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="game"></param>
        public ClientContext(Game game)
        {
            Guid       = Guid.NewGuid();
            Game       = game;
            GameClient = game.GameClient;
            Instance   = game.GameFactory.CreateClient(game, Guid);



            var netConfig = new NetPeerConfiguration(Game.GameID);

            netConfig.AutoFlushSendQueue = true;
            netConfig.EnableMessageType(NetIncomingMessageType.ConnectionApproval);
            netConfig.EnableMessageType(NetIncomingMessageType.ConnectionLatencyUpdated);
            netConfig.EnableMessageType(NetIncomingMessageType.DiscoveryRequest);
            netConfig.UnreliableSizeBehaviour = NetUnreliableSizeBehaviour.NormalFragmentation;

            if (Debugger.IsAttached)
            {
                netConfig.ConnectionTimeout = float.MaxValue;
                Log.Message("CL: Debugger is attached: ConnectionTimeout = {0} sec", netConfig.ConnectionTimeout);
            }

            NetClient = new NetClient(netConfig);
            NetClient.Start();
        }
Пример #2
0
    public static ClientInstance Create(ClientTypes ofClientType)
    {
        IClientInstance clientObject = null;

        switch (ofClientType)
        {
        case ClientInstance.ClientTypes.ClientTypeA:
            clientObject = new ClientClassA() as ClientInstance;

        default:
            break;
        }
        return(clientObject);
    }