示例#1
0
 /// <summary>
 /// 初始化接收消息队列
 /// </summary>
 /// <param name="msg">消息</param>
 /// <param name="ip">发送者IP</param>
 /// <param name="port">发送者端口</param>
 /// <param name="sender">发送者套接字对像</param>
 public UDPReceiveMessage(IMLibrary.Class.Msg msg, System.Net.IPAddress ip, int port, object sender)
 {
     this.Msg = msg;
     this.Ip = ip;
     this.Port = port;
     this.Sender = sender;
 }
示例#2
0
 //视频位图信息捕获事件
 void video1_VideoCapturerBefore(object sender, IMLibrary.AV.BITMAPINFO bitmapinfo)
 {
     IMLibrary3.Protocol.AVMsg msg = new IMLibrary3.Protocol.AVMsg();
     msg.type = IMLibrary3.Protocol.type.Else;//其他信息
     msg.biBitCount =bitmapinfo.bmiHeader.biBitCount ;
     msg.biClrImportant = bitmapinfo.bmiHeader.biClrImportant;
     msg.biClrUsed = bitmapinfo.bmiHeader.biClrUsed;
     msg.biCompression = bitmapinfo.bmiHeader.biCompression;
     msg.biHeight = bitmapinfo.bmiHeader.biHeight;
     msg.biPlanes = bitmapinfo.bmiHeader.biPlanes;
     msg.biSize = bitmapinfo.bmiHeader.biSize;
     msg.biSizeImage = bitmapinfo.bmiHeader.biSizeImage;
     msg.biWidth = bitmapinfo.bmiHeader.biWidth;
     msg.biXPelsPerMeter = bitmapinfo.bmiHeader.biXPelsPerMeter;
     msg.biYPelsPerMeter = bitmapinfo.bmiHeader.biYPelsPerMeter;
     
     if (SendMsgToUser != null)//触发消息发送事件
         SendMsgToUser(msg, User);
 } 
 /// <summary>
 /// sockUDP 发送文件数据
 /// </summary>
 /// <param name="fInfo">文件信息</param>
 private void sendData(IMLibrary.Class.msgAV msg)
 {
     try
     {
         if (this.netClass == IMLibrary.Class.NetCommunicationClass.LanUDP)//如果是局域网通信
             this.sockUDP1.Send(this._OppositeUserInfo.LocalIP, this.OppositeUDPPort, msg.getBytes());//采用UDP发送数据到对方局域网IP与端口
         else if (this.netClass == IMLibrary.Class.NetCommunicationClass.WanNoProxyUDP)//如果是广域网直接通信
             this.sockUDP1.Send(this._OppositeUserInfo.IP, this.OppositeUDPPort, msg.getBytes());//采用UDP发送数据到对方广域网IP与端口
         else if (this.netClass == IMLibrary.Class.NetCommunicationClass.WanProxyUDP)//如果是广域网服务器中转通信
             this.sockUDP1.Send(this._serverIp, this._serverUDPPort, msg.getBytes());//采用UDP发送数据到服务器中转IP与端口
         else if (this.netClass == IMLibrary.Class.NetCommunicationClass.TCP)
             this.TCPClient1.SendData(msg.getBytes());//采用TCP发送数据
     }
     catch
     { }
 }
示例#4
0
 /// <summary>
 /// �ͻ��˶Ͽ�����
 /// </summary>
 private void Close(object sender, IMLibrary.Net.SockEventArgs e)
 {
     if (OnClose  != null)
         OnClose(sender,e );
 }
 /// <summary>
 /// sockUDP �����ļ�����
 /// </summary>
 /// <param name="msg">�ļ���Ϣ</param>
 private void sendData(IMLibrary.Class.msgFile msg)
 {
     try
     {
         if (this.netClass == IMLibrary.Class.NetCommunicationClass.LanUDP)//����Ǿ�����ͨ��
             this.sockUDP1.Send(this._OppositeUserInfo.LocalIP,this.OppositeUDPPort, msg.getBytes());//����UDP�������ݵ��Է�������IP��˿�
         else if (this.netClass == IMLibrary.Class.NetCommunicationClass.WanNoProxyUDP)//����ǹ�����ֱ��ͨ��
             this.sockUDP1.Send(this._OppositeUserInfo.IP, this.OppositeUDPPort, msg.getBytes());//����UDP�������ݵ��Է�������IP��˿�
         else if (this.netClass == IMLibrary.Class.NetCommunicationClass.WanProxyUDP)//����ǹ�������������תͨ��
             this.sockUDP1.Send(this._serverIp, this._serverUDPPort, msg.getBytes());//����UDP�������ݵ���������תIP��˿�
         else if (this.netClass == IMLibrary.Class.NetCommunicationClass.TCP)
             this.asyncTCPClient1.SendData(msg.getBytes());//����TCP��������
     }
     catch
     { }
 }
        private void DataArrival(IMLibrary.Class.msgFile msg, IMLibrary.Class.NatClass netClass, System.Net.IPAddress Ip, int Port)
        {
            switch (msg.InfoClass)
            {
                case (byte)IMLibrary.Class.ProtocolFileTransmit.GetFileTransmitProxyID://����Լ��ӷ������ϻ����ת����ID
                    {
                        this.serverSelfID = msg.SendID;
                        if (this.serverOppositeID != -1)//����Ƿ��ͷ������ת����ID������߶Է���ʼ�ս��ļ�
                        {
                            this.netClass = IMLibrary.Class.NetCommunicationClass.TCP;//��ʶ��ǰͨ��Э��ΪTCP
                            //this._mtu = 1200;//�����������ļ�ʱ����MTUֵ����Ϊ1200ʹ·���������ǽת������
                            msg.InfoClass = (byte)IMLibrary.Class.ProtocolFileTransmit.BeginTransmit;
                            msg.SendID = this.serverSelfID;
                            msg.RecID = this.serverOppositeID;
                            this.sendData(msg);
                        }
                        else if (this.getFileProxyID != null)//����ǽ��շ��򴥷������ת����ID��֮�Է�
                            this.getFileProxyID(this, this.serverSelfID);
                    }
                    break;
                case (byte)IMLibrary.Class.ProtocolFileTransmit.FileTransmit://����ļ���������
                    {
                        //Calculate.WirteLog("�����ļ����Է�");
                        this.sendFile((int)msg.pSendPos);//�����ļ����Է�
                    }
                    break;
                case (byte)IMLibrary.Class.ProtocolFileTransmit.GetFileBlock :// ��öԷ�������ļ����ݰ�
                    {
                        //Calculate.WirteLog("�յ��ļ�����");
                        this.ReceivedFileBlock(msg);//�Է������ļ����ݹ���,�������ݵ��ļ�
                    }
                    break;
                case (byte)IMLibrary.Class.ProtocolFileTransmit.BeginTransmit://�����Ѿ��������Է�Ҫ��ʼ�����ļ�
                    {
                        this.serverOppositeID = msg.SendID;//��öԷ�ID
                        if (netClass == IMLibrary.Class.NatClass.Tcp)//�����TCPͨ��
                        {
                            this.netClass = IMLibrary.Class.NetCommunicationClass.TCP;//����TCPЭ�鴫���ļ�
                        }
                        else
                        {
                            this.netClass = IMLibrary.Class.NetCommunicationClass.WanNoProxyUDP;//����UDPЭ�鴫��
                        }

                        if (this.fileTransmitConnected != null)//����ͨ�ųɹ��¼������˳�ͨ�Ų���
                            this.fileTransmitConnected(this, this.netClass);

                        if (!this.IsSendState)//����ļ���û�п�ʼ���ͣ�����
                            this.sendRequestGetFileData();//�����ļ����Է�
                        //Calculate.WirteLog("�����Ѿ��������Է�Ҫ��ʼ�����ļ�");
                    }
                    break;
                case (byte)IMLibrary.Class.ProtocolFileTransmit.FileTranstmitOver ://�ļ��������
                    {
                        this.onFileTransmitted();
                    }
                    break;

                case (byte)IMLibrary.Class.ProtocolFileTransmit.HandshakeLAN://�յ��Է�������UDP��������
                    {
                        this._OppositeUserInfo.LocalIP = Ip;//�������öԷ��ľ�����IP
                        this.OppositeUDPPort = Port;//�������öԷ��ľ�����UDP�˿�
                        msg.InfoClass =(byte)IMLibrary.Class.ProtocolFileTransmit.IsOppositeRecSelfLanUDPData;//���߶Է��յ�����������Ϣ
                        this.sockUDP1.Send(this._OppositeUserInfo.LocalIP, this.OppositeUDPPort, msg.getBytes());
                        //Calculate.WirteLog(this._IsSend.ToString()+ "�յ��Է�������UDP��������:"+ Ip.ToString() +":"+ Port.ToString());
                    }
                    break;
                case (byte)IMLibrary.Class.ProtocolFileTransmit.IsOppositeRecSelfLanUDPData://�Է��յ��Լ����͵ľ�����UDP��������
                    {
                        this.netClass = IMLibrary.Class.NetCommunicationClass.LanUDP;//��ʶ��Է�����������ͨ�ųɹ�
                       if (this._IsSend)//����Ƿ����ļ���һ�����ҶԷ���֮�յ��Լ����������ݣ���ͨ��ͨ����ͨ
                       {
                           //this._mtu = 1400;//�����������ļ�ʱ����MTUֵ����Ϊ5120��5k������ٶ�
                           msg.InfoClass = (byte)IMLibrary.Class.ProtocolFileTransmit.BeginTransmit;
                           msg.SendID = 0;
                           this.sendData(msg);//���߶Է���ʼ�����ļ�
                       }
                       //Calculate.WirteLog(Ip.ToString() + ":" + Port.ToString() + "�Է��յ��Լ����͵ľ�����UDP��������" + this._IsSend.ToString());
                    }
                    break;

                case (byte)IMLibrary.Class.ProtocolFileTransmit.HandshakeWAN ://�յ��Է�������UDP��������
                    {
                        this._OppositeUserInfo.IP = Ip;//�������öԷ��Ĺ�����IP
                        this.OppositeUDPPort = Port;//�������öԷ��Ĺ�����UDP�˿�
                        msg.InfoClass = (byte)IMLibrary.Class.ProtocolFileTransmit.IsOppositeRecSelfWanUDPData ;//���߶Է��յ�����������Ϣ
                        this.sockUDP1.Send(this._OppositeUserInfo.IP, this.OppositeUDPPort, msg.getBytes());
                        //Calculate.WirteLog(this._IsSend.ToString()+ "�յ��Է�������UDP��������:"+ Ip.ToString() +":"+ Port.ToString());
                    }
                    break;
                case (byte)IMLibrary.Class.ProtocolFileTransmit.IsOppositeRecSelfWanUDPData://�Է��յ��Լ����͵ľ�����UDP��������
                    {
                        this.netClass = IMLibrary.Class.NetCommunicationClass.WanNoProxyUDP;//��ʶ��Է�����������ֱ��ͨ�ųɹ�
                        if (this._IsSend)//����Ƿ����ļ���һ�����ҶԷ���֮�յ��Լ����������ݣ���ͨ��ͨ����ͨ
                        {
                            //this._mtu = 1200;//�����������ļ�ʱ����MTUֵ����Ϊ1200��1k�ٶ�
                            msg.InfoClass = (byte)IMLibrary.Class.ProtocolFileTransmit.BeginTransmit;
                            msg.SendID = 0;
                            this.sendData(msg);//���߶Է���ʼ�����ļ�
                        }
                        //Calculate.WirteLog(Ip.ToString() + ":" + Port.ToString() + "�Է��յ��Լ����͵ľ�����UDP��������" + this._IsSend.ToString());
                    }
                    break;

                case (byte)IMLibrary.Class.ProtocolFileTransmit.GetUDPWANInfo://��÷��������ص��ļ������׽��ֹ�����UDP�˿�
                    {
                        this.selfUDPPort=msg.SendID;//�������öԷ��Ĺ�����UDP�˿�
                        if (!this.IsGetWanUDP && this.fileTransmitGetUDPPort != null)
                        {
                            this.IsGetWanUDP = true;//��ʶ�Ѿ�������WAN UDP�˿ڻ�ȡ�¼�
                            this.fileTransmitGetUDPPort(this, this.selfUDPPort, true);
                        }
                        //Calculate.WirteLog(this._IsSend.ToString() + "��÷��������ص��ļ������׽��ֹ�����UDP�˿�:" + this.selfUDPPort);
                    }
                    break;

            }
        }
 private void asyncTCPClient1_OnDisconnected(object sender, IMLibrary.Net.SockEventArgs e)
 {
     //IMLibrary.Calculate.WirteLog("��������Ͽ�����");
 }
 private void asyncTCPClient1_OnConnected(object sender,  IMLibrary.Net.SockEventArgs  e)
 {
     //IMLibrary.Calculate.WirteLog("������");
     IMLibrary.Class.msgFile msg = new IMLibrary.Class.msgFile((byte)IMLibrary.Class.ProtocolFileTransmit.GetFileTransmitProxyID, -1, -1, 0, new byte[1]);
     this.asyncTCPClient1.SendData(msg.getBytes());//�������������ת����ID��
 }
示例#9
0
 /// <summary>
 /// 从组织机构集中删除一个分组 
 /// </summary>
 /// <param name="d">要删除的分组</param>
 public void Romove(IMLibrary.Class.Department d)
 {
     base.InnerList.Remove(d);
 }
示例#10
0
 /// <summary>
 /// 向组织机构集中添加一个分组 
 /// </summary>
 /// <param name="d">要添加的分组</param>
 public void add(IMLibrary.Class.Department d)
 {
     base.InnerList.Add(d);
 }
示例#11
0
 private void myTcp_OnClose(object sender, IMLibrary.Net.SockEventArgs e)
 {
     CloseClientSocket(sender as MyTcp);//�ر�SOCKET
 }
示例#12
0
 /// <summary>
 /// ���ӿͻ��������ﵽ�����õ�����ֵ
 /// </summary>
 private void MaxConnectCountArrival(object sender, IMLibrary.Net.SockEventArgs e)
 {
     if (OnMaxConnectCountArrival != null)
         OnMaxConnectCountArrival(sender,e);
 }
示例#13
0
 /// <summary>
 /// �쳣����
 /// </summary>
 private void Error(object sender, IMLibrary.Net.SockEventArgs e)
 {
     if (OnError != null)
         OnError(sender ,e);
 }
示例#14
0
 /// <summary>
 /// ���ն���������
 /// </summary>
 private void DataArrival(object sender, IMLibrary.Net.SockEventArgs e)
 {
     if (OnDataArrival != null)
         OnDataArrival(sender ,e);
 }
示例#15
0
 private void TCPClient1_OnConnected(object sender, IMLibrary.Net.SockEventArgs e)
 {
     //IMLibrary.Calculate.WirteLog("已连接");
     IMLibrary.Class.msgAV msg = new IMLibrary.Class.msgAV();
     msg.InfoClass = (byte)IMLibrary.Class.ProtocolAVTransmit.GetAVTransmitProxyID;
     this.TCPClient1.SendData(msg.getBytes());//向服务器申请中转服务ID号
 }
示例#16
0
        /// <summary>
        /// ���ô����ļ�����
        /// </summary>
        /// <param name="isSend">��ʶ�ļ��Ƿ��ͻ��ǽ���</param>
        /// <param name="FullFileName">��������ļ���������Ҫ���ŵ��ļ�·��</param>
        /// <param name="FileName">�ļ���</param>
        /// <param name="FileLen">�ļ�����</param>
        /// <param name="fileExtension">�ļ���չ��</param>
        /// <param name="FileMD5Value">�ļ�MD5ֵ</param>
        /// <param name="ServerIP">������IP��ַ</param>
        /// <param name="ServerUDPPort">������UDP����˿�</param>
        /// <param name="ServerTCPPort">������TCP����˿�</param>
        /// <param name="selfUserInfo">�Լ��������û���Ϣ</param>
        /// <param name="OppositeUserInfo">�Է��������û���Ϣ</param>
        public void SetParameter(bool IsSend, string FullFileName, string FileName, int FileLen, string fileExtension, string FileMD5Value, System.Net.IPAddress ServerIP
                 , int ServerUDPPort, int ServerTCPPort, IMLibrary.Class.UserInfo selfUserInfo, IMLibrary.Class.UserInfo OppositeUserInfo)
        {
            //�ļ�����ǰ����˫�����ӵIJ������ú���
            this._IsSend = IsSend;
            this._serverIp = ServerIP;//��ȡ������IP��ַ
            this._serverUDPPort = ServerUDPPort;//��ȡ�ļ�������UDP����˿�
            this._serverTCPPort = ServerTCPPort;//��ȡ�ļ�������TCP����˿�
            this.Extension = fileExtension;//��ȡ�ļ���չ��
            this._FileLen = FileLen;//��ȡ�ļ�����
            this._fileName = FileName;//�ļ�����
            this.FileMD5Value = FileMD5Value;//��ȡ�ļ���MD5ֵ
            this._selfUserInfo = selfUserInfo;//��ȡ�Լ��������û���Ϣ
            this._OppositeUserInfo = OppositeUserInfo;//��ȡ�Է��������û���Ϣ

            this.FileLenStr = IMLibrary.Class.Calculate.GetSizeStr(FileLen);//����ļ��ߴ��ַ���

            this.readFileCount = FileLen / this.maxReadWriteFileBlock;//����ļ���д����

            if (FileLen % this.maxReadWriteFileBlock != 0)
                this.readFileCount++;//�����д�ļ����࣬�����д������1

            if (_IsSend)//������ļ�������
                this._fullFileName  = FullFileName;//���ļ��ľ���·��
        }
示例#17
0
文件: video.cs 项目: iraychen/ourmsg
 /// <summary>
 /// 设置对方视频位图信息,构造解码器
 /// </summary>
 /// <param name="bitmapinfo"></param>
 public void SetVideoBitmapinfo(IMLibrary.AV.BITMAPINFO bitmapinfo)
 {
     if (AVC != null)
         AVC.SetRemoteBITMAPINFOHEADER(bitmapinfo);
 }
示例#18
0
 private void asyncTCPClient1_OnDataArrival(object sender, IMLibrary.Net.SockEventArgs e)
 {
     //if (e.Data.Length < 10) return;
     IMLibrary.Class.msgFile msg = new IMLibrary.Class.msgFile(e.Data);
     this.DataArrival(msg,IMLibrary.Class.NatClass.Tcp ,null,0);
 }
示例#19
0
 public void add(IMLibrary.MyPicture tempGif)
 {
     base.InnerList.Add(tempGif);
 }
示例#20
0
 private void asyncTCPClient1_OnError(object sender, IMLibrary.Net.SockEventArgs e)
 {
     //IMLibrary.Calculate.WirteLog("�ļ��������"+ e.ErrorCode + e.ErrorMessage );
 }
示例#21
0
 public void Romove(IMLibrary.MyPicture tempGif)
 {
     base.InnerList.Remove(tempGif);
 }
示例#22
0
        //���Է������ļ����ݿ����
        /// <summary>
        /// ����Է������ļ����ݿ�
        /// </summary>
        private void ReceivedFileBlock(IMLibrary.Class.msgFile msg)
        {
            if (msg.pSendPos > this.currGetPos)//������͹��������ݴ��ڵ�ǰ��õ�����
            {
                if (this.IsReadWriteFile(this.currGetPos))
                {
                    //�����Ƕ�һ���ļ����ڴ����
                    if (this.currReadCount + 1 == this.readFileCount)//��������һ�ζ�д�ļ����������ļ�β����ȫ�����뵽�ڴ�
                        FileBlock = new byte[this._FileLen - this.currReadCount * this.maxReadWriteFileBlock];
                    else
                        FileBlock = new byte[this.maxReadWriteFileBlock];

                    this.currReadCount++;//�ļ�����������1
                }

                int offSet = this.currGetPos % this.maxReadWriteFileBlock;// ���Ҫ��д�ڴ�ľ���λ��
                Buffer.BlockCopy(msg.FileBlock, 0, this.FileBlock, offSet, msg.FileBlock.Length);//���䱣����Buffer�ֽ�����

                this.currGetPos = (int)msg.pSendPos;

                if (this.fileTransmitting != null)//�����յ������ļ������¼�
                    this.fileTransmitting(this, new fileTransmitEvnetArgs(this._IsSend, this._fullFileName, this._fileName, "", this._FileLen, this.currGetPos, this.FileMD5Value));

                if (this.IsReadWriteFile(this.currGetPos) || this.currGetPos == this._FileLen)
                {
                    ////////////////////////�ļ�����
                    FileStream fw = new FileStream(this._fullFileName, FileMode.Append, FileAccess.Write, FileShare.Read);
                    //fw.Seek(fw.l, SeekOrigin.Begin);//�ϴη��͵�λ��
                    fw.Write(this.FileBlock, 0, this.FileBlock.Length);
                    //�����д�����������첽��ʽ
                    //fw.BeginRead(myData.Buffer, 0, assignSize, new AsyncCallback(AsyncRead), myData);
                    ///ʵ�ֶ��߳�ͬʱ��д�ļ�
                    fw.Close();
                    fw.Dispose();
                    ///////////////////////////
                }

                if (this.currGetPos == this._FileLen)//����ļ�������ɣ�������������¼�
                {
                    msg.InfoClass = (byte)IMLibrary.Class.ProtocolFileTransmit.FileTranstmitOver;
                    msg.SendID = this.serverSelfID;
                    msg.RecID = this.serverOppositeID;
                    this.sendData(msg);//���߶Է��ļ��������
                    onFileTransmitted();//�����ļ���������¼�
                    //return;//�ļ�����
                }

                this.sendRequestGetFileData();//���۵�ǰ��ö������ݣ���Ҫ��Է�������һ���ݰ�
            }
        }
示例#23
0
 /// <summary>
 /// 设置传输音视频参数
 /// </summary>
 /// <param name="ServerIP">服务器IP地址</param>
 /// <param name="ServerUDPPort">服务器UDP服务端口</param>
 /// <param name="ServerTCPPort">服务器TCP服务端口</param>
 /// <param name="selfUserInfo">自己的在线用户信息</param>
 /// <param name="OppositeUserInfo">对方的在线用户信息</param>
 public void SetParameter(System.Net.IPAddress ServerIP, int ServerUDPPort, int ServerTCPPort, IMLibrary.Class.UserInfo selfUserInfo, IMLibrary.Class.UserInfo OppositeUserInfo)
 {
     //音视频传输前建立双方连接的参数设置函数
     this._serverIp = ServerIP;//获取服务器IP地址
     this._serverUDPPort = ServerUDPPort;//获取文件服务器UDP服务端口
     this._serverTCPPort = ServerTCPPort;//获取文件服务器TCP服务端口
     this._selfUserInfo = selfUserInfo;//获取自己的在线用户信息
     this._OppositeUserInfo = OppositeUserInfo;//获取对方的在线用户信息
 }
示例#24
0
 /// <summary>
 /// UDP���ݵ����¼�
 /// </summary>
 /// <param name="e">UDP���ݲ���</param>
 private void sockUDP1_DataArrival(object sender,IMLibrary.Net.SockEventArgs  e)
 {
     //if (e.Data.Length < 10) return;
     IMLibrary.Class.msgFile msg = new IMLibrary.Class.msgFile(e.Data);
     this.DataArrival(msg,IMLibrary.Class.NatClass.FullCone, e.IP,e.Port);
 }
示例#25
0
        private void DataArrival(IMLibrary.Class.msgAV msg, IMLibrary.Class.NatClass netClass, System.Net.IPAddress Ip, int Port)
        {
            switch (msg.InfoClass)
            {
                case (byte)IMLibrary.Class.ProtocolAVTransmit.GetVideoData:// 获得对方传输的视频数据包
                    {
                        this.OnVideoData(msg.DataBlock);
                        //Calculate.WirteLog("收到v"+ msg.DataBlock.Length.ToString());
                        //this.ReceivedFileBlock(msg);//对方发送文件数据过来,保存数据到文件
                    }
                    break;
                case (byte)IMLibrary.Class.ProtocolAVTransmit.GetAudioData:// 获得对方传输的音频数据包
                    {
                        this.OnAudioData(msg.DataBlock);
                        //Calculate.WirteLog("收到a"+ msg.DataBlock.Length.ToString());
                        //this.ReceivedFileBlock(msg);//对方发送文件数据过来,保存数据到文件
                    }
                    break;
                case (byte)IMLibrary.Class.ProtocolAVTransmit.GetBITMAPINFOHEADER://获得对方视频图像头信息
                    {
                        this.OnGetBITMAPINFOHEADER(msg.DataBlock);
                        break;
                    }
                case (byte)IMLibrary.Class.ProtocolAVTransmit.GetAVTransmitProxyID://获得自己从服务器上获得中转服务ID
                    {
                        this.serverSelfID = msg.SendID;
                        if (this.serverOppositeID != -1)//如果已经获得对方中转服务ID,则告诉对方开始视频传输
                        {
                            this.netClass = IMLibrary.Class.NetCommunicationClass.TCP;//采用TCP协议传输文件
                            msg.InfoClass = (byte)IMLibrary.Class.ProtocolAVTransmit.BeginTransmit;
                            msg.SendID = this.serverSelfID;
                            msg.RecID = this.serverOppositeID;
                            this.sendData(msg);
                        }
                        else if (this.AVGetProxyID != null)//如果对方中转服务ID没有获得,则产生事件通知对方自己的ID//如果是接收方则触发获得中转服务ID
                            this.AVGetProxyID(this, this.serverSelfID);
                    }
                    break;

                case (byte)IMLibrary.Class.ProtocolAVTransmit.BeginTransmit://连接已经建立,对方要求开始接收文件
                    {
                        this.serverOppositeID = msg.SendID;//获得对方ID
                        if (netClass == IMLibrary.Class.NatClass.Tcp)//如果是TCP通信
                        {
                            this.netClass = IMLibrary.Class.NetCommunicationClass.TCP;//采用TCP协议传输文件
                        }
                        else
                        {
                            this.netClass = IMLibrary.Class.NetCommunicationClass.WanNoProxyUDP;//采用UDP协议传输
                        }
                        if (this.AVConnected != null)//触发通信成功事件,并退出通信测试
                            this.AVConnected(this, this.netClass);

                        //通信已经建立,开始传输数据
                        //Calculate.WirteLog("连接已经建立");
                    }
                    break;

                case (byte)IMLibrary.Class.ProtocolAVTransmit.HandshakeLAN://收到对方局域网UDP握手数据
                    {
                        this._OppositeUserInfo.LocalIP = Ip;//重新设置对方的局域网IP
                        this.OppositeUDPPort = Port;//重新设置对方的局域网UDP端口
                        msg.InfoClass =(byte)IMLibrary.Class.ProtocolAVTransmit.IsOppositeRecSelfLanUDPData;//告诉对方收到握手数据信息
                        this.sockUDP1.Send(this._OppositeUserInfo.LocalIP, this.OppositeUDPPort, msg.getBytes());
                        //Calculate.WirteLog(this._IsSend.ToString()+ "收到对方局域网UDP握手数据:"+ Ip.ToString() +":"+ Port.ToString());
                    }
                    break;
                case (byte)IMLibrary.Class.ProtocolAVTransmit.IsOppositeRecSelfLanUDPData://对方收到自己发送的局域网UDP握手数据
                    {
                        this.netClass = IMLibrary.Class.NetCommunicationClass.LanUDP;//标识与对方建立局域网通信成功
                        msg.InfoClass = (byte)IMLibrary.Class.ProtocolAVTransmit.BeginTransmit;
                       msg.SendID = 0;
                       this.sendData(msg);//告诉对方开始发送文件
                       //Lan通信已经建立,开始传输数据
                    }
                    break;

                case (byte)IMLibrary.Class.ProtocolAVTransmit.HandshakeWAN://收到对方广域网UDP握手数据
                    {
                        this._OppositeUserInfo.IP = Ip;//重新设置对方的广域网IP
                        this.OppositeUDPPort = Port;//重新设置对方的广域网UDP端口
                        msg.InfoClass = (byte)IMLibrary.Class.ProtocolAVTransmit.IsOppositeRecSelfWanUDPData;//告诉对方收到握手数据信息
                        this.sockUDP1.Send(this._OppositeUserInfo.IP, this.OppositeUDPPort, msg.getBytes());
                        //Calculate.WirteLog(this._IsSend.ToString()+ "收到对方广域网UDP握手数据:"+ Ip.ToString() +":"+ Port.ToString());
                    }
                    break;
                case (byte)IMLibrary.Class.ProtocolAVTransmit.IsOppositeRecSelfWanUDPData://对方收到自己发送的局域网UDP握手数据
                    {
                        this.netClass = IMLibrary.Class.NetCommunicationClass.WanNoProxyUDP;//标识与对方建立广域网直接通信成功

                        msg.InfoClass = (byte)IMLibrary.Class.ProtocolAVTransmit.BeginTransmit;
                            msg.SendID = 0;
                            this.sendData(msg);//告诉对方开始视频
                        //Wan通信已经建立,开始传输数据
                    }
                    break;

                case (byte)IMLibrary.Class.ProtocolAVTransmit.GetUDPWANInfo://获得服务器返回的文件传输套接字广域网UDP端口
                    {
                        this.selfUDPPort=msg.SendID;//重新设置对方的广域网UDP端口
                        if (!this.IsGetWanUDP && this.AVGetUDPPort != null)//如果自己还未与对方套接字建立通信则触发获得端口事件
                        {
                            this.IsGetWanUDP = true;
                            this.AVGetUDPPort(this, this.selfUDPPort, true);
                        }
                    }
                    break;
            }
        }
示例#26
0
 private void aVcommunication1_AVConnected(object sender, IMLibrary.Class.NetCommunicationClass netCommuctionClass)
 {
     if (this.AVConnected != null)
         this.AVConnected(sender, netCommuctionClass);
 }
示例#27
0
 /// <summary>
 /// �����µ�Socketͨ����������
 /// </summary>
 private void AcceptClientSocket(object sender, IMLibrary.Net.SockEventArgs e)
 {
     if (OnAcceptClientSocket != null)
         OnAcceptClientSocket(sender, e);
 }