public void Receive(Guid hubId, MessageHub.Message message) { MessageEnvelope env = new MessageEnvelope { SenderId = hubId, Contents = message }; Receive(env); }
public void Send(Guid senderId, MessageHub.Message message) { var clients = _clients.All(); foreach (MsmqConnectedClient client in clients) { if (client.Id == senderId) { continue; } client.Receive(senderId, message); } }
public override Task Broadcast(MessageHub.Message message) { MessageEnvelope env = new MessageEnvelope(); env.SenderId = Id; env.ServiceOp = HubServiceOperation.Send; env.Contents = message; Message msg = new Message(); msg.Body = env; msg.Formatter = new XmlMessageFormatter(new Type[1] { typeof(MessageEnvelope) }); _remoteQueue.Send(msg); return(Task.CompletedTask); }
private void OnReceiveCompleted(object sender, ReceiveCompletedEventArgs e) { MessageQueue mq = (MessageQueue)sender; Message msg = mq.EndReceive(e.AsyncResult); try { MessageEnvelope env = (MessageEnvelope)msg.Body; switch (env.ServiceOp) { case HubServiceOperation.Send: if (env.IsSecure) { SecureMessageContainer container = (SecureMessageContainer)env.Contents; SendSecure(env.SenderId, container); } else { MessageHub.Message hubMsg = (MessageHub.Message)env.Contents; Send(env.SenderId, hubMsg); } break; case HubServiceOperation.AddReceiver: MsmqConnectedClient client = (MsmqConnectedClient)env.Contents; AddReceiver(client); break; case HubServiceOperation.RemoveReceiver: Guid clientId = (Guid)env.Contents; RemoveReceiver(clientId); break; } } finally { msg.Dispose(); mq.BeginReceive(); } }
public void Receive(Guid senderId, MessageHub.Message message) { base.Receive(message); }