public MonitoredDuplexOutputChannel(IDuplexOutputChannel underlyingOutputChannel, ISerializer serializer,
                                            int pingFrequency,
                                            int receiveTimeout,
                                            IThreadDispatcher dispatcher)
        {
            using (EneterTrace.Entering())
            {
                myUnderlyingOutputChannel = underlyingOutputChannel;

                mySerializer     = serializer;
                myPingFrequency  = pingFrequency;
                myReceiveTimeout = receiveTimeout;
                Dispatcher       = dispatcher;

                MonitorChannelMessage aPingMessage = new MonitorChannelMessage(MonitorChannelMessageType.Ping, null);
                myPreserializedPingMessage = mySerializer.Serialize <MonitorChannelMessage>(aPingMessage);

                myPingingTimer = new EneterTimer(OnPingingTimerTick);
                myReceiveTimer = new EneterTimer(OnResponseTimerTick);

                myUnderlyingOutputChannel.ResponseMessageReceived += OnResponseMessageReceived;
                myUnderlyingOutputChannel.ConnectionOpened        += OnConnectionOpened;
                myUnderlyingOutputChannel.ConnectionClosed        += OnConnectionClosed;
            }
        }
示例#2
0
        public MonitoredDuplexInputChannel(IDuplexInputChannel underlyingInputChannel, ISerializer serializer,
                                           int pingFrequency,
                                           int receiveTimeout,
                                           IThreadDispatcher dispatcher)
        {
            using (EneterTrace.Entering())
            {
                myUnderlyingInputChannel = underlyingInputChannel;
                mySerializer             = serializer;

                myPingFrequency  = pingFrequency;
                myReceiveTimeout = receiveTimeout;
                Dispatcher       = dispatcher;

                myCheckTimer = new EneterTimer(OnCheckerTick);

                MonitorChannelMessage aPingMessage = new MonitorChannelMessage(MonitorChannelMessageType.Ping, null);
                myPreserializedPingMessage = mySerializer.Serialize <MonitorChannelMessage>(aPingMessage);
            }
        }