internal AsyncIncomingMessageHandler() { //Initialize an actionblock that decodes a message and handles it actionBlock = new ActionBlock <NetworkIncomingPackage>(package => { var readableMessage = MessageSerializer.Decode(package.Message, package.Arguments.MessagePoco); package.Arguments.MessageHandler.Handle(null, readableMessage.ReadAllProperties()); }); }
public void ThenIShouldGetAResponseMessageAndConnectionApproval() { //wait for the server to respond System.Threading.Thread.Sleep(100); msg = client.ReadMessage(); dynamic readableMessageWithType = MessageSerializer.Decode(msg, myNewType); Assert.AreEqual(readableMessageWithType.Name, "DynamicType"); server.CloseMainWindow(); server.Close(); }
/// <summary> /// Decodes and handles incoming messages /// </summary> /// <param name="args">The message arguments</param> /// <param name="message">The net incoming message to decode and handle</param> internal static void HandleIncomingMessage(this MessageArguments args, NetIncomingMessage message) { var readableMessage = MessageSerializer.Decode(message, args.MessagePoco); args.MessageHandler.Handle(message.SenderConnection, readableMessage); }