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)); } }
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); }
internal Message Initialize() { return(Messages.CreateMessage("Initialize")); }
internal Message ReadyChanged(LobbyConnection lc) { return(Messages.CreateMessage("SetReady", lc)); }