/// <summary> /// Sends a message synchronously, regardless of its type /// </summary> /// <param name="message"></param> /// <remarks> /// added cbrown /// due to the extensive use of the sockettransport, and the desire not /// to break existing code, this interface is being used to extend the /// transport protocol. /// usage: /// IRelayTransportExtended xTend = Transport as IRelayTransportExtended; /// if (null == xTend) /// { /// use "tradidional" handling /// } /// else /// { /// use extended handling /// } /// </remarks> public void SendSyncMessage(RelayMessage message) { MemoryStream replyStream; ResourcePoolItem <MemoryStream> bufferItem = null; try { bufferItem = bufferPool.GetItem(); // there is not need to check the type, we are FORCING sync handling RelayMessageFormatter.WriteRelayMessage(message, bufferItem.Item); bufferItem.Item.Seek(0, SeekOrigin.Begin); replyStream = socketClient.SendSync((int)SocketCommand.HandleSyncMessage, bufferItem.Item); } finally { if (bufferItem != null) { bufferPool.ReleaseItem(bufferItem); } } if (replyStream != null) { RelayMessage replyMessage = RelayMessageFormatter.ReadRelayMessage(replyStream); message.ExtractResponse(replyMessage); } //this doesn't make any sense, the incoming message already //has error occured with no respones? fwise 5/09 else if (message.ErrorOccurred) { message.Payload = null; } }
/// <summary> /// Sends a message synchronously, regardless of its type /// </summary> /// <param name="message"></param> /// <remarks> /// added cbrown /// due to the extensive use of the sockettransport, and the desire not /// to break existing code, this interface is being used to extend the /// transport protocol. /// usage: /// IRelayTransportExtended xTend = Transport as IRelayTransportExtended; /// if (null == xTend) /// { /// use "tradidional" handling /// } /// else /// { /// use extended handling /// } /// </remarks> public void SendSyncMessage(RelayMessage message) { MemoryStream replyStream; ResourcePoolItem<MemoryStream> bufferItem = null; try { bufferItem = bufferPool.GetItem(); // there is not need to check the type, we are FORCING sync handling RelayMessageFormatter.WriteRelayMessage(message, bufferItem.Item); bufferItem.Item.Seek(0, SeekOrigin.Begin); replyStream = socketClient.SendSync((int)SocketCommand.HandleSyncMessage, bufferItem.Item); } finally { if (bufferItem != null) bufferPool.ReleaseItem(bufferItem); } if (replyStream != null) { RelayMessage replyMessage = RelayMessageFormatter.ReadRelayMessage(replyStream); message.ExtractResponse(replyMessage); } //this doesn't make any sense, the incoming message already //has error occured with no respones? fwise 5/09 else if (message.ErrorOccurred) { message.Payload = null; } }