private void OnBackendReady(object sender, NetMQSocketEventArgs e) { Codec.Receive(m_backend); if (Codec.Id == Codec.MessageId.ServiceRegister) { Service service; if (!m_services.TryGetValue(Codec.ServiceRegister.Service, out service)) { service = new Service(Codec.ServiceRegister.Service); m_services.Add(Codec.ServiceRegister.Service, service); } // register the new service service.Add(Codec.RoutingId); } else if (Codec.Id == Codec.MessageId.Message) { // route the message to the client id Codec.RoutingId = RouterUtility.ConvertConnectionIdToRoutingId(Codec.Message.ConnectionId); Codec.Message.ConnectionId = 0; Codec.Send(m_frontend); } else if (Codec.Id == Codec.MessageId.Error) { // route the message to the client id Codec.RoutingId = RouterUtility.ConvertConnectionIdToRoutingId(Codec.Error.ConnectionId); Codec.Error.ConnectionId = 0; Codec.Send(m_frontend); } }
private void OnFrontendReady(object sender, NetMQSocketEventArgs e) { Codec.Receive(m_frontend); if (Codec.Id == Codec.MessageId.Message) { Service service; if (!m_services.TryGetValue(Codec.Message.Service, out service)) { // TODO: we should return error or save the message until a service become available } else { // Add the routing id as the client id and send to correct service Codec.Message.ConnectionId = RouterUtility.ConvertRoutingIdToConnectionId(Codec.RoutingId); Codec.RoutingId = service.GetNextRoutingId(); Codec.Send(m_backend); } } }
private Task <object> HandleRequestAsync(byte[] routingId, ulong messageId, string service, object message) { return(m_asyncHandler.HandleRequestAsync(messageId, RouterUtility.ConvertRoutingIdToConnectionId(routingId), service, message)); }
private void HandleOneWay(byte[] routingId, ulong messageId, string service, object message) { m_asyncHandler.HandleOneWay(messageId, RouterUtility.ConvertRoutingIdToConnectionId(routingId), service, message); }