コード例 #1
0
		public UDP_Control()
		{
			this.InitializeComponent();
            DataContext = this;

            CurClient = new UDP_Client();
            CurServer = new UDP_Server();		    


            this.Loaded += new RoutedEventHandler(UDP_Control_Loaded);
		}
コード例 #2
0
        public ServerVideoChatViewModel()
        {
            try
            {
                UDP_IP_VIDEO = new UDP_Client() { ServerIP = "224.0.0.1", ServerPort = 5000 };
                UDP_IP_VIDEO.Start();
                UDP_IP_AUDIO = new UDP_Client() { ServerIP = "224.0.0.1", ServerPort = 6000 };
                UDP_IP_AUDIO.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ошибка создания UDP серверов\n" + ex.ToString());
                //throw;
            }

            try
            {
                if (waveIn == null)
                {
                    if(WaveInRecorder.Devices.Length>0)
                    {
                        WaveIn = new WaveInRecorder(-1, waveFormat, 4096, 2);
                        WaveIn.DevRecordIn = WaveInRecorder.Devices[0];
                    }
                    else
                        WaveIn = new WaveInRecorder(-1, waveFormat, 4096, 2);
                }

            }
            catch (Exception)
            {

            }

            try
            {
                netCamera.NewImage += (_1, e) =>
                {
                    if (Participant != null && Participant.State == CommunicationState.Opened)
                    {
                        lock (this)
                        {
                            IPVideoSample = e.ImageBuffer.Clone() as byte[];
                        }
                    }
                };
                tmrPing = new DispatcherTimer() { Interval = TimeSpan.FromSeconds(1) };
                StartIPVideoSending();

                IsPinging = true;
                CheckAutoStart();
                ClickOnceUpdater.Restarting += (_1, _2) => { SaveSettings(); };
                tmrTime.Tick += (_1, _2) =>
                {
                    tmrTime.Stop();
                    if (Participant != null && Participant.State == CommunicationState.Opened)
                    {
                        Participant.TimeSignal(ServerName, DateTime.Now);
                    }
                    tmrTime.Start();
                };
                tmrTime.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.StackTrace);
            }
        }