コード例 #1
0
        public void Unpack_TypeRegistry()
        {
            var messages = new IMessage[]
            {
                SampleMessages.CreateFullTestAllTypes(),
                new TestWellKnownTypes {
                    BoolField = true
                },
                new MoreString {
                    Data = { "x" }
                },
                new MoreBytes {
                    Data = ByteString.CopyFromUtf8("xyz")
                },
                new ReservedNames {
                    Descriptor_ = 10
                }
            };
            var anyMessages = messages.Select(Any.Pack);

            // The type registry handles the first four of the packed messages, but not the final one.
            var registry = TypeRegistry.FromFiles(
                UnittestWellKnownTypesReflection.Descriptor,
                UnittestProto3Reflection.Descriptor);
            var unpacked = anyMessages.Select(any => any.Unpack(registry)).ToList();
            var expected = (IMessage[])messages.Clone();

            expected[4] = null;
            Assert.AreEqual(expected, unpacked);
        }
コード例 #2
0
        public void PushMessageToClients(ICollection subscribers, IMessage message)
        {
            MessageDestination  destination         = base.GetDestination(message) as MessageDestination;
            SubscriptionManager subscriptionManager = destination.SubscriptionManager;

            if ((subscribers != null) && (subscribers.Count > 0))
            {
                IMessage message2 = message.Clone() as IMessage;
                foreach (string str in subscribers)
                {
                    MessageClient subscriber = subscriptionManager.GetSubscriber(str);
                    if (subscriber != null)
                    {
                        if (log.get_IsDebugEnabled())
                        {
                            if (message2 is BinaryMessage)
                            {
                                log.Debug(__Res.GetString("MessageServicePushBinary", new object[] { message.GetType().Name, str }));
                            }
                            else
                            {
                                log.Debug(__Res.GetString("MessageServicePush", new object[] { message.GetType().Name, str }));
                            }
                        }
                        base._messageBroker.GetEndpoint(subscriber.Endpoint).Push(message2, subscriber);
                    }
                }
            }
        }
コード例 #3
0
ファイル: AMFEndpoint.cs プロジェクト: saggelopoulos/AMFCore
 public override void Push(IMessage message, MessageClient messageClient)
 {
     if (_channelSettings != null && _channelSettings.IsPollingEnabled)
     {
         IMessage messageClone = message.Clone() as IMessage;
         messageClone.SetHeader(MessageBase.DestinationClientIdHeader, messageClient.ClientId);
         messageClone.clientId = messageClient.ClientId;
     }
 }
コード例 #4
0
ファイル: AMFEndpoint.cs プロジェクト: Joy011024/PickUpData
 public override void Push(IMessage message, MessageClient messageClient)
 {
     if ((base._channelSettings != null) && base._channelSettings.IsPollingEnabled)
     {
         IMessage message2 = message.Clone() as IMessage;
         message2.SetHeader("DSDstClientId", messageClient.ClientId);
         message2.clientId = messageClient.ClientId;
         messageClient.AddMessage(message2);
     }
 }
コード例 #5
0
        void Publish <T>(IMessage <T> message, List <Action <object> > actions)
        {
            var tasks = new List <Task>();

            foreach (var action in actions)
            {
                var task = Task.Run(() => action(message.Clone()));
                tasks.Add(task);
            }

            if (waitForSink)
            {
                Task.WaitAll(tasks.ToArray());
            }
        }
コード例 #6
0
ファイル: TemplateBase.cs プロジェクト: frozen4/UnityPlus
        public virtual T DeepClone()
        {
            IMessage <T> msg = this as IMessage <T>;

            return(msg.Clone());
        }