Exemple #1
0
 public void AddFragment(ImageMessage imageMessage)
 {
     Fragments.Add(imageMessage);
 }
Exemple #2
0
 private async Task ListenAsync(short channel)
 {
     bool listening = true;
     while (listening)
     {
         var result = await Client.ReceiveAsync();
         var message = Messaging.ReceiveMessage(result.Buffer);
         switch (message.Type)
         {
             case MessageType.Disconnect:
             case MessageType.Terminate:
                 await EndConnection(channel, true);
                 listening = false;
                 break;
             case MessageType.Acknowledge:
                 var acknowledgeMessage = new AcknowledgeMessage(message.Payload);
                 ClientResolutionChanged?.Invoke(this,
                     new ClientResolutionChangedEventArgs(acknowledgeMessage.ScreenWidth, acknowledgeMessage.ScreenHeight));
                 IsConnected = true;
                 break;
             case MessageType.Sharing:
                 var sharingMessage = new SharingMessage(message.Payload);
                 Sharing?.Invoke(this, sharingMessage.IsSharing);
                 break;
             case MessageType.Image:
                 var imageMessage = new ImageMessage(message.Payload);
                 try
                 {
                     var imageFragment = ImageFragments.FirstOrDefault(mf => mf.MessageId.Equals(message.MessageId));
                     if (imageFragment == null)
                     {
                         imageFragment = new ImageFragment(message.MessageId, imageMessage);
                         ImageFragments.Add(imageFragment);
                     }
                     else
                         imageFragment.AddFragment(imageMessage);
                 }
                 catch (Exception ex)
                 {
                     Console.WriteLine($"Something bad happened: {ex.Message}");
                 }
                 break;
             case MessageType.MouseMessage:
                 var mouseMessage = new MouseMessage(message.Payload);
                 MouseMove?.Invoke(this,
                     new MouseMoveEventArgs(mouseMessage.X, mouseMessage.Y, mouseMessage.ScreenWidth,
                         mouseMessage.ScreenHeight));
                 break;
         }
     }
 }
Exemple #3
0
 public ImageFragment(short messageId, ImageMessage imageMessage)
 {
     MessageId = messageId;
     Length = imageMessage.ImageLength;
     Fragments.Add(imageMessage);
     ImageLocation = imageMessage.Location;
     Duration.Start();
 }