Example #1
0
 private void UserLeftRoom(int who)
 {
     Application.Current.Dispatcher.Invoke(delegate
     {
         FriendsInCall.Remove(FriendsInCall.FirstOrDefault(f => f.Friend.Id == who));
     });
 }
Example #2
0
        private void NewUserCall(int who)
        {
            if (!VoiceRecorder.Recording)
            {
                VoiceRecorder.StartRecording();
                InCall = true;
            }

            if (FriendsInCall.FirstOrDefault(f => f.Friend.Id == who) == null)
            {
                Application.Current.Dispatcher.Invoke(delegate
                {
                    User newFriend = Client.Friends.FirstOrDefault(f => f.Id == who);
                    if (newFriend == null)
                    {
                        newFriend = new User(who, "Unknown friend", null);
                    }
                    Call newFriendCall = new Call(newFriend);
                    if (!FriendsInCall.Contains(newFriendCall))
                    {
                        FriendsInCall.Add(newFriendCall);
                    }


                    using (MemoryStream ms = new MemoryStream())
                    {
                        Resources.Resources.welcomeuser.CopyTo(ms);
                        Client.SendToServer(new ServerObject(ServerFlag.SendingData, new SenderObject(SenderFlags.Voice, ms.ToArray())));
                    }


                    newFriendCall.Frame = ImageSourceFromBitmap((Bitmap)newFriend.Picture);
                });
            }
        }
Example #3
0
        private void EndCall()
        {
            VoiceRecorder.StopRecording();
            ScreenRecorder.StopRecord();

            Application.Current.Dispatcher.Invoke(delegate
            {
                FriendsInCall.Clear();
                InCall = false;
            });
            Client.SendToServer(new ServerObject(ServerFlag.ExitFromGroup, Client.Id));
        }
Example #4
0
        private void NewVoice(byte[] voice, int id)
        {
            Call auxFriend = FriendsInCall.FirstOrDefault(f => f.Friend.Id == id);

            if (auxFriend != null)
            {
                auxFriend.AddToQueue(voice);
            }
            else
            {
                NewUserCall(id);
            }
        }
Example #5
0
        private void NewFrame(List <VideoFrame.FrameMapping> frames, System.Windows.Point resolution, int id)
        {
            Task.Run(() =>
            {
                Call auxFriend = FriendsInCall.FirstOrDefault(f => f.Friend.Id == id);
                if (auxFriend == null)
                {
                    NewUserCall(id);
                }
                if (auxFriend.Resolution == null)
                {
                    auxFriend.SetResolution(resolution);
                }

                auxFriend.Render(frames);
            });
        }