Inheritance: MockConnection, IServerConnection
Exemplo n.º 1
0
        internal void Connect(MockClientConnection connection)
        {
            var c = new MockServerConnection(connection);

            c.ConnectionId        = connection.ConnectionId;
            connection.connection = c;

            if (connection.protocols != null)
            {
                foreach (Protocol ip in connection.protocols)
                {
                    Protocol lp;
                    if (!this.protocols.TryGetValue(ip.id, out lp) || !lp.CompatibleWith(ip))
                    {
                        connection.Disconnect(ConnectionResult.IncompatibleVersion);
                        return;
                    }
                }
            }

            var e = new ConnectionMadeEventArgs(c, null);

            OnConnectionMade(e);

            if (e.Rejected)
            {
                connection.Disconnect(ConnectionResult.ConnectionFailed);
                c.Disconnect(ConnectionResult.ConnectionFailed);
            }
        }
Exemplo n.º 2
0
 public void Teardown()
 {
     handler = null;
     manager = null;
     context = null;
     server = null;
     permissions = null;
 }
Exemplo n.º 3
0
        public AudioSource GetSourceFromRequest(MockServerConnection serverConnection, ConnectionBuffer clientConnection)
        {
            permissions.EnablePermissions (userManager.GetUser (serverConnection).UserId,	PermissionName.RequestSource);

            var audioArgs = new AudioCodecArgs (AudioFormat.Mono16bitLPCM, 64000, AudioSourceTests.FrameSize, 10);
            handler.RequestSourceMessage (new MessageEventArgs<RequestSourceMessage> (serverConnection,
                new RequestSourceMessage ("Name", audioArgs)));

            var result = clientConnection.DequeueAndAssertMessage<SourceResultMessage>();
            Assert.AreEqual (SourceResult.Succeeded, result.SourceResult);
            Assert.AreEqual ("Name", result.SourceName);
            Assert.AreEqual ("Name", result.Source.Name);

            AudioCodecArgsTests.AssertAreEqual (audioArgs, result.Source.CodecSettings);

            clientConnection.AssertNoMessage();

            return result.Source;
        }
Exemplo n.º 4
0
        public void Setup()
        {
            permissions = new MockPermissionsProvider();

            LobbyChannelProvider channels = new LobbyChannelProvider();
            channels.SaveChannel (new ChannelInfo
            {
                Name = "Channel 2"
            });

            this.provider = new MockConnectionProvider (GablarskiProtocol.Instance);
            this.provider.Start (MessageTypes.All);

            userManager = new ServerUserManager();
            MockServerContext c;
            context = c = new MockServerContext (provider)
            {
                Settings = new ServerSettings
                {
                    Name = "Server",
                    DefaultAudioBitrate = defaultBitrate,
                    MaximumAudioBitrate = maxBitrate,
                    MinimumAudioBitrate = minBitrate
                },

                UserManager = userManager,
                PermissionsProvider = permissions,
                ChannelsProvider = channels
            };
            c.Users = new ServerUserHandler (context, userManager);

            manager = new ServerSourceManager (context);
            handler = new ServerSourceHandler (context, manager);

            user = UserInfoTests.GetTestUser (1, 1, false);

            var cs = provider.GetConnections (GablarskiProtocol.Instance);

            client = new ConnectionBuffer (cs.Item1);
            server = cs.Item2;

            userManager.Connect (server);
            userManager.Join (server, user);
        }
Exemplo n.º 5
0
        internal void Connect(MockClientConnection connection)
        {
            var c = new MockServerConnection (connection);
            c.ConnectionId = connection.ConnectionId;
            connection.connection = c;

            if (connection.protocols != null)
            {
                foreach (Protocol ip in connection.protocols)
                {
                    Protocol lp;
                    if (!this.protocols.TryGetValue (ip.id, out lp) || !lp.CompatibleWith (ip))
                    {
                        connection.Disconnect (ConnectionResult.IncompatibleVersion);
                        return;
                    }
                }
            }

            var e = new ConnectionMadeEventArgs (c, null);
            OnConnectionMade (e);

            if (e.Rejected)
            {
                connection.Disconnect (ConnectionResult.ConnectionFailed);
                c.Disconnect (ConnectionResult.ConnectionFailed);
            }
        }
Exemplo n.º 6
0
 public void TearDown()
 {
     user = null;
     manager = null;
     server = null;
     server = null;
 }
Exemplo n.º 7
0
        public void Setup()
        {
            user = new UserInfo ("Nickname", "Phonetic", "Username", 1, 2, true);
            manager = new ServerUserManager();

            provider = new MockConnectionProvider (GablarskiProtocol.Instance);
            provider.Start (MessageTypes.All);

            var cs = provider.GetConnections (GablarskiProtocol.Instance);
            server = cs.Item2;
            client = cs.Item1;
        }
Exemplo n.º 8
0
		public void Setup()
		{
			manager = new ServerUserManager();
			permissions = new MockPermissionsProvider();
			channels = new LobbyChannelProvider();

			MockServerContext mcontext;
			context = mcontext = new MockServerContext
			{
				ChannelsProvider = channels,
				PermissionsProvider = permissions,
				UserManager = new ServerUserManager (),
				Settings = new ServerSettings { Name = "Test Server" }
			};

			mcontext.Users = new ServerUserHandler (context, manager);
			mcontext.Channels = handler = new ServerChannelHandler (context);

			user = UserInfoTests.GetTestUser (1, 1, false);

			provider = new MockConnectionProvider (GablarskiProtocol.Instance);
			mcontext.AddConnectionProvider (provider);
			mcontext.Start();

			var connections = provider.GetConnections (GablarskiProtocol.Instance);
			client = new ConnectionBuffer (connections.Item1);
			server = connections.Item2;

			manager.Connect (server);
			manager.Join (server, user);
		}