//public int RequestAllOrders() //{ // //try // //{ // // lock (this) // // { // // for (int i = 0; i < _pendingMessages.Count; i++) // // { // // if (_pendingMessages[i] is GetAllOrdersMessage) // // { // // TracerHelper.Trace(_sessionInformation.Info.Name); // // int result = ((GetAllOrdersMessage)_pendingMessages[i]).OperationID; // // System.Diagnostics.Debug.Assert(result != 0); // // _pendingMessages.RemoveAt(i); // // return result; // // } // // } // // } // //} // //catch (Exception ex) // //{// Make sure we handle any possible unexpected exceptions, as otherwise they bring the // // // entire package (MT4 included) down with a bad error. // // SystemMonitor.Error(ex.Message); // //} // return 0; //} protected void SendToSubscribers(TransportMessage message) { TracerHelper.TraceEntry(message.GetType().Name + " to " + _subscribers.Count + " subscribers"); lock (this) { foreach (KeyValuePair<ArbiterClientId, TransportInfo> pair in _subscribers) { SendResponding(pair.Value, message); } } }
/// <summary> /// Helper, unused. /// </summary> /// <param name="inputMessage"></param> /// <returns></returns> protected bool VerifySubscriber(TransportMessage inputMessage) { if (_subscriberTransportMessageInfo == null) { return false; } lock (this) { return _subscriberTransportMessageInfo.CheckOriginalSender(inputMessage.TransportInfo); } }
/// <summary> /// /// </summary> /// <param name="message"></param> void SendToSubscriber(TransportMessage message) { TracerHelper.TraceEntry(message.GetType().Name); lock (this) { if (_subscriberTransportMessageInfo != null) { this.SendResponding(_subscriberTransportMessageInfo, message); } } TracerHelper.TraceExit(); }
/// <summary> /// Change default TransportClient behaviour. /// Handle a requestMessage received from local Arbiter and send down the pipe. /// </summary> /// <param name="requestMessage"></param> protected override void OnMessageReceived(TransportMessage message) { if (message.IsRequest == false) {// Responce requestMessage. // Clear off the transporting information from the last node to here. message.TransportInfo.PopTransportInfo(); } MessageContainer container = new MessageContainer(message); TracerHelper.Trace("[" + message.GetType().Name + "], length [" + container.MessageStreamLength + "]"); if (_transportClient != null) { _transportClient.SendMessageContainer(container); } else { SystemMonitor.OperationError("Message received after Integration Client uninitialized [" + message.GetType().Name + "].", TracerItem.PriorityEnum.Medium); } }
/// <summary> /// /// </summary> protected virtual bool IsAddressedToMe(TransportMessage message) { return (message.TransportInfo.CurrentTransportInfo.Value.ReceiverID != null && message.TransportInfo.CurrentTransportInfo.Value.ReceiverID.HasValue && this._ownerID.Equals(message.TransportInfo.CurrentTransportInfo.Value.ReceiverID.Value)); }
public new void SendResponding(TransportInfo incomingMessageTransportInfo, TransportMessage message) { base.SendResponding(incomingMessageTransportInfo, message); }
/// <summary> /// Change default TransportClient behaviour. /// Handle a requestMessage received from local Arbiter and send down the pipe. /// </summary> /// <param name="requestMessage"></param> protected override void OnMessageReceived(TransportMessage message) { TracerHelper.TraceEntry(); if (message.TransportInfo == null) { SystemMonitor.Error("Transport message stack can not be null."); } if (message.TransportInfo == null || message.TransportInfo.TransportInfoCount == 0 || message.TransportInfo.CurrentTransportInfo.Value.ReceiverID == null || message.TransportInfo.CurrentTransportInfo.Value.ReceiverID.HasValue == false || message.TransportInfo.CurrentTransportInfo.Value.ReceiverID.Value.Equals(this.SubscriptionClientID) == false) {// This requestMessage was sent to me, not to one of the clients on the server. SystemMonitor.Error("Error. Send messages to server-client instances."); return; } // We shall now establish the tag defining which will be the client connection receiving the requestMessage (or all). // by default send to all. string tagID = "*"; if (message.IsRequest) {// Request. if (message.TransportInfo.ForwardTransportInfoCount != 0) { if (message.TransportInfo.CurrentForwardTransportInfoAddress.HasValue) {// Has value - take it into account, if no value is present, just use the "*" pop, // and use the rest of the AdditionalForwardTransportSessionStack. tagID = message.TransportInfo.CurrentForwardTransportInfoAddress.Value.SessionTag; } // Pop in both cases - if it is null or it is value. message.TransportInfo.PopForwardTransportInfo(); } } else {// Responce. // Clear the transporting information from the last node to here. message.TransportInfo.PopTransportInfo(); // Now this is the additional marking in the case with the server - the marking of the PipeChannel. SystemMonitor.CheckError(message.TransportInfo.TransportInfoCount > 0 && message.TransportInfo.CurrentTransportInfo.Value.SenderID.Value.Id.Name == "PipeChannelID"); // Responce requestMessage, read and pop out the channel ID entry . tagID = message.TransportInfo.PopTransportInfo().Value.SenderID.Value.SessionTag; } MessageContainer container = new MessageContainer(message); TracerHelper.Trace("[" + message.GetType().Name + "], tag [" + tagID + "] length [" + container.MessageStreamLength + "]"); GeneralHelper.FireAndForget(delegate() { _transportServer.SendMessageContainer(tagID, container); }); }
public new TExpectedMessageClass SendAndReceive <TExpectedMessageClass>(TransportMessage message, TimeSpan timeOut) where TExpectedMessageClass : TransportMessage { return(base.SendAndReceive <TExpectedMessageClass>(message, timeOut)); }
public TExpectedMessageClass SendAndReceiveAddressed <TExpectedMessageClass>( ArbiterClientId receiverID, TransportMessage message, TimeSpan timeOut) where TExpectedMessageClass : TransportMessage { return(base.SendAndReceiveAddressed <TExpectedMessageClass>(receiverID, message, timeOut)); }
public new void SendAddressed(ArbiterClientId receiverID, TransportMessage message) { base.SendAddressed(receiverID, message); }
/// <summary> /// /// </summary> public Message DirectCall(ArbiterClientId receiverID, TransportMessage message) { return(base.DirectCall(receiverID, message)); }
public new void Send(TransportMessage message) { base.Send(message); }