Inheritance: MockConnection, IClientConnection
示例#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);
            }
        }
示例#2
0
        public void Setup()
        {
            provider = new MockConnectionProvider(protocol);
            provider.Start(MessageTypes.Reliable);

            connection = new MockClientConnection(provider);
            client     = new TempestClient(connection, MessageTypes.All);
        }
        public void Ctor()
        {
            var c = new MockClientConnection (new MockConnectionProvider (MockProtocol.Instance));

            var context = new SerializationContext (c, MockProtocol.Instance, new TypeMap());
            Assert.AreSame (c, context.Connection);
            Assert.AreSame (MockProtocol.Instance, context.Protocol);
        }
        public void Ctor()
        {
            var c = new MockClientConnection (new MockConnectionProvider (MockProtocol.Instance));

            var protocols = new Dictionary<byte, Protocol> {
                { MockProtocol.Instance.id, MockProtocol.Instance }
            };

            var context = new SerializationContext (c, protocols);
            Assert.AreSame (c, context.Connection);
            Assert.AreSame (MockProtocol.Instance, context.Protocols.First().Value);
        }
        public void Ctor()
        {
            var c = new MockClientConnection(new MockConnectionProvider(MockProtocol.Instance));

            var protocols = new Dictionary <byte, Protocol> {
                { MockProtocol.Instance.id, MockProtocol.Instance }
            };

            var context = new SerializationContext(c, protocols);

            Assert.AreSame(c, context.Connection);
            Assert.AreSame(MockProtocol.Instance, context.Protocols.First().Value);
        }
        public void CtorTypeMap()
        {
            var map = new TypeMap();
            ushort id;
            map.GetTypeId (typeof (string), out id);
            map.GetTypeId (typeof (int), out id);

            var c = new MockClientConnection (new MockConnectionProvider (MockProtocol.Instance));

            var context = new SerializationContext (c, MockProtocol.Instance, map);

            Assert.AreSame (map, context.TypeMap);
        }
示例#7
0
        public Tuple <MockClientConnection, MockServerConnection> GetConnections(IEnumerable <Protocol> protocols)
        {
            if (protocols == null)
            {
                throw new ArgumentNullException("protocols");
            }

            MockClientConnection c = new MockClientConnection(this, protocols);

            c.ConnectionId = Interlocked.Increment(ref this.cid);
            c.ConnectAsync(new Target(Target.AnyIP, 0), MessageTypes.Reliable);

            return(new Tuple <MockClientConnection, MockServerConnection> (c, c.connection));
        }
示例#8
0
		public void Setup()
		{
			var provider = new MockConnectionProvider (SocialProtocol.Instance);
			provider.ConnectionMade += (sender, args) => server = new ConnectionBuffer (args.Connection);
			provider.Start (MessageTypes.Reliable);

			var c = new MockClientConnection (provider);
			client = new ConnectionBuffer (c);

			clientContext = new SerializationContext (c, new Dictionary<byte, Protocol> { { 2, SocialProtocol.Instance } });

			var context = new TempestClient (c, MessageTypes.Reliable);
			context.ConnectAsync (new Target (Target.LoopbackIP, 1)).Wait();

			list = new WatchList (context);
		}
        public void ManagerSetup()
        {
            this.provider = new MockConnectionProvider (GablarskiProtocol.Instance);
            this.provider.Start (MessageTypes.All);

            var connections = this.provider.GetConnections (GablarskiProtocol.Instance);

            this.server = new ConnectionBuffer (connections.Item2);
            this.client = connections.Item1;

            context = new MockClientContext (this.client);
            var channels = new ClientChannelManager (context);
            ClientChannelManagerTests.PopulateChannels (channels, server);

            context.Users = new ClientUserHandler (context, new ClientUserManager());
            context.Channels = channels;
            context.CurrentUser = new CurrentUser (context, 1, "Foo", channels.First().ChannelId);

            this.manager = new ClientSourceManager (context);
        }
示例#10
0
        public void Setup()
        {
            provider = new MockConnectionProvider (protocol);
            provider.Start (MessageTypes.Reliable);

            connection = new MockClientConnection (provider);
            client = new TempestClient (connection, MessageTypes.All);
        }
示例#11
0
 internal MockServerConnection(MockClientConnection connection)
 {
     this.connected = true;
     this.connection = connection;
 }
示例#12
0
        public void ManagerSetup()
        {
            this.provider = new MockConnectionProvider (GablarskiProtocol.Instance);
            this.provider.Start (MessageTypes.All);

            var connections = this.provider.GetConnections (GablarskiProtocol.Instance);

            this.server = new ConnectionBuffer (connections.Item2);
            this.client = connections.Item1;

            userProvider = new MockUserProvider();
            context = new MockClientContext (client) { ServerInfo = new ServerInfo (new ServerSettings(), userProvider) };

            var channels = new ClientChannelManager (context);
            ClientChannelManagerTests.PopulateChannels (channels, this.server);

            this.userManager = new ClientUserManager();
            this.handler = new ClientUserHandler (context, userManager);
            context.Users = this.handler;
            context.Channels = channels;
        }
示例#13
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);
            }
        }
示例#14
0
        public Tuple<MockClientConnection, MockServerConnection> GetConnections(IEnumerable<Protocol> protocols)
        {
            if (protocols == null)
                throw new ArgumentNullException ("protocols");

            MockClientConnection c = new MockClientConnection (this, protocols);
            c.ConnectionId = Interlocked.Increment (ref this.cid);
            c.ConnectAsync (new Target (Target.AnyIP, 0), MessageTypes.Reliable);

            return new Tuple<MockClientConnection, MockServerConnection> (c, c.connection);
        }
示例#15
0
 internal MockServerConnection(MockClientConnection connection)
 {
     this.connected  = true;
     this.connection = connection;
 }
示例#16
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;
        }