public AuthenticatedDuplexOutputChannel(IDuplexOutputChannel underlyingOutputChannel, GetLoginMessage getLoginMessageCallback, GetHandshakeResponseMessage getHandshakeResponseMessageCallback, TimeSpan authenticationTimeout, IThreadDispatcher threadDispatcher) { using (EneterTrace.Entering()) { myUnderlyingOutputChannel = underlyingOutputChannel; myGetLoginMessageCallback = getLoginMessageCallback; myGetHandshakeResponseMessageCallback = getHandshakeResponseMessageCallback; myAuthenticationTimeout = authenticationTimeout; myUnderlyingOutputChannel.ConnectionClosed += OnConnectionClosed; myUnderlyingOutputChannel.ResponseMessageReceived += OnResponseMessageReceived; myThreadDispatcher = threadDispatcher; } }
/// <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(); } }
/// <summary> /// Constructs factory that will be used only by a client. /// </summary> /// <remarks> /// The constructor takes only callbacks which are used by the client. Therefore if you use this constructor /// you can create only duplex output 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> public AuthenticatedMessagingFactory(IMessagingSystemFactory underlyingMessagingSystem, GetLoginMessage getLoginMessageCallback, GetHandshakeResponseMessage getHandshakeResponseMessageCallback) : this(underlyingMessagingSystem, getLoginMessageCallback, getHandshakeResponseMessageCallback, null, null, null) { }