コード例 #1
0
 public SendVideo(string monikerStringVideo, string ip, PictureBox pb_Video, AutoResetEvent nextEventThread, AutoResetEvent thisEventThread)
 {
     udp_Sender           = new Udp_Sender();
     this.ip              = GetIpInBytes(ip);
     listUsers            = new List <InfoSendUser>();
     MonikerStringVideo   = monikerStringVideo;
     this.nextEventThread = nextEventThread;
     this.thisEventThread = thisEventThread;
 }
コード例 #2
0
        private void SendBytesForUdp(Udp_Sender udp_Server, byte[] data, string ip)
        {
            byte[] sendData = new byte[Defines.lengthDgram];
            int    pointer  = 0;

            udp_Server.Connect(ip, Defines.startPortsUsers);
            if (udp_Server.Connected)
            {
                try
                {
                    sendData[Defines.lengthDgram - 5] = this.ip[0];
                    sendData[Defines.lengthDgram - 4] = this.ip[1];
                    sendData[Defines.lengthDgram - 3] = this.ip[2];
                    sendData[Defines.lengthDgram - 2] = this.ip[3];
                    if (data.Length <= (Defines.lengthDgram - 5))
                    {
                        data.CopyTo(sendData, 0);
                        sendData[Defines.lengthDgram - 1] = 1;
                        thisEventThread.WaitOne();
                        udp_Server.SendTo(sendData);
                        nextEventThread.Set();
                    }
                    else
                    {
                        while (pointer < data.Length)
                        {
                            if (pointer == 0)
                            {
                                sendData[Defines.lengthDgram - 1] = 1;
                            }
                            else
                            {
                                sendData[Defines.lengthDgram - 1] = 0;
                            }
                            for (int index = 0; index < Defines.lengthDgram - 5; index++)
                            {
                                if (pointer < data.Length)
                                {
                                    sendData[index] = data[pointer];
                                    pointer++;
                                }
                                else
                                {
                                    break;
                                }
                            }
                            thisEventThread.WaitOne();
                            udp_Server.SendTo(sendData);
                            nextEventThread.Set();
                        }
                    }
                }
                catch (Exception error)
                {
                }
            }
        }
コード例 #3
0
 public void StartGetRequests()
 {
     if ((threadGetRequests == null) || (!threadGetRequests.IsAlive))
     {
         RequestSender    = new Udp_Sender();
         RequestsReceiver = new Udp_Receiver(Defines.portGetRequests);
         threadGetRequests.Start();
     }
 }