/// <summary> /// /// </summary> /// <param name="senderId"></param> /// <param name="receiverId"></param> /// <param name="envelope"></param> /// <param name="requestConfirm">Only valid for remote clients, since all local calls are confirmed or denied by default.</param> /// <returns></returns> protected override SendToClientResultEnum DoSendToClient(ClientId senderId, ClientId receiverId, Envelope envelope, TimeSpan? requestConfirmTimeout) { if (receiverId.IsMessageBusIndexValid && (receiverId.MessageBus == this)) //|| receiverId.MessageBus == null)) // This allows for "lost" ids. {// Receiver seems to be a local item. SendToClientResultEnum result = base.DoSendToClient(senderId, receiverId, envelope, requestConfirmTimeout); if (result != SendToClientResultEnum.ClientNotFound) { return result; } } int clientSocketId = 0; lock (_syncRoot) { if (_remoteClientNetId.TryGetValue(receiverId, out clientSocketId) == false) { return SendToClientResultEnum.ClientNotFound; } } // Send message. EnvelopeMessage message = new EnvelopeMessage() { Envelope = envelope, Receivers = new ClientId[] { receiverId }, Sender = senderId, RequestResponse = false }; if (ToClient(clientSocketId, message, requestConfirmTimeout) == false) { return SendToClientResultEnum.Failure; } else { return SendToClientResultEnum.Success; } }
/// <summary> /// /// </summary> /// <param name="requestConfirm">Only valid for remote clients, since all local calls are confirmed or denied by default.</param> protected override SendToClientResultEnum DoSendToClient(ClientId senderId, ClientId receiverId, Envelope envelope, TimeSpan? requestConfirmTimeout) { if (receiverId.IsMessageBusIndexValid && receiverId.MessageBus == this) {// Seems to be a local client Id. SendToClientResultEnum result = base.DoSendToClient(senderId, receiverId, envelope, requestConfirmTimeout); if (result != SendToClientResultEnum.ClientNotFound) { return result; } } // Receiver was not local in parrent, try remote. if (IsConnected == false) { return SendToClientResultEnum.Failure; } EnvelopeMessage message = new EnvelopeMessage() { Envelope = envelope, Receivers = new ClientId[] { receiverId }, Sender = senderId }; return ToServer(message, requestConfirmTimeout) ? SendToClientResultEnum.Success : SendToClientResultEnum.Failure; }