Exemple #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="ev"></param>
 public void OnEvent(SlaveEvent ev)
 {
     switch ((SlaveEventType)ev.EventType)
     {
     case SlaveEventType.IncommingMessage:
     {
         ev.Data.Match()
         .With <GreetTheMasterMessage>(m =>
             {
                 if (ev.Source.Initialize(m.Ip, m.OperatingSystem, m.MachineName, m.UserName))
                 {
                     FireSlaveConnected(ev.Source);
                 }
             })
         .With <PongMessage>(m => ev.Source.DecrementPingTimeout())
         .With <LoginMessage>(m =>
             {
                 if (StudentsDB.QueryStuidAndPassword(m.stuid, m.password) == 1)
                 {
                     ev.Source.Send(new LoginSuccessMessage
                     {
                         Price = 0.05
                     });
                 }
                 else
                 {
                     ev.Source.Send(new LoginFailMessage());
                 }
             });
         break;
     }
     }
 }
Exemple #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="ev"></param>
 public override async void OnEvent(SlaveEvent ev)
 {
     base.OnEvent(ev);
     await this.ExecuteInDispatcher(() =>
     {
         switch ((SlaveEventType)ev.EventType)
         {
         case SlaveEventType.IncommingMessage:
             {
                 ev.Data.Match().With <WebcamCaptureMessage>(UpdateScreenCapture);
                 break;
             }
         }
     });
 }
Exemple #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="ev"></param>
 public override async void OnEvent(SlaveEvent ev)
 {
     base.OnEvent(ev);
     await this.ExecuteInDispatcher(() =>
     {
         switch ((SlaveEventType)ev.EventType)
         {
         case SlaveEventType.IncommingMessage:
             {
                 ev.Data.Match()
                 .With <TasksMessage>(message =>
                 {
                     TasksList.ItemsSource = message.Tasks.Select(c => c.Dictionary).ToArray();
                 });
                 break;
             }
         }
     });
 }
Exemple #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="ev"></param>
 public override async void OnEvent(SlaveEvent ev)
 {
     base.OnEvent(ev);
     await this.ExecuteInDispatcher(() =>
     {
         switch ((SlaveEventType)ev.EventType)
         {
         case SlaveEventType.IncommingMessage:
             {
                 ev.Data.Match()
                 .With <FolderNavigationMessage>(m =>
                 {
                     TxtBoxDirectory.Text = m.Path;
                     ViewModelFiles.Items.Clear();
                     m.Files.ForEach(ViewModelFiles.AddItem);
                 })
                 .With <DownloadedFilePartMessage>(m =>
                 {
                     UpdateCommand(m, command =>
                     {
                         command.Completed = m.CurrentPart >= m.TotalPart;
                         command.UpdateProgression(m.CurrentPart + 1, m.TotalPart);
                     });
                 })
                 .With <UploadProgressMessage>(m =>
                 {
                     // will be received when the slave download the file
                     UpdateCommand(m, command =>
                     {
                         command.Completed = m.Percentage == -1;
                         if (!command.Completed)
                         {
                             command.UpdateProgression(m.Percentage, 100);
                         }
                     });
                 })
                 .With <FileDeletionMessage>(m => NavigateToTypedFolder());
                 break;
             }
         }
     });
 }
Exemple #5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="ev"></param>
 public static void PostEvent(SlaveEvent ev) => SlaveEvents.PostEvent(ev);