/// <summary> /// Creates the input channel which can receive messages from the output channel and send response messages. /// </summary> /// <remarks> /// In addition it expects receiving ping messages from each connected client within a specified time and sends /// ping messages to each connected client in a specified frequency. /// </remarks> /// <param name="channelId">input channel address. It must comply to underlying messaging</param> /// <returns>monitoring duplex input channel</returns> public IDuplexInputChannel CreateDuplexInputChannel(string channelId) { using (EneterTrace.Entering()) { IDuplexInputChannel anUnderlyingChannel = myUnderlyingMessaging.CreateDuplexInputChannel(channelId); IThreadDispatcher aThreadDispatcher = InputChannelThreading.GetDispatcher(); return(new MonitoredDuplexInputChannel(anUnderlyingChannel, Serializer, (int)PingFrequency.TotalMilliseconds, (int)ReceiveTimeout.TotalMilliseconds, aThreadDispatcher)); } }
public IDuplexInputChannel CreateDuplexInputChannel(string channelId) { using (EneterTrace.Entering()) { IThreadDispatcher aDispatcher = InputChannelThreading.GetDispatcher(); IInputConnector anInputConnector = myInputConnectorFactory.CreateInputConnector(channelId); return(new DefaultDuplexInputChannel(channelId, aDispatcher, myDispatcherAfterMessageDecoded, anInputConnector)); } }
/// <summary> /// Creates the duplex input channel which can receive and send messages to the duplex output channel using shared memory. /// </summary> /// <param name="channelId">Address which shell be used for listening. /// It is the name of the memory-mapped file that will be used to send and receive messages. /// </param> /// <returns>duplex input channel</returns> public IDuplexInputChannel CreateDuplexInputChannel(string channelId) { using (EneterTrace.Entering()) { IInputConnectorFactory aConnectorFactory = new SharedMemoryConnectorFactory(myProtocolFormatter, ConnectTimeout, SendTimeout, MaxMessageSize, SharedMemorySecurity); IThreadDispatcher aThreadDispatcher = InputChannelThreading.GetDispatcher(); IInputConnector anInputConnector = aConnectorFactory.CreateInputConnector(channelId); IThreadDispatcher aDispatcherAfterMessageDecoded = myDispatchingAfterMessageDecoded.GetDispatcher(); return(new DefaultDuplexInputChannel(channelId, aThreadDispatcher, aDispatcherAfterMessageDecoded, anInputConnector)); } }
/// <summary> /// Creates the duplex input channel which can receive and send messages to the duplex output channel using UDP. /// </summary> /// <remarks> /// It can create duplex input channels for unicast, multicast or broadcast communication. /// If the property UnicastCommunication is set to true then it creates the input channel for the unicast communication. /// It means, like a service it can receive connections and messages from multiple output channels but /// send messages only to particular output channels which are connected. /// 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 output channels. /// It also can receive multicast and broadcast messages. /// <example> /// Creating the duplex input channel for unicast communication. /// <code> /// IMessagingSystemFactory aMessaging = new UdpMessagingSystemFactory(); /// IDuplexInputChannel anInputChannel = aMessaging.CreateDuplexInputChannel("udp://127.0.0.1:8765/"); /// </code> /// </example> /// <example> /// Creating the duplex input channel for multicast communication. /// <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 duplex input channel which is listening to udp://127.0.0.1:8095/ and can also receive multicast messages /// // sent to udp://234.4.5.6:8095/. /// IDuplexInputChannel anInputChannel = aMessaging.CreateDuplexInputChannel("udp://127.0.0.1:8095/"); /// </code> /// </example> /// <example> /// Sending mulitcast and broadcast messages from the duplex input channel. /// <code> /// IProtocolFormatter aProtocolFormatter = new EasyProtocolFormatter(); /// IMessagingSystemFactory aMessaging = new UdpMessagingSystemFactory(aProtocolFormatter) /// { /// // Setup the factory to create channels for mulitcast or broadcast communication. /// UnicastCommunication = false, /// /// // Setup the factory to create chennels which are allowed to send broadcast messages. /// AllowSendingBroadcasts = true /// } /// /// // Create duplex input channel which is listening to udp://127.0.0.1:8095/. /// IDuplexInputChannel anInputChannel = aMessaging.CreateDuplexInputChannel("udp://127.0.0.1:8095/"); /// /// // Subscribe to handle messages. /// anIputChannel.MessageReceived += OnMessageReceived; /// /// // Start listening. /// anIputChannel.StartListening(); /// /// ... /// /// // Send a multicast message. /// // Note: it will be received by all output and input channels which have joined the multicast group 234.4.5.6 /// // and are listening to the port 8095. /// anInputChannel.SendResponseMessage("udp://234.4.5.6:8095/", "Hello"); /// /// ... /// /// // Send a broadcast message. /// // Note: it will be received by all output and input channels within the sub-network which are listening to the port 8095. /// anInputChannel.SendResponseMessage("udp://255.255.255.255:8095/", "Hello"); /// /// ... /// /// // Stop listening. /// anInputChannel.StopListening(); /// </code> /// </example> /// </remarks> /// <param name="channelId">Identifies this duplex input channel. The channel id must be a valid URI address (e.g. udp://127.0.0.1:8090/) the input channel will listen to.</param> /// <returns>duplex input channel</returns> public IDuplexInputChannel CreateDuplexInputChannel(string channelId) { using (EneterTrace.Entering()) { IThreadDispatcher aDispatcher = InputChannelThreading.GetDispatcher(); IInputConnectorFactory aConnectorFactory = new UdpConnectorFactory(myProtocolFormatter, ReuseAddress, -1, UnicastCommunication, AllowSendingBroadcasts, Ttl, MulticastGroupToReceive, MulticastLoopback, MaxAmountOfConnections); IInputConnector anInputConnector = aConnectorFactory.CreateInputConnector(channelId); return(new DefaultDuplexInputChannel(channelId, aDispatcher, myDispatcherAfterMessageDecoded, anInputConnector)); } }
/// <summary> /// Creates the duplex input channel receiving messages from the duplex output channel and sending back response messages by using WebSocket. /// </summary> /// <param name="channelId">Identifies this duplex input channel. The channel id must be a valid URI address (e.g. ws://127.0.0.1:8090/MyService/) the input channel will listen to.</param> /// <returns>duplex input channel</returns> public IDuplexInputChannel CreateDuplexInputChannel(string channelId) { using (EneterTrace.Entering()) { IThreadDispatcher aDispatcher = InputChannelThreading.GetDispatcher(); IInputConnectorFactory anInputConnectorFactory = new WebSocketInputConnectorFactory(myProtocolFormatter, ServerSecurityStreamFactory, (int)SendTimeout.TotalMilliseconds, (int)ReceiveTimeout.TotalMilliseconds, ReuseAddress, MaxAmountOfConnections); IInputConnector anInputConnector = anInputConnectorFactory.CreateInputConnector(channelId); return(new DefaultDuplexInputChannel(channelId, aDispatcher, myDispatcherAfterMessageDecoded, anInputConnector)); } }