Esempio n. 1
0
 public TClientContext(string clientResponseReceiverId, string serviceId, string serviceResponseReceiverId)
 {
     ClientResponseReceiverId = clientResponseReceiverId;
     ServiceId = serviceId;
     ServiceResponseReceiverId        = serviceResponseReceiverId;
     ForwardToClientThreadDispatcher  = new SyncDispatching().GetDispatcher();
     ForwardToServiceThreadDispatcher = new SyncDispatching().GetDispatcher();
 }
 /// <summary>
 /// Constructs the factory with specified timeout for synchronous message sender and specified serializer.
 /// </summary>
 /// <param name="syncResponseReceiveTimeout">maximum waiting time when synchronous message sender is used.</param>
 /// <param name="serializer">serializer that will be used to serialize/deserialize messages.</param>
 public DuplexTypedMessagesFactory(TimeSpan syncResponseReceiveTimeout, ISerializer serializer)
 {
     using (EneterTrace.Entering())
     {
         SyncResponseReceiveTimeout = syncResponseReceiveTimeout;
         Serializer = serializer;
         SyncDuplexTypedSenderThreadMode = new SyncDispatching();
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Constructs RpcFactory with specified serializer.
        /// </summary>
        /// <remarks>
        /// List of serializers provided by Eneter: <see cref="Eneter.Messaging.DataProcessing.Serializing"/>.
        /// </remarks>
        /// <param name="serializer"></param>
        public RpcFactory(ISerializer serializer)
        {
            using (EneterTrace.Entering())
            {
                Serializer = serializer;

                // Default timeout is set to infinite by default.
                RpcTimeout = TimeSpan.FromMilliseconds(-1);

                RpcClientThreading = new SyncDispatching();
            }
        }
        /// <summary>
        /// Constructs the factory specifying the number of processing threads in the input channel and the timeout
        /// for the output channel. It also allows to specify the security settings for the pipe.
        /// </summary>
        /// <remarks>
        /// Security settings can be needed, if communicating processes run under different integrity levels.
        /// E.g. If the service runs under administrator account and the client under some user account,
        /// then the communication will not work until the pipe security is not set.
        /// (Client will get access denied exception.)
        /// <example>
        /// The following example shows how to set the pipe security on the service running under administrator
        /// account to be accessible from client processes.
        /// <code>
        /// PipeSecurity aPipeSecurity = new PipeSecurity();
        ///
        /// // Set to low integrity level.
        /// aPipeSecurity.SetSecurityDescriptorSddlForm("S:(ML;;NW;;;LW)");
        ///
        /// SecurityIdentifier aSid = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
        /// ipeAccessRule aPipeAccessRule = new PipeAccessRule(aSid, PipeAccessRights.ReadWrite, AccessControlType.Allow);
        /// aPipeSecurity.AddAccessRule(aPipeAccessRule);
        ///
        /// // Create the messaging communicating via Named Pipes.
        /// IMessagingSystemFactory aMessagingSystem = new NamedPipeMessagingSystemFactory(10, 10000, aPipeSecurity);
        /// </code>
        /// </example>
        /// </remarks>
        /// <param name="numberOfPipeInstances">
        /// Number of clients that can be connected at the same time.
        /// The maximum number is 254. Many threads can increase the number of processing connections at the same time
        /// but it consumes a lot of resources.
        /// </param>
        /// <param name="pipeConnectionTimeout">
        /// The maximum time in miliseconds, the output channel waits to connect the pipe and sends the message.</param>
        /// <param name="protocolFormatter">formatter of low-level messages between channels</param>
        /// <param name="pipeSecurity">
        /// Pipe security.
        /// </param>
        public NamedPipeMessagingSystemFactory(int numberOfPipeInstances, int pipeConnectionTimeout,
                                               IProtocolFormatter protocolFormatter,
                                               PipeSecurity pipeSecurity)
        {
            using (EneterTrace.Entering())
            {
                myConnectorFactory = new NamedPipeConnectorFactory(protocolFormatter, pipeConnectionTimeout, numberOfPipeInstances, pipeSecurity);

                InputChannelThreading  = new SyncDispatching();
                OutputChannelThreading = InputChannelThreading;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Constructs the factory that will create channel with specified settings.
        /// </summary>
        /// <remarks>
        /// The polling frequency and the inactivity time are used only by duplex channels.
        /// The polling frequency specifies how often the duplex output channel checks if there are pending response messages.
        /// The inactivity time is measured by the duplex input channel and specifies the maximum time, the duplex output channel
        /// does not have to poll for messages.
        /// If the inactivity time is exceeded, considers the duplex output channel as disconnected.
        /// </remarks>
        /// <param name="pollingFrequency">how often the duplex output channel polls for the pending response messages</param>
        /// <param name="inactivityTimeout">maximum time (measured by duplex input channel), the duplex output channel does not have to poll
        /// for response messages. If the time is exceeded, the duplex output channel is considered as disconnected.</param>
        /// <param name="protocolFormatter">formatter for low-level messages between duplex output channel and duplex input channel</param>
        public HttpMessagingSystemFactory(int pollingFrequency, int inactivityTimeout, IProtocolFormatter protocolFormatter)
        {
            using (EneterTrace.Entering())
            {
                myPollingFrequency  = pollingFrequency;
                myProtocolFormatter = protocolFormatter;

                InputChannelThreading  = new SyncDispatching();
                OutputChannelThreading = InputChannelThreading;

                myInputConnectorFactory = new HttpInputConnectorFactory(protocolFormatter, inactivityTimeout);
            }
        }
 /// <summary>
 /// Constructs the UDP messaging factory.
 /// </summary>
 /// <param name="protocolFromatter">formatter used for low-level messaging between output and input channels.</param>
 public UdpMessagingSystemFactory(IProtocolFormatter protocolFromatter)
 {
     using (EneterTrace.Entering())
     {
         myProtocolFormatter    = protocolFromatter;
         InputChannelThreading  = new SyncDispatching();
         OutputChannelThreading = InputChannelThreading;
         Ttl = 128;
         ResponseReceiverPort   = -1;
         UnicastCommunication   = true;
         MulticastLoopback      = true;
         MaxAmountOfConnections = -1;
     }
 }
        /// <summary>
        /// Constructs the factory from specified parameters.
        /// </summary>
        /// <param name="underlyingMessaging">underlying messaging system e.g. Websocket, TCP, ...</param>
        /// <param name="pingFrequency">how often the ping message is sent.</param>
        /// <param name="pingReceiveTimeout">the maximum time within it the ping message must be received.</param>
        public MonitoredMessagingFactory(IMessagingSystemFactory underlyingMessaging,
                                         TimeSpan pingFrequency,
                                         TimeSpan pingReceiveTimeout)
        {
            using (EneterTrace.Entering())
            {
                myUnderlyingMessaging = underlyingMessaging;
                PingFrequency         = pingFrequency;
                ReceiveTimeout        = pingReceiveTimeout;
                Serializer            = new MonitoredMessagingCustomSerializer();

                InputChannelThreading  = new SyncDispatching();
                OutputChannelThreading = InputChannelThreading;
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Constructs the messaging system.
        /// </summary>
        /// <param name="protocolFormatter">formats low-level communication between channels.
        /// The default formatter is EneterProtocolFormatter.
        /// </param>
        public SharedMemoryMessagingSystemFactory(IProtocolFormatter protocolFormatter)
        {
            using (EneterTrace.Entering())
            {
                myProtocolFormatter = protocolFormatter;

                MaxMessageSize       = 10485760;
                SharedMemorySecurity = null;

                ConnectTimeout = TimeSpan.FromMilliseconds(30000);

                // Infinite time for sending and receiving.
                SendTimeout = TimeSpan.FromMilliseconds(0);

                InputChannelThreading  = new SyncDispatching();
                OutputChannelThreading = InputChannelThreading;
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Constructs factory that can be used by client and service simultaneously.
        /// </summary>
        /// <remarks>
        /// If you construct the factory with this constructor you can create both duplex output channels and
        /// duplex input channels.
        /// </remarks>
        /// <param name="underlyingMessagingSystem">underlying messaging upon which the authentication will work.</param>
        /// <param name="getLoginMessageCallback">callback called by the output channel to get the login message which shall be used to open the connection</param>
        /// <param name="getHandshakeResponseMessageCallback">callback called by the output channel to get the response for the handshake message which was received from the input channel.</param>
        /// <param name="getHandshakeMessageCallback">callback called by the input chanel to get the handshake message for the login message which was received from the output channel.</param>
        /// <param name="authenticateCallback">callback called by the input channe to perform the authentication.</param>
        /// <param name="handleAuthenticationCancelledCallback">callback called by the input channel to indicate the output channel closed the connection during the authentication procedure.
        /// Can be null if your authentication code does not need to handle it.
        /// (E.g. if the authentication logic needs to clean if the authentication fails.)</param>
        public AuthenticatedMessagingFactory(IMessagingSystemFactory underlyingMessagingSystem,
                                             GetLoginMessage getLoginMessageCallback,
                                             GetHandshakeResponseMessage getHandshakeResponseMessageCallback,
                                             GetHanshakeMessage getHandshakeMessageCallback,
                                             Authenticate authenticateCallback,
                                             HandleAuthenticationCancelled handleAuthenticationCancelledCallback)
        {
            using (EneterTrace.Entering())
            {
                myUnderlyingMessaging = underlyingMessagingSystem;
                AuthenticationTimeout = TimeSpan.FromMilliseconds(30000);

                myGetLoginMessageCallback             = getLoginMessageCallback;
                myGetHandShakeMessageCallback         = getHandshakeMessageCallback;
                myGetHandshakeResponseMessageCallback = getHandshakeResponseMessageCallback;
                myAuthenticateCallback          = authenticateCallback;
                myHandleAuthenticationCancelled = handleAuthenticationCancelledCallback;

                OutputChannelThreading = new SyncDispatching();
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Constructs the WebSocket messaging factory.
        /// </summary>
        /// <param name="protocolFormatter">formatter used for low-level messaging between output and input channels.</param>
        public WebSocketMessagingSystemFactory(IProtocolFormatter protocolFormatter)
        {
            using (EneterTrace.Entering())
            {
                myProtocolFormatter = protocolFormatter;

                ConnectTimeout = TimeSpan.FromMilliseconds(30000);

                // Infinite time for sending and receiving.
                SendTimeout    = TimeSpan.FromMilliseconds(0);
                ReceiveTimeout = TimeSpan.FromMilliseconds(0);

                ResponseReceiverPort   = -1;
                MaxAmountOfConnections = -1;

                InputChannelThreading  = new SyncDispatching();
                OutputChannelThreading = InputChannelThreading;

                PingFrequency = TimeSpan.FromMilliseconds(300000);
            }
        }
Esempio n. 11
0
 /// <summary>
 /// Constructs the factory.
 /// </summary>
 /// <remarks>
 /// It instantiates the factory with infinite timeout for SyncMultiTypedMessageSender.
 /// </remarks>
 /// <param name="serializer">serializer which will be used to serializer/deserialize messages</param>
 public MultiTypedMessagesFactory(ISerializer serializer)
 {
     SyncResponseReceiveTimeout = TimeSpan.FromMilliseconds(-1);
     Serializer = serializer;
     SyncDuplexTypedSenderThreadMode = new SyncDispatching();
 }