Esempio n. 1
0
        public void InitiateCommunication(Address serverAddress)
        {
            heartbeatThreadCollection = new HeartbeatThreadCollection();
            heartbeatThreadCollection.ClientVanished += OnClientVanished;

            notificationThreadCollection = new NotificationThreadCollection();

            var responseHandlerFactory = new ResponseHandlerFactory(dataCenter,
                                                                    sessionRepository,
                                                                    NewConnectionEstablished,
                                                                    NewDebugConnectionEstablishedCallback,
                                                                    ConnectionEnded);

            universalResponseThread = new UniversalResponseThread(serverAddress, responseHandlerFactory);
            new Thread(universalResponseThread.Run).Start();

            IsConnectionActive = true;
        }
Esempio n. 2
0
        public void StopCommunication()
        {
            sessionRepository.ClearRepository();

            if (heartbeatThreadCollection != null)
            {
                heartbeatThreadCollection.Dispose();
                heartbeatThreadCollection.ClientVanished -= OnClientVanished;
                heartbeatThreadCollection = null;
            }

            notificationThreadCollection?.Dispose();
            notificationThreadCollection = null;

            universalResponseThread?.Stop();
            universalResponseThread = null;

            IsConnectionActive = false;
        }