public IDuplexOutputChannel CreateDuplexOutputChannel(string channelId, string responseReceiverId)
 {
     using (EneterTrace.Entering())
     {
         IThreadDispatcher aDispatcher = OutputChannelThreading.GetDispatcher();
         return(new DefaultDuplexOutputChannel(channelId, responseReceiverId, aDispatcher, myDispatcherAfterMessageDecoded, myOutputConnectorFactory));
     }
 }
 /// <summary>
 /// Creates duplex output channel which can send and receive messages from the duplex input channel using UDP.
 /// </summary>
 /// <remarks>
 /// It can create duplex output channels for unicast, multicast or broadcast communication.
 /// If the property UnicastCommunication is set to true then it creates the output channel for the unicast communication.
 /// It means it can send messages to one particular input channel and receive messages only from that input channel.
 /// If the property UnicastCommunication is set to false then it creates the output channel for mulitcast or broadcast communication.
 /// It means it can send mulitcast or broadcast messages which can be received by multiple input channels.
 /// It can also receive multicast and broadcast messages.<br/>
 /// <br/>
 /// This method allows to specify the id of the created output channel.
 /// <example>
 /// Creating the duplex output channel for unicast communication (e.g. for client-service communication)
 /// with a specific output channel id.
 /// <code>
 /// IMessagingSystemFactory aMessaging = new UdpMessagingSystemFactory();
 /// string aSessionId = Guid.NewGuid().ToString();
 /// IDuplexOutputChannel anOutputChannel = aMessaging.CreateDuplexOutputChannel("udp://127.0.0.1:8765/", aSessionId);
 /// </code>
 /// </example>
 /// <example>
 /// Creating the duplex output channel which can send messages to a particular UDP address and
 /// which can recieve messages on a specific UDP address and which can receive mulitcast messages.
 /// <code>
 /// IProtocolFormatter aProtocolFormatter = new EasyProtocolFormatter();
 /// IMessagingSystemFactory aMessaging = new UdpMessagingSystemFactory(aProtocolFormatter)
 /// {
 ///     // Setup the factory to create channels for mulitcast or broadcast communication.
 ///     UnicastCommunication = false,
 ///
 ///     // Specify the mulitcast group to receive messages from.
 ///     MulticastGroupToReceive = "234.4.5.6"
 /// };
 ///
 /// // Create output channel which can send messages to the input channel listening to udp://127.0.0.1:8095/
 /// // and which is listening to udp://127.0.0.1:8099/ and which can also receive messages sent for the mulitcast
 /// // group 234.4.5.6.
 /// IDuplexOutputChannel anOutputChannel = aMessaging.CreateDuplexOutputChannel("udp://127.0.0.1:8095/", "udp://127.0.0.1:8099/");
 /// </code>
 /// </example>
 /// </remarks>
 /// <param name="channelId">Identifies the receiving duplex input channel. The channel id must be a valid URI address e.g. udp://127.0.0.1:8090/</param>
 /// <param name="responseReceiverId">
 /// Unique identifier of the output channel.<br/>
 /// In unicast communication the identifier can be a string e.g. GUID which represents the session between output and input channel.<br/>
 /// In mulitcast or broadcast communication the identifier must be a valid URI address which will be used by the output channel
 /// to receive messages from input channels.<br/>
 /// <br/>
 /// If the parameter is null then in case of unicast communication a unique id is generated automatically.
 /// In case of multicast or broadcast communication the address udp://0.0.0.0:0/ is used which means the the output channel will
 /// listen to random free port on all available IP addresses.
 /// </param>
 /// <returns>duplex output channel</returns>
 public IDuplexOutputChannel CreateDuplexOutputChannel(string channelId, string responseReceiverId)
 {
     using (EneterTrace.Entering())
     {
         IThreadDispatcher       aDispatcher       = OutputChannelThreading.GetDispatcher();
         IOutputConnectorFactory aConnectorFactory = new UdpConnectorFactory(myProtocolFormatter, ReuseAddress, ResponseReceiverPort, UnicastCommunication, AllowSendingBroadcasts, Ttl, MulticastGroupToReceive, MulticastLoopback, MaxAmountOfConnections);
         return(new DefaultDuplexOutputChannel(channelId, responseReceiverId, aDispatcher, myDispatcherAfterMessageDecoded, aConnectorFactory));
     }
 }
 /// <summary>
 /// Creates the output channel which can send messages to the input channel and receive response messages.
 /// </summary>
 /// <remarks>
 /// In addition the output channel monitors the connection availability. It sends ping messages in a specified frequency to the input channel
 /// and expects receiving ping messages within a specified time.
 /// </remarks>
 /// <param name="channelId">channel id, the syntax of the channel id must comply to underlying messaging</param>
 /// <param name="responseReceiverId">response receiver id of the channel</param>
 /// <returns>monitoring duplex output channel</returns>
 public IDuplexOutputChannel CreateDuplexOutputChannel(string channelId, string responseReceiverId)
 {
     using (EneterTrace.Entering())
     {
         IDuplexOutputChannel anUnderlyingChannel = myUnderlyingMessaging.CreateDuplexOutputChannel(channelId, responseReceiverId);
         IThreadDispatcher    aDispatcher         = OutputChannelThreading.GetDispatcher();
         return(new MonitoredDuplexOutputChannel(anUnderlyingChannel, Serializer, (int)PingFrequency.TotalMilliseconds, (int)ReceiveTimeout.TotalMilliseconds, aDispatcher));
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Creates duplex output channel which can send and receive messages from the duplex input channel using shared memory.
 /// </summary>
 /// <param name="channelId">Identifies the input channel which shall be connected.
 /// The channel id is the name of the memory-mapped file that
 /// is used to send and receive messages.
 /// </param>
 /// <param name="responseReceiverId">Identifies the input channel which shall be connected.
 /// The channel id is the name of the memory-mapped file that
 /// is used to send and receive messages.
 /// </param>
 /// <returns>duplex output channel</returns>
 public IDuplexOutputChannel CreateDuplexOutputChannel(string channelId, string responseReceiverId)
 {
     using (EneterTrace.Entering())
     {
         IThreadDispatcher       aDispatcher = OutputChannelThreading.GetDispatcher();
         IThreadDispatcher       aDispatcherAfterMessageDecoded = myDispatchingAfterMessageDecoded.GetDispatcher();
         IOutputConnectorFactory aConnectorFactory = new SharedMemoryConnectorFactory(myProtocolFormatter, ConnectTimeout, SendTimeout, MaxMessageSize, SharedMemorySecurity);
         return(new DefaultDuplexOutputChannel(channelId, responseReceiverId, aDispatcher, aDispatcherAfterMessageDecoded, aConnectorFactory));
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Creates duplex output channel which can send and receive messages from the duplex input channel using HTTP.
 /// </summary>
 /// <remarks>
 /// The channel id must be a valid URI address e.g. http://127.0.0.1:8090/something/
 /// </remarks>
 /// <param name="channelId">Identifies the input channel which shall be connected. The channel id must be a valid URI address e.g. http://127.0.0.1:8090/</param>
 /// <param name="responseReceiverId">Unique identifier of the output channel. If null then the id is generated automatically.</param>
 /// <returns>duplex output channel</returns>
 public IDuplexOutputChannel CreateDuplexOutputChannel(string channelId, string responseReceiverId)
 {
     using (EneterTrace.Entering())
     {
         IThreadDispatcher       aDispatcher = OutputChannelThreading.GetDispatcher();
         IThreadDispatcher       aDispatcherAfterMessageDecoded = myDispatchingAfterMessageDecoded.GetDispatcher();
         IOutputConnectorFactory aClientConnectorFactory        = new HttpOutputConnectorFactory(myProtocolFormatter, myPollingFrequency);
         return(new DefaultDuplexOutputChannel(channelId, responseReceiverId, aDispatcher, aDispatcherAfterMessageDecoded, aClientConnectorFactory));
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Creates the duplex output channel sending messages to the duplex input channel and receiving response messages by using WebSocket.
        /// </summary>
        /// <param name="channelId">Identifies the receiving duplex input channel. The channel id must be a valid URI address e.g. ws://127.0.0.1:8090/</param>
        /// <param name="responseReceiverId">Identifies the response receiver of this duplex output channel.</param>
        /// <returns>duplex output channel</returns>
        public IDuplexOutputChannel CreateDuplexOutputChannel(string channelId, string responseReceiverId)
        {
            using (EneterTrace.Entering())
            {
                IThreadDispatcher       aDispatcher = OutputChannelThreading.GetDispatcher();
                IOutputConnectorFactory aFactory    = new WebSocketOutputConnectorFactory(myProtocolFormatter, ClientSecurityStreamFactory,
                                                                                          (int)ConnectTimeout.TotalMilliseconds, (int)SendTimeout.TotalMilliseconds, (int)ReceiveTimeout.TotalMilliseconds,
                                                                                          (int)PingFrequency.TotalMilliseconds,
                                                                                          ResponseReceiverPort);

                return(new DefaultDuplexOutputChannel(channelId, responseReceiverId, aDispatcher, myDispatcherAfterMessageDecoded, aFactory));
            }
        }
        /// <summary>
        /// Creates duplex output channel which can send and receive messages from the duplex input channel using TCP.
        /// </summary>
        /// <remarks>
        /// <example>
        /// Creating the duplex output channel.
        /// <code>
        /// IMessagingSystemFactory aMessaging = new TcpMessagingSystemFactory();
        /// IDuplexOutputChannel anOutputChannel = aMessaging.CreateDuplexOutputChannel("tcp://127.0.0.1:8765/");
        /// </code>
        /// </example>
        /// </remarks>
        /// <param name="channelId">Identifies the input channel which shall be connected. The channel id must be a valid URI address e.g. tcp://127.0.0.1:8090/ </param>
        /// <returns>duplex output channel</returns>
        public IDuplexOutputChannel CreateDuplexOutputChannel(string channelId)
        {
            using (EneterTrace.Entering())
            {
                IThreadDispatcher       aDispatcher = OutputChannelThreading.GetDispatcher();
                IOutputConnectorFactory anOutputConnectorFactory = new TcpOutputConnectorFactory(
                    myProtocolFormatter, ClientSecurityStreamFactory,
                    (int)ConnectTimeout.TotalMilliseconds, (int)SendTimeout.TotalMilliseconds, (int)ReceiveTimeout.TotalMilliseconds,
                    SendBufferSize, ReceiveBufferSize,
                    ReuseAddress, ResponseReceiverPort);

                return(new DefaultDuplexOutputChannel(channelId, null, aDispatcher, myDispatcherAfterMessageDecoded, anOutputConnectorFactory));
            }
        }
        /// <summary>
        /// Creates duplex output channel which can send and receive messages from the duplex input channel using Named Pipes.
        /// </summary>
        /// <param name="channelId">Identifies the input channel which shall be connected. The channel id must be a valid URI address e.g. net.pipe://127.0.0.1/SomeName/ </param>
        /// <returns>duplex output channel</returns>
        public IDuplexOutputChannel CreateDuplexOutputChannel(string channelId)
        {
            using (EneterTrace.Entering())
            {
                // Create response receiver id.
                // Note: The response receiver id must be created here because if the id is created by SimpleDuplexOutputChannel,
                //       then the id would not have to be a valid Uri address.
                string aResponseReceiverId = channelId.TrimEnd('/');
                aResponseReceiverId += "_" + Guid.NewGuid().ToString() + "/";

                IThreadDispatcher aDispatcher = OutputChannelThreading.GetDispatcher();
                return(new DefaultDuplexOutputChannel(channelId, aResponseReceiverId, aDispatcher, myDispatcherAfterMessageDecoded, myConnectorFactory));
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Creates duplex output channel which performs authentication procedure during opening the connection.
        /// </summary>
        /// <remarks>
        /// The created authenticated output channel can throw following exceptions when opening the connection:
        /// <ul>
        /// <li>TimeOutException - if the authentication sequence exceeds the specified AuthenticationTimeout.</li>
        /// <li>AuthenticationException - if the authentication fails and the conneciton is not granted.</li>
        /// <li>Other underlying messaging specific exception - if it fails to open the connection and start the authentication.</li>
        /// </ul>
        /// </remarks>
        /// <param name="channelId">service address</param>
        /// <param name="responseReceiverId">unique identifier of the connection with the service.</param>
        /// <returns></returns>
        public IDuplexOutputChannel CreateDuplexOutputChannel(string channelId, string responseReceiverId)
        {
            using (EneterTrace.Entering())
            {
                if (myGetLoginMessageCallback == null)
                {
                    string anErrorMessage = TracedObject + "failed to create duplex output channel because the callback to get the login message is null.";
                    EneterTrace.Error(anErrorMessage);
                    throw new InvalidOperationException(anErrorMessage);
                }

                if (myGetHandshakeResponseMessageCallback == null)
                {
                    string anErrorMessage = TracedObject + "failed to create duplex output channel because the callback to get the response message for handshake is null.";
                    EneterTrace.Error(anErrorMessage);
                    throw new InvalidOperationException(anErrorMessage);
                }

                IDuplexOutputChannel anUnderlyingOutputChannel = myUnderlyingMessaging.CreateDuplexOutputChannel(channelId, responseReceiverId);
                IThreadDispatcher    aThreadDispatcher         = OutputChannelThreading.GetDispatcher();
                return(new AuthenticatedDuplexOutputChannel(anUnderlyingOutputChannel, myGetLoginMessageCallback, myGetHandshakeResponseMessageCallback, AuthenticationTimeout, aThreadDispatcher));
            }
        }