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); }
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); } } } }
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; } }
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); } }
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()); } }
public virtual T DeepClone() { IMessage <T> msg = this as IMessage <T>; return(msg.Clone()); }