Ejemplo n.º 1
0
        protected BaseClient([NotNull] ICommsNetworkState network)
        {
            if (network == null)
            {
                throw new ArgumentNullException("network");
            }

            Log = Logs.Create(LogCategory.Network, GetType().Name);

            const int poolSize        = 32;
            const int byteBufferSize  = 1024;
            const int channelListSize = 8;
            var       byteArrayPool   = new ReadonlyLockedValue <Pool <byte[]> >(new Pool <byte[]>(poolSize, () => new byte[byteBufferSize]));
            var       channelListPool = new ConcurrentPool <List <RemoteChannel> >(poolSize, () => new List <RemoteChannel>(channelListSize));

            _sendQueue        = new SendQueue <TPeer>(this, byteArrayPool);
            _serverNegotiator = new ConnectionNegotiator <TPeer>(_sendQueue, network.PlayerName, network.CodecSettings);
            _lossSimulator    = new PacketDelaySimulator();

            _events = new EventQueue(byteArrayPool, channelListPool);
            _peers  = new SlaveClientCollection <TPeer>(_sendQueue, _serverNegotiator, _events, network.Rooms, network.PlayerName, network.CodecSettings);
            _peers.OnClientJoined        += OnAddedClient;
            _peers.OnClientIntroducedP2P += OnMetClient;

            _voiceReceiver = new VoiceReceiver <TPeer>(_serverNegotiator, _peers, _events, network.Rooms, channelListPool);
            _voiceSender   = new VoiceSender <TPeer>(_sendQueue, _serverNegotiator, _peers, _events, network.PlayerChannels, network.RoomChannels);

            _textReceiver = new TextReceiver <TPeer>(_events, network.Rooms, _peers);
            _textSender   = new TextSender <TPeer>(_sendQueue, _serverNegotiator, _peers);
        }
 public LostClient(ICommsNetworkState network)
     : base(network)
 {
 }
Ejemplo n.º 3
0
 protected BaseClient(ICommsNetworkState network)
     : this(network.PlayerName, network.Rooms, network.PlayerChannels, network.RoomChannels)
 {
     SentTraffic = new TrafficCounter();
 }