Advertisement
Guest User

Untitled

a guest
Aug 30th, 2015
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.81 KB | None | 0 0
  1. using System.Windows;
  2. using ClientCom.CallInitializerService;
  3. using System.Collections.Generic;
  4. using NAudio.Wave;
  5. using System;
  6.  
  7. namespace ClientCom
  8. {
  9.     public class ClientWCFCallback : ICallInitializerServiceCallback
  10.     {
  11.         public readonly MainWindow Window;
  12.         public readonly Register RegisterWindow;
  13.         public ClientWCFCallback(Register registerWindow, MainWindow mainWindow)
  14.         {
  15.             RegisterWindow = registerWindow;
  16.             Window = mainWindow;
  17.         }
  18.  
  19.  
  20.         public void RegisterStatus(bool status)
  21.         {
  22.             if(status)
  23.                 RegisterWindow.RegisterSuccessful();
  24.         }
  25.  
  26.         public void StreamVoiceDataClient(byte[] data, int bytesRecorded)
  27.         {
  28.              Window.Speakers.OnDataAvailable(data,bytesRecorded);
  29.         }
  30.  
  31.         public void PendingCall(Client client)
  32.         {
  33.             // Is calling
  34.             Window.ClientStatus = Status.PendingCall;
  35.             var status = client.Name + " dzwoni!";
  36.             this.Window.SetStatus(status);
  37.             Window.ShowAcceptCallButton();
  38.             Window.ShowRejectCallButton();
  39.             Window.DisableContactsList();
  40.         }
  41.  
  42.         public void WaitingForCallAccept()
  43.         {
  44.             this.Window.SetStatus("Dryndam ...");
  45.         }
  46.  
  47.         public void CallRefused()
  48.         {
  49.             Window.ClientStatus = Status.Available;
  50.             Window.Speakers = null;
  51.             Window.Mic = null;
  52.             // odrzucił chuj ;(
  53.             this.Window.SetStatus("Rozmowa odrzucona ;(");
  54.             Window.EnableContactsList();
  55.             Window.ShowAcceptCallButton();
  56.             Window.HideRejectCallButton();
  57.             Window.EnableContactsList();
  58.  
  59.         }
  60.  
  61.         public void CallAccepted()
  62.         {
  63.             Window.ClientStatus = Status.InConversation;
  64.             Window.Mic = new MicrophoneListener(Window.ServiceClient);
  65.             Window.Speakers = new SpeakersSender(new WaveFormat(8000, 1));
  66.             Window.Mic.Speakers = Window.Speakers;
  67.             Window.Speakers.Start();
  68.             Window.Mic.Run();
  69.             this.Window.SetStatus("Mów do różdżki");
  70.            
  71.         }
  72.  
  73.         public void CallEnded()
  74.         {
  75.             Window.ClientStatus = Status.Available;
  76.             Window.Speakers.Stop();
  77.             Window.Speakers = null;
  78.             Window.Mic.Stop();
  79.             Window.Mic = null;
  80.             throw new System.NotImplementedException();
  81.         }
  82.  
  83.         public void EndCall()
  84.         {
  85.             MessageBox.Show("EndCall");
  86.         }
  87.  
  88.         public void SendResponse(Response response)
  89.         {
  90.            
  91.         }
  92.         public void UpdateClientList(List<Client> list)
  93.         {
  94.             Window.UpdateClientList(list);
  95.         }
  96.  
  97.        
  98.     }
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement