Ejemplo n.º 1
0
        /// <summary>
        /// 实例化
        /// </summary>
        /// <param name="endPoint">此处endPoint是服务器的,用来打洞</param>
        /// <param name="af"></param>
        public AudioUtil(MyEndPoint endPoint, AudioForm af)
        {

            this.af = af;
            socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

            this.endPoint = new IPEndPoint(IPAddress.Parse(endPoint.Address), endPoint.Port);

        }
Ejemplo n.º 2
0
        /// <summary>
        /// 处理语音请求消息
        /// </summary>
        /// <param name="mesg"></param>
        private void ReceiveAudioMessage(Message mesg)
        {
            ///已经语音,不能再跟其他人语音
            DataUtil.FriendMessageTabItems[(mesg.from as Member).id].audioMenu.IsEnabled = false;

            AudioMessage am = mesg as AudioMessage;
            AudioForm af = new AudioForm(am, false);

            ///结束语音,enable语音按钮,能继续跟其他人语音
            af.Closed += new EventHandler((obj, args) =>
            {
                DataUtil.FriendMessageTabItems[(mesg.from as Member).id].audioMenu.IsEnabled = true;
            }
            );
            af.Show();


        }
Ejemplo n.º 3
0
        void MyMenu_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {

            if (this.baseRole is Member)
            {
                Member member = this.baseRole as Member;
                if (member.status == MemberStatus.Offline)
                {
                    return;
                }

                switch(messageType)
                {
                    case MessageType.File:
                        {
                            OpenFileDialog ofd = new OpenFileDialog();
                            ofd.RestoreDirectory = true;
                            ofd.ShowDialog();

                            FileMessage fm = new FileMessage();
                            fm.from = DataUtil.Member;
                            fm.to = this.baseRole;

                            fm.Path = ofd.FileName;
                            if (!File.Exists(fm.Path))
                                return;
                            fm.FileName = ofd.SafeFileName;
                            fm.Size = ofd.OpenFile().Length;
                            fm.sendTime = DateTime.Now;
                            fm.Guid = Guid.NewGuid().ToString();


                            DataUtil.Transfer.SendFile(fm);
                            break;
                        }
                    case MessageType.Audio:
                        {

                            this.IsEnabled = false;
                            AudioMessage am = new AudioMessage();
                            am.from = DataUtil.Member;
                            am.to = this.baseRole;

                            DataUtil.Client.SendMesg(am);
                            AudioForm af = new AudioForm(am, true);
                            
                            af.Show();
                            af.Closed += new EventHandler((obj, args) =>
                                {
                                    this.IsEnabled = true;
                                });
                            break;
                        }
            }

            }
        }
Ejemplo n.º 4
0
        public FromAudioUtil(MyEndPoint iPEndPoint,AudioForm af=null)
            : base(iPEndPoint,af)
        {

        }
Ejemplo n.º 5
0
        public ToAudioUtil(MyEndPoint iPEndPoint,AudioForm af)
            : base(iPEndPoint,af)
        {

        }