Ejemplo n.º 1
0
        public void TestMessageHandler()
        {
            MockSender sender = new() { Id = 42 };

            TestMessageHandler handler = new();

            MockReceiver receiver = new();

            MessageProcessor processor = new();

            processor.SetMessageReceiver(receiver);

            MessageDictionary dic = MessageDictionary.GetInstance();

            processor.RegisterMessageHandler(handler);

            dic.AddOutgoingMessage(Module, Type, p =>
            {
                return(Tuple.Create(TestValue, 42));
            });

            var msg = dic.CreateMessage(Type);

            receiver.ReceiveMessage(new RawMessage(sender, msg.Serialize()));

            Assert.IsTrue(handler.Tcs.Task.Wait(100));
        }
    }
Ejemplo n.º 2
0
        public async override Task SynchronizeConnection(IConnection connection)
        {
            Data.AddConnection(connection);

            var response = await Messenger.SendAndWaitForResponse(connection, Messages.CreateMessage("Games", Data.Games.Values), Const.RESPONSE_TIMEOUT, "Games");

            var gameIds = response.Data.Get <int[]>("Data");
            var games   = gameIds.Select(id => Games[id]).ToArray();

            Data.AddGameToConnection(connection, games);
        }
Ejemplo n.º 3
0
 internal Message Initialize()
 {
     return(Messages.CreateMessage("Initialize"));
 }
Ejemplo n.º 4
0
 internal Message ReadyChanged(LobbyConnection lc)
 {
     return(Messages.CreateMessage("SetReady", lc));
 }