Пример #1
0
        void ICommsNetwork.Initialize([NotNull] string playerName, [NotNull] Rooms rooms, [NotNull] PlayerChannels playerChannels, [NotNull] RoomChannels roomChannels, CodecSettings codecSettings)
        {
            if (playerName == null)
            {
                throw new ArgumentNullException("playerName");
            }
            if (rooms == null)
            {
                throw new ArgumentNullException("rooms");
            }
            if (playerChannels == null)
            {
                throw new ArgumentNullException("playerChannels");
            }
            if (roomChannels == null)
            {
                throw new ArgumentNullException("roomChannels");
            }

            PlayerName     = playerName;
            Rooms          = rooms;
            PlayerChannels = playerChannels;
            RoomChannels   = roomChannels;
            CodecSettings  = codecSettings;

            Profiler.BeginSample("virtual void Initialize");
            Initialize();
            Profiler.EndSample();

            IsInitialized = true;
        }
Пример #2
0
        public SlaveClientCollection([NotNull] ISendQueue <TPeer> sender, [NotNull] ISession session, [NotNull] EventQueue events, [NotNull] Rooms localRooms, [NotNull] string playerName, CodecSettings codecSettings)
        {
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }
            if (sender == null)
            {
                throw new ArgumentNullException("sender");
            }
            if (events == null)
            {
                throw new ArgumentNullException("events");
            }
            if (localRooms == null)
            {
                throw new ArgumentNullException("localRooms");
            }
            if (playerName == null)
            {
                throw new ArgumentNullException("playerName");
            }

            _session       = session;
            _sender        = sender;
            _events        = events;
            _localRooms    = localRooms;
            _playerName    = playerName;
            _codecSettings = codecSettings;
        }
Пример #3
0
        /// <summary>
        /// Write codec settings into the underlying array.
        /// </summary>
        /// <param name="codecSettings">The codec settings to write</param>
        /// <returns>A copy of this writer (after the write has been applied)</returns>
        public PacketWriter Write(CodecSettings codecSettings)
        {
            Write((byte)codecSettings.Codec);
            Write(codecSettings.FrameSize);
            Write((uint)codecSettings.SampleRate);

            return(this);
        }
Пример #4
0
        /// <summary>
        /// Writes client info into the underlying array.
        /// </summary>
        /// <param name="playerName">The name of the player</param>
        /// <param name="playerId">The player's client ID</param>
        /// <param name="codecSettings">The player's codec settings</param>
        /// <returns>A copy of this writer (after the write has been applied)</returns>
        public PacketWriter Write(string playerName, ushort playerId, CodecSettings codecSettings)
        {
            Write(playerName);
            Write(playerId);
            Write(codecSettings);

            return(this);
        }
Пример #5
0
 public void EnqueuePlayerJoined(string playerName, CodecSettings codecSettings)
 {
     using (var events = _queuedEvents.Lock())
         events.Value.Add(new NetworkEvent(EventType.PlayerJoined)
         {
             PlayerName = playerName, CodecSettings = codecSettings
         });
 }
Пример #6
0
        private void OnPlayerJoined(string obj, CodecSettings codecSettings)
        {
            var handler = PlayerJoined;

            if (handler != null)
            {
                handler(obj, codecSettings);
            }
        }
Пример #7
0
        /// <summary>
        /// Write out a handshake request. Mutate this writer to represent the position after the write.
        /// </summary>
        /// <returns>A copy of this writer (after the write has been applied)</returns>
        public PacketWriter WriteHandshakeRequest([NotNull] string name, CodecSettings codecSettings)
        {
            WriteMagic();
            Write((byte)MessageTypes.HandshakeRequest);
            Write(codecSettings);
            Write(name);

            return(this);
        }
Пример #8
0
            public NetworkEvent(EventType type)
            {
                Type = type;

                _playerName    = null;
                _room          = null;
                _allRooms      = null;
                _codecSettings = default(CodecSettings);
                _voicePacket   = default(VoicePacket);
                _textMessage   = default(TextMessage);
            }
Пример #9
0
        private void OnPlayerJoined(string name, CodecSettings _)
        {
            if (name == _network.PlayerName)
            {
                return;
            }

            // Try to connect directly to this peer if their ID comes after yours
            // This ensures that connections are only established in one direction between any two given peers.
            if (_peerHandshake != null && string.Compare(name, _network.PlayerName, StringComparison.Ordinal) > 0)
            {
                var s = UniquePlayerSessionId(name);
                Log.Debug("Trying to establish p2p connection to `{0}`", s);
                _webrtcNetwork.Connect(s);
            }
        }
Пример #10
0
        private void OnPlayerJoined([NotNull] string name, CodecSettings codecSettings)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            //Find any pending channels which address this new player by name and open them now we know who they are
            for (var i = _pendingPlayerChannels.Count - 1; i >= 0; i--)
            {
                var p = _pendingPlayerChannels[i];
                if (p.Key == name)
                {
                    OpenPlayerChannel(p.Key, p.Value);
                    _pendingPlayerChannels.RemoveAt(i);
                }
            }
        }
Пример #11
0
        /// <summary>
        /// Shows the codec settings form.
        /// </summary>
        /// <remarks>Documented by Dev02, 2008-04-15</remarks>
        private void ShowCodecSettings()
        {
            CodecSettings settingsForm = new CodecSettings();

            settingsForm.Codecs          = codecs;
            settingsForm.ShowEncoder     = Settings.Default.ShowEncodingWindow;
            settingsForm.ShowDecoder     = Settings.Default.ShowDecodingWindow;
            settingsForm.MinimizeWindows = Settings.Default.MimimizeWindows;

            if (settingsForm.ShowDialog() == DialogResult.OK)
            {
                codecs = settingsForm.Codecs;
                Settings.Default.ShowEncodingWindow = settingsForm.ShowEncoder;
                Settings.Default.ShowDecodingWindow = settingsForm.ShowDecoder;
                Settings.Default.MimimizeWindows    = settingsForm.MinimizeWindows;
                Settings.Default.Save();
            }
        }
Пример #12
0
        /// <summary>
        /// Shows the codec settings.
        /// </summary>
        /// <returns></returns>
        /// <remarks>Documented by Dev02, 2008-04-15</remarks>
        public static DialogResult ShowCodecSettings(Settings settings)
        {
            Codecs.Codecs codecs = new MLifter.AudioTools.Codecs.Codecs();
            codecs.XMLString = settings.CodecSettings;

            CodecSettings codecSettings = new CodecSettings();

            codecSettings.Codecs = codecs;
            codecSettings.EnableDecodeSettings = false;
            codecSettings.ShowEncoder          = settings.ShowEncoderWindow;
            codecSettings.MinimizeWindows      = settings.MinimizeEncoderWindow;

            DialogResult result = codecSettings.ShowDialog();

            if (result == DialogResult.OK)
            {
                settings.CodecSettings         = codecSettings.Codecs.XMLString;
                settings.ShowEncoderWindow     = codecSettings.ShowEncoder;
                settings.MinimizeEncoderWindow = codecSettings.MinimizeWindows;
            }

            return(result);
        }
        public CapturePipelineManager([NotNull] CodecSettings codecSettings, [NotNull] RoomChannels roomChannels, [NotNull] PlayerChannels playerChannels, [NotNull] ReadOnlyCollection <VoicePlayerState> players)
        {
            if (codecSettings == null)
            {
                throw new ArgumentNullException("codecSettings");
            }
            if (roomChannels == null)
            {
                throw new ArgumentNullException("roomChannels");
            }
            if (playerChannels == null)
            {
                throw new ArgumentNullException("playerChannels");
            }
            if (players == null)
            {
                throw new ArgumentNullException("players");
            }

            _codecSettings              = codecSettings;
            _roomChannels               = roomChannels;
            _playerChannels             = playerChannels;
            _receivingPacketLossMonitor = new PacketLossMonitor(players);
        }
Пример #14
0
 public void ReadHandshakeRequest([CanBeNull] out string name, out CodecSettings codecSettings)
 {
     codecSettings = ReadCodecSettings();
     name          = ReadString();
 }
Пример #15
0
        /// <summary>
        /// Write out a client state packet. Mutate this writer to represent the position after the write.
        /// </summary>
        /// <param name="session"></param>
        /// <param name="clientId"></param>
        /// <param name="rooms">Rooms state of the local player</param>
        /// <param name="name">Name of the local player</param>
        /// <param name="codecSettings">The player's codec settings</param>
        /// <returns>A copy of this writer (after the write has been applied)</returns>
        public PacketWriter WriteClientState(uint session, [NotNull] string name, ushort clientId, CodecSettings codecSettings, [NotNull] Rooms rooms)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name", "Attempted to serialize ClientState with a null name");
            }
            if (rooms == null)
            {
                throw new ArgumentNullException("rooms");
            }

            WriteMagic();
            Write((byte)MessageTypes.ClientState);
            Write(session);

            //Write out ID of this client
            Write(name, clientId, codecSettings);

            //Write out the rooms this client is listening to
            Write((ushort)rooms.Count);
            for (var i = 0; i < rooms.Count; i++)
            {
                Write(rooms[i].RoomName);
            }

            return(this);
        }
Пример #16
0
 public ClientInfo(string playerName, ushort playerId, CodecSettings codecSettings) : this()
 {
     PlayerName    = playerName;
     PlayerId      = playerId;
     CodecSettings = codecSettings;
 }
Пример #17
0
        [NotNull] protected ClientInfo <TPeer> GetOrCreateClientInfo(ushort id, [NotNull] string name, CodecSettings codecSettings, [CanBeNull] TPeer connection)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            ClientInfo <TPeer> info;

            if (TryGetClientInfoById(id, out info))
            {
                return(info);
            }

            info = new ClientInfo <TPeer>(name, id, codecSettings, connection);
            _clientsByPlayerId[id] = info;
            _clientsByName[name]   = info;

            OnAddedClient(info);

            return(info);
        }
Пример #18
0
 public ConnectionNegotiator([NotNull] ISendQueue <TPeer> sender, string playerName, [NotNull] CodecSettings codecSettings)
 {
     _sender        = sender;
     _playerName    = playerName;
     _codecSettings = codecSettings;
 }
Пример #19
0
        /// <summary>
        /// Write out a client state packet. Mutate this writer to represent the position after the write.
        /// </summary>
        /// <param name="session"></param>
        /// <param name="clientId"></param>
        /// <param name="rooms">Rooms state of the local player</param>
        /// <param name="name">Name of the local player</param>
        /// <param name="codecSettings">The player's codec settings</param>
        /// <returns>A copy of this writer (after the write has been applied)</returns>
        public PacketWriter WriteClientState(uint session, [NotNull] string name, ushort clientId, CodecSettings codecSettings, [NotNull] Rooms rooms)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name", "Attempted to serialize ClientState with a null name");
            }
            if (rooms == null)
            {
                throw new ArgumentNullException("rooms");
            }

            return(WriteClientState(session, name, clientId, codecSettings, rooms.Memberships));
        }