Exemple #1
0
        public void ConfigureRemoteHandlers(Client[] clients)
        {
            _remoteExecutionMessageHandlers = new List <RemoteExecutionMessageHandler>(clients.Length);

            foreach (var client in clients)
            {
                var remoteExecutionMessageHandler = new RemoteExecutionMessageHandler
                {
                    FileHandler = new FileManagerHandler(client),
                    TaskHandler = new TaskManagerHandler(client)
                };

                var lvi = new ListViewItem(new[]
                {
                    $"{client.Value.Username}@{client.Value.PcName} [{client.EndPoint.Address}:{client.EndPoint.Port}]",
                    "Waiting..."
                })
                {
                    Tag = remoteExecutionMessageHandler
                };

                lstTransfers.Items.Add(lvi);

                _remoteExecutionMessageHandlers.Add(remoteExecutionMessageHandler);
                RegisterMessageHandler(remoteExecutionMessageHandler);
            }
        }
Exemple #2
0
 /// <summary>
 /// Unregisters the message handlers.
 /// </summary>
 private void UnregisterMessageHandler(RemoteExecutionMessageHandler remoteExecutionMessageHandler)
 {
     MessageHandler.Unregister(remoteExecutionMessageHandler.TaskHandler);
     MessageHandler.Unregister(remoteExecutionMessageHandler.FileHandler);
     remoteExecutionMessageHandler.FileHandler.ProgressChanged        -= SetStatusMessage;
     remoteExecutionMessageHandler.FileHandler.FileTransferUpdated    -= FileTransferUpdated;
     remoteExecutionMessageHandler.TaskHandler.ProcessActionPerformed -= ProcessActionPerformed;
 }
Exemple #3
0
 /// <summary>
 /// Registers the message handlers for client communication.
 /// </summary>
 private void RegisterMessageHandler(RemoteExecutionMessageHandler remoteExecutionMessageHandler)
 {
     // TODO handle disconnects
     remoteExecutionMessageHandler.TaskHandler.ProcessActionPerformed += ProcessActionPerformed;
     remoteExecutionMessageHandler.FileHandler.ProgressChanged        += SetStatusMessage;
     remoteExecutionMessageHandler.FileHandler.FileTransferUpdated    += FileTransferUpdated;
     MessageHandler.Register(remoteExecutionMessageHandler.FileHandler);
     MessageHandler.Register(remoteExecutionMessageHandler.TaskHandler);
 }