void HandleClient4Event(object sender, ServerEvent serverEvent)
        {
            var logMessageForConsole = $"(client4)\t{serverEvent}";

            var logMessageForFile =
                $"(client4)\t{DateTime.Now:MM/dd/yyyy HH:mm:ss.fff}\t{serverEvent.GetLogFileEntry()}";

            if (!serverEvent.DoNotDisplayInLog)
            {
                Console.WriteLine(logMessageForConsole);
                _client4LogMessages.Add(logMessageForFile);
            }

            switch (serverEvent.EventType)
            {
            case EventType.ReceivedNotificationFolderIsEmpty:
                _client4WasNotifiedFolderIsEmpty = true;
                break;
            }
        }
        void HandleClient3Event(object sender, ServerEvent serverEvent)
        {
            var logMessageForConsole = $"(client3)\t{serverEvent}";

            var logMessageForFile =
                $"(client3)\t{DateTime.Now:MM/dd/yyyy HH:mm:ss.fff}\t{serverEvent.GetLogFileEntry()}";

            if (!serverEvent.DoNotDisplayInLog)
            {
                Console.WriteLine(logMessageForConsole);
                _client3LogMessages.Add(logMessageForFile);
            }

            switch (serverEvent.EventType)
            {
            case EventType.ReceivedFileList:
                _client3ReceivedFileInfoList = true;
                break;
            }
        }
Пример #3
0
        void HandleClientEvent(object sender, ServerEvent serverEvent)
        {
            var logMessageForConsole = $"(client)\t{serverEvent}";

            var logMessageForFile =
                $"(client)\t{DateTime.Now:MM/dd/yyyy HH:mm:ss.fff}\t{serverEvent.GetLogFileEntry()}";

            if (!serverEvent.DoNotDisplayInLog)
            {
                Console.WriteLine(logMessageForConsole);
                _clientLogMessages.Add(logMessageForFile);
            }

            switch (serverEvent.EventType)
            {
            case EventType.PendingFileTransfer:
                _clientFileTransferPending = true;
                break;

            case EventType.ReceivedTextMessage:
                _clientReceivedTextMessage = true;
                break;

            case EventType.ReceivedServerInfo:
                _remoteServerFolderPath   = serverEvent.RemoteFolder;
                _remoteServerPublicIp     = serverEvent.PublicIpAddress;
                _remoteServerLocalIp      = serverEvent.LocalIpAddress;
                _remoteServerPlatform     = serverEvent.RemoteServerPlatform;
                _clientReceivedServerInfo = true;
                break;

            case EventType.ReceivedFileList:
                _fileInfoList = serverEvent.RemoteServerFileList;
                _clientReceivedFileInfoList = true;
                break;

            case EventType.ReceivedNotificationFileDoesNotExist:
                _clientWasNotifiedFileDoesNotExist = true;
                break;

            case EventType.ReceiveFileBytesStarted:
                _clientReceiveFileBytesStarted = true;
                break;

            case EventType.ReceiveFileBytesComplete:
                _clientReceiveFileBytesComplete = true;
                break;

            case EventType.ReceivedRetryLimitExceeded:
                _clientWasNotifiedRetryLimitExceeded = true;
                break;

            case EventType.RemoteServerRejectedFileTransfer:
                _serverRejectedFileTransfer = true;
                break;

            case EventType.ReceivedNotificationFolderIsEmpty:
                _clientWasNotifiedFolderIsEmpty = true;
                break;

            case EventType.ReceivedNotificationFolderDoesNotExist:
                _clientWasNotifiedFolderDoesNotExist = true;
                break;

            case EventType.RemoteServerConfirmedFileTransferCompleted:
                _serverConfirmedFileTransferComplete = true;
                break;

            case EventType.ProcessRequestBacklogStarted:
                _clientProcessingRequestBacklogStarted = true;
                break;

            case EventType.ProcessRequestBacklogComplete:
                _clientProcessingRequestBacklogComplete = true;
                break;

            case EventType.ErrorOccurred:
                _clientErrorOccurred = true;
                break;
            }
        }
Пример #4
0
        void HandleServerEvent(object sender, ServerEvent serverEvent)
        {
            var logMessageForConsole = $"(server)\t{serverEvent}";

            var logMessageForFile =
                $"(server)\t{DateTime.Now:MM/dd/yyyy HH:mm:ss.fff}\t{serverEvent.GetLogFileEntry()}";

            if (!serverEvent.DoNotDisplayInLog)
            {
                Console.Write(logMessageForConsole);
                _serverLogMessages.Add(logMessageForFile);
            }

            switch (serverEvent.EventType)
            {
            case EventType.PendingFileTransfer:
                _serverFileTransferPending = true;
                break;

            case EventType.ReceivedTextMessage:
                _serverReceivedTextMessage = true;
                break;

            case EventType.StoppedSendingFileBytes:
                _serverStoppedSendingFileBytes = true;
                break;

            case EventType.FileTransferStalled:
                _serverWasNotifiedFileTransferStalled = true;
                break;

            case EventType.ReceiveFileBytesComplete:
                _serverReceivedAllFileBytes = true;
                break;

            case EventType.SendFileBytesStarted:
                _serverSendFileBytesStarted = true;
                break;

            case EventType.SendFileBytesComplete:
                _serverSendFileBytesComplete = true;
                break;

            case EventType.RemoteServerRejectedFileTransfer:
                _clientRejectedFileTransfer = true;
                break;

            case EventType.RemoteServerConfirmedFileTransferCompleted:
                _clientConfirmedFileTransferComplete = true;
                break;

            case EventType.ProcessRequestBacklogStarted:
                _serverProcessingRequestBacklogStarted = true;
                break;

            case EventType.ProcessRequestBacklogComplete:
                _serverProcessingRequestBacklogComplete = true;
                break;

            case EventType.ErrorOccurred:
                _serverErrorOccurred = true;
                break;
            }
        }
        async void HandleServerEventAsync(object sender, ServerEvent serverEvent)
        {
            _log.Info(serverEvent.GetLogFileEntry());

            switch (serverEvent.EventType)
            {
            case EventType.ProcessRequestComplete:
                await CheckIfRemoteServerAlreadySavedAsync(serverEvent);

                RefreshMainMenu(serverEvent);
                break;

            case EventType.ReceivedTextMessage:
            case EventType.PendingFileTransfer:
            case EventType.SendFileTransferRejectedStarted:
                RefreshMainMenu(serverEvent);
                break;

            case EventType.ReceivedServerInfo:
                ReceivedServerInfo(serverEvent);
                break;

            case EventType.ReceivedFileList:
                _state.RemoteServerFileList       = serverEvent.RemoteServerFileList;
                _state.WaitingForFileListResponse = false;
                return;

            case EventType.ReceivedNotificationFolderIsEmpty:
                _state.NoFilesAvailableForDownload = true;
                _state.WaitingForFileListResponse  = false;
                break;

            case EventType.ReceivedNotificationFolderDoesNotExist:
                _state.RequestedFolderDoesNotExist = true;
                _state.WaitingForFileListResponse  = false;
                break;

            case EventType.SendFileBytesStarted:
                _state.OutboundFileTransferInProgress = true;
                _mainMenu.DisplayMenu();
                break;

            case EventType.FileTransferStalled:
            case EventType.SendFileBytesComplete:
                _state.OutboundFileTransferInProgress = false;
                _mainMenu.DisplayMenu();
                break;

            case EventType.ReceiveFileBytesStarted:
                _state.InboundFileTransferInProgress = true;
                ReceiveFileBytesStarted(serverEvent);
                break;

            case EventType.ReceiveFileBytesComplete:
                _state.InboundFileTransferInProgress = false;
                await ReceiveFileBytesCompleteAsync(serverEvent).ConfigureAwait(false);

                break;

            case EventType.SendFileTransferStalledComplete:
                await NotifiedRemoteServerThatFileTransferIsStalledAsync().ConfigureAwait(false);

                break;

            case EventType.ErrorOccurred:
                HandleErrorOccurred();
                _mainMenu.DisplayMenu();
                break;

            default:
                return;
            }
        }