Beispiel #1
0
 public MessageFlowBuilder(string profile,MessageType messageType)
 {
     this.profile = profile;
     this.Id = GemNetwork.GetMesssageId(profile);
     this.messageType = messageType;
     this.messageFlowArgs = new MessageFlowArguments();
 }
 /// <summary>
 /// Post a message and the handling delegate to the asynchronous task
 /// </summary>
 /// <param name="message">The incoming message</param>
 /// <param name="arguments">The delegate to handle the message</param>
 internal void Post(NetIncomingMessage message, MessageFlowArguments arguments)
 {
     actionBlock.Post(new NetworkIncomingPackage
     {
         Message   = message,
         Arguments = arguments
     });
 }
Beispiel #3
0
        private static byte CreateMessageFlowArguments(byte id, Type type, string profile)
        {
            var properties      = RuntimePropertyInfo.GetPropertyInfo(Activator.CreateInstance(type).GetPropertyTypes().ToArray());
            var messageFlowArgs = new MessageFlowArguments();

            messageFlowArgs.MessageHandler = new DummyHandler();
            messageFlowArgs.MessagePoco    = Dependencies.Container.Resolve <IPocoFactory>().Create(properties, "poco" + id);
            messageFlowArgs.ID             = (byte)(GemNetwork.InitialId + ProtocolObjectsFound++);

            GemClient.MessageFlow[profile, MessageType.Data].Add(messageFlowArgs);
            GemServer.MessageFlow[profile, MessageType.Data].Add(new MessageArguments
            {
                ID             = messageFlowArgs.ID,
                MessageHandler = new DummyHandler(),
                MessagePoco    = messageFlowArgs.MessagePoco
            });

            return(messageFlowArgs.ID);
        }
Beispiel #4
0
        /// <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 MessageFlowArguments args, NetIncomingMessage message)
        {
            var readableMessage = MessageSerializer.Decode(message, args.MessagePoco);

            args.MessageHandler.Handle(message.SenderConnection, readableMessage);//.ReadAllProperties());
        }