Ejemplo n.º 1
0
        /// <summary>
        /// A Message is received. Now check if its from a Jid we are looking for and
        /// raise the event in this case.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="msg"></param>
        private void m_connection_OnMessage(object sender, Message msg)
        {
            if (msg == null)
                return;

            lock (m_grabbing)
            {
                IDictionaryEnumerator myEnum = m_grabbing.GetEnumerator();

                while(myEnum.MoveNext())
                {
                    TrackerData t = myEnum.Value as TrackerData;
                    if (t.comparer.Compare(new Jid((string)myEnum.Key), msg.From) == 0)
                    {
                        // Execute the callback
                        t.cb(this, msg, t.data);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void ftpClient_PushFileSucceedEvent(FTPClient sender, string args)
        {
            FileTransfersItem item =sender.sendFileManager.Tag as FileTransfersItem;
            Util.SendFileManagerList.Remove(sender.sendFileManager.MD5);
            if (item != null)
            {
                BeginInvoke(new MethodInvoker(delegate()
                {
                    CSS.IM.XMPP.protocol.client.Message fmsg = new CSS.IM.XMPP.protocol.client.Message();
                    fmsg.Type = MessageType.chat;
                    fmsg.To = TO_Jid;
                    fmsg.SetTag("m_type", 8);
                    fmsg.SetTag("MD5", args);
                    fmsg.SetTag("FileName", System.IO.Path.GetFileName(sender.sendFileManager.FileName));
                    fmsg.SetTag("Length", sender.sendFileManager.Length);
                    fmsg.SetTag("Path", XmppConn.MyJID.User);
                    fmsg.From = XmppConn.MyJID;
                    fmsg.Body = "离线文件" + System.IO.Path.GetFileName(sender.sendFileManager.FileName);
                    XmppConn.Send(fmsg);

                    fileTansfersContainer.RemoveItem(item);
                    item.Dispose();
                }));
            }
            this.AppendSystemRtf(string.Format("离线文件 {0} 发送完成。", sender.sendFileManager.Name));
        }
Ejemplo n.º 3
0
        public void IncomingMessage(CSS.IM.XMPP.protocol.client.Message msg)
        {
            try
            {
                if (msg.Type == MessageType.error)
                {
                    MsgBox.Show(this, "CSS&IM", "离线消息没有发送成功!", MessageBoxButtons.OK);
                    btn_close_Click(null, null);
                    //btn_close_Click(null, null);
                    //if (msg.To.Bare == _connection.MyJID.Bare && msg.From.Bare == to_Jid.Bare)
                    //{
                    //    MsgBox.Show(this, "CSS&IM", "在服务器中没有找到该用户,无法发送消息!", MessageBoxButtons.OK);
                    //    btn_close_Click(null, null);
                    //}
                }

                int m_type = msg.GetTagInt("m_type");

                switch (m_type)
                {
                    case 0://正常消息
                        //RTBRecord.AppendTextAsRtf(msg.From.User + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second + "\n", new Font(this.Font, FontStyle.Underline | FontStyle.Bold), CSS.IM.Library.ExtRichTextBox.RtfColor.Red, CSS.IM.Library.ExtRichTextBox.RtfColor.White);
                        CSS.IM.UI.Util.Win32.FlashWindow(this.Handle, true);//闪烁

                        #region 显示我自己发送的消息
                        CSS.IM.XMPP.protocol.client.Message top_msg = new XMPP.protocol.client.Message();
                        top_msg.SetTag("FName", this.Font.Name);//获得字体名称
                        top_msg.SetTag("FSize", this.Font.Size);//字体大小
                        top_msg.SetTag("FBold", true);//是否粗体
                        top_msg.SetTag("FItalic", this.Font.Italic);//是否斜体
                        top_msg.SetTag("FStrikeout", this.Font.Strikeout);//是否删除线
                        top_msg.SetTag("FUnderline", true);//是否下划线

                        Color top_cl = Color.Red;//获取颜色
                        byte[] top_cby = BitConverter.GetBytes(top_cl.ToArgb());
                        top_msg.SetTag("CA", top_cby[0]);
                        top_msg.SetTag("CR", top_cby[1]);
                        top_msg.SetTag("CG", top_cby[2]);
                        top_msg.SetTag("CB", top_cby[3]);
                        top_msg.Body = (_NickName != "" ? _NickName : msg.From.User) + "(" + msg.From.User + "):" + DateTime.Now.ToString("HH:mm:ss");
                        top_msg.From = TO_Jid;
                        top_msg.To = TO_Jid;
                        RTBRecord_Show(top_msg, true);
                        #endregion

                        RTBRecord_Show(msg, false);

                        if (IsPlayMsg)
                        {
                            if (CSS.IM.UI.Util.Path.MsgSwitch)
                                CSS.IM.UI.Util.SoundPlayEx.MsgPlay(CSS.IM.UI.Util.Path.MsgPath);
                        }
                        break;
                    case 1://收到对方的请求要过行视频功能服务,初始化本地的视频
                        this.Invoke(AccepVideotInit, new object[] { msg });
                        break;
                    case 2://我发送视频请求后,对方告诉我视频初使化完成,进行自己本地的视频初使化
                        this.Invoke(ReturnAcceptVideoInit, new object[] { msg });
                        break;
                    case 3://对方给我发送视频请求,我初使化本地视频服务,告诉对方,对方也初使化视频服务了,我打开视频功能
                        this.Invoke(AcceptVideoOpen, new object[] { msg });
                        break;
                    case 4://去对方获取截图的功能
                        RemotBaseUDPPort = msg.GetTagInt("BPort");
                        RemotBaseUDPIP = IPAddress.Parse(msg.GetTag("BIP"));
                        bool isSend = msg.GetTagBool("isSend");

                        if (isSend)
                        {
                            CSS.IM.XMPP.protocol.client.Message fmsg = new CSS.IM.XMPP.protocol.client.Message();
                            fmsg.SetTag("m_type", 4);
                            fmsg.Type = MessageType.chat;
                            fmsg.To = TO_Jid;
                            fmsg.SetTag("BPort", ListenBasicUDPPort);
                            fmsg.SetTag("BIP", Program.LocalHostIP.ToString());
                            fmsg.SetTag("isSend", false);
                            XmppConn.Send(fmsg);
                        }

                        sendSelfImage();
                        break;
                    case 5://视频释放
                        if (RemotVideoUDPPort != -1)
                        {
                            //avForm.isBtn_hangup = true;
                            if (avForm != null && !avForm.IsDisposed)
                            {
                                avForm.isBtn_hangup = true;
                                avForm.AVClose();
                            }
                            if (ravForm != null && !ravForm.IsDisposed)
                            {
                                ravForm.isBtn_hangup = true;
                                ravForm.AVClose();
                            }
                        }
                        break;
                    case 6://传文件
                        RemotBaseUDPPort = msg.GetTagInt("BPort");
                        RemotBaseUDPIP = IPAddress.Parse(msg.GetTag("BIP"));

                        CSS.IM.XMPP.protocol.client.Message lmsg = new CSS.IM.XMPP.protocol.client.Message();
                        lmsg.SetTag("m_type", 7);//告诉对方要发送文件啦
                        lmsg.Type = MessageType.chat;
                        lmsg.To = TO_Jid;
                        lmsg.SetTag("BPort", udpReceiveFile.Port);
                        lmsg.SetTag("BIP", Program.LocalHostIP.ToString());
                        lmsg.SetTag("isSend", false);
                        lmsg.SetTag("File", msg.GetTag("File").ToString());
                        XmppConn.Send(lmsg);
                        break;
                    case 7:
                        RemotBaseUDPPort = msg.GetTagInt("BPort");
                        RemotBaseUDPIP = IPAddress.Parse(msg.GetTag("BIP"));
                        this.Invoke(FileSendInitEvent, msg.GetTag("File").ToString());
                        break;
                    case 8://ftp离线文件
                        this.Invoke(GetFtpFileEvent, new object[] { msg});
                        break;
                    case 9://对方拒绝接收主线文件
                        this.AppendSystemRtf("对方"+msg.Body);
                        break;
                    case 10://对方接收离线文件
                        //DownloadImage
                        try
                        {
                            FTPClient ftpClient = new FTPClient(Util.ServerAddress, Util.ftpPath, Util.ftpUser, Util.ftpPswd, Util.ftpPort);
                            ftpClient.FtpPath=msg.GetTag("Path");
                            DownloadImage downloadImage = new DownloadImage();
                            downloadImage.ftpClient = ftpClient;
                            downloadImage.remoteImageName = msg.GetTag("FileName");
                            downloadImage.parent = this;
                            Thread getFileThread = new Thread(downloadImage.Download);
                            getFileThread.Start();
                        }
                        catch (Exception)
                        {

                        }
                        break;
                    case 11://接收到red的视频请求
                        this.Invoke(Red5AccpetEvent, new object[] { msg });
                        break;
                    case 12://接收到red的视频请求
                        this.Invoke(Red5RefuseEvent, new object[] { msg });
                        break;
                    case 13:
                        //red5MsgSend_FormClosing
                        if (red5MsgReceive != null || !red5MsgReceive.IsDisposed)
                        {
                            red5MsgReceive.Close();
                            red5MsgReceive.Dispose();
                            red5MsgReceive = null;
                        }
                        this.AppendSystemRtf("对方" + msg.From.User + "关闭了视频通话");
                        break;
                    case 14:
                        //red5MsgReceive_FormClosing
                        if (red5MsgSend != null || !red5MsgSend.IsDisposed)
                        {
                            red5MsgSend.Close();
                            red5MsgSend.Dispose();
                            red5MsgSend = null;
                        }
                        this.AppendSystemRtf("对方" + msg.From.User + "关闭了视频通话");
                        break;

                }
            }
            catch (Exception)
            {

            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Decline a groupchat invitation
        /// </summary>
        /// <param name="to">the jid which invited us</param>
        /// <param name="room">to room to which we send the decline (this is normally the same room we were invited to)</param>
        /// <param name="reason">reason why we decline the invitation</param>
        public void Decline(Jid to, Jid room, string reason)
        {
            Message msg = new Message();
            msg.To = room;

            User user = new User();
            if (reason != null)
                user.Decline = new Decline(to, reason);
            else
                user.Decline = new Decline(to);

            msg.AddChild(user);

            m_connection.Send(msg);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// red5视频请求
        /// </summary>
        /// <param name="msg"></param>
        private void Red5AccpetMethod(XMPP.protocol.client.Message msg)
        {
            if (InvokeRequired)
            {
                this.Invoke(Red5AccpetEvent, new object[]{msg});
            }

            if (red5MsgReceive != null)
                if (!red5MsgReceive.IsDisposed)
                    return;

            DialogResult result=MsgBox.Show(this, "CSS&IM", "好友" + NickName + "向您发送视频请求,是否接受!", MessageBoxButtons.YesNo);

            if (result==DialogResult.Yes)
            {
                string serUrl = @"http://"+Program.ServerIP+":7070/redfire/video/redfire_2way.html?me={0}&you={1}&key={2}";
                red5MsgReceive = new Red5Msg();
                red5MsgReceive.FriendName = "正在与[" + msg.GetTag("me").ToString() + "]视频通话中";
                red5MsgReceive.FormClosing += new FormClosingEventHandler(red5MsgReceive_FormClosing);
                red5MsgReceive.Accept(string.Format(serUrl, msg.GetTag("you").ToString(), msg.GetTag("me").ToString(), msg.GetTag("key").ToString()));
                red5MsgReceive.Show();
                this.AppendSystemRtf("开始与" + msg.GetTag("me").ToString() + "进行视频通话");
            }
            else
            {
                CSS.IM.XMPP.protocol.client.Message emsg = new CSS.IM.XMPP.protocol.client.Message();
                emsg.Type = MessageType.chat;
                emsg.To = TO_Jid;
                emsg.SetTag("m_type", 12);
                emsg.SetTag("me", msg.GetTag("me").ToString());
                emsg.SetTag("you", msg.GetTag("you").ToString());
                emsg.SetTag("key", msg.GetTag("key").ToString());
                XmppConn.Send(emsg);
                this.AppendSystemRtf("拒绝了" + msg.GetTag("me").ToString() + "视频通话");
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 对方同意视频,并初使化视频后,本地也进行视频初使化
        /// </summary>
        /// <param name="msg"></param>
        void ReturnAcceptVideoInitMethod(XMPP.protocol.client.Message msg)
        {
            UserInfo user1;
            UserInfo user2;
            CSS.IM.XMPP.protocol.client.Message res_msg;
            RemotVideoUDPPort = msg.GetTagInt("UDPPort");
            RemotVideoUDPIP = IPAddress.Parse(msg.GetTag("UDPIP"));

            user1 = new UserInfo();
            user1.LocalIP = RemotVideoUDPIP;
            user1.LocalPort = RemotVideoUDPPort;

            avForm.SetRemoteAddress(user1, RemotVideoUDPPort);

            user2 = new UserInfo();
            user2.LocalIP = Program.LocalHostIP;
            user2.LocalPort = ListenBasicUDPPort;

            avForm.SetLocalAddress(user2);

            avForm.iniAV(CSS.IM.Library.AV.VideoSizeModel.W320_H240);

            res_msg = new CSS.IM.XMPP.protocol.client.Message();
            res_msg.Type = MessageType.chat;
            res_msg.To = TO_Jid;
            res_msg.SetTag("m_type", 3);
            XmppConn.Send(res_msg);//告诉对我准备好了

            if (avForm.callSoundPlayer != null)
                avForm.callSoundPlayer.Stop();
        }
Ejemplo n.º 7
0
        public void IncomingMessage(CSS.IM.XMPP.protocol.client.Message msg)
        {
            try
            {
                if (msg.Type == MessageType.error)
                {
                    MsgBox.Show(this, "CSS&IM", "离线消息没有发送成功!", MessageBoxButtons.OK);
                    btn_close_Click(null, null);
                    //btn_close_Click(null, null);
                    //if (msg.To.Bare == _connection.MyJID.Bare && msg.From.Bare == to_Jid.Bare)
                    //{
                    //    MsgBox.Show(this, "CSS&IM", "在服务器中没有找到该用户,无法发送消息!", MessageBoxButtons.OK);
                    //    btn_close_Click(null, null);
                    //}
                }

                int m_type = msg.GetTagInt("m_type");

                switch (m_type)
                {
                    case 0://正常消息
                        //RTBRecord.AppendTextAsRtf(msg.From.User + " " + DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second + "\n", new Font(this.Font, FontStyle.Underline | FontStyle.Bold), CSS.IM.Library.ExtRichTextBox.RtfColor.Red, CSS.IM.Library.ExtRichTextBox.RtfColor.White);
                        Win32.FlashWindow(this.Handle, true);//闪烁
                        #region 显示我自己发送的消息
                        CSS.IM.XMPP.protocol.client.Message top_msg = new XMPP.protocol.client.Message();
                        top_msg.SetTag("FName", this.Font.Name);//获得字体名称
                        top_msg.SetTag("FSize", this.Font.Size);//字体大小
                        top_msg.SetTag("FBold", true);//是否粗体
                        top_msg.SetTag("FItalic", this.Font.Italic);//是否斜体
                        top_msg.SetTag("FStrikeout", this.Font.Strikeout);//是否删除线
                        top_msg.SetTag("FUnderline", true);//是否下划线

                        Color top_cl = Color.Red;//获取颜色
                        byte[] top_cby = BitConverter.GetBytes(top_cl.ToArgb());
                        top_msg.SetTag("CA", top_cby[0]);
                        top_msg.SetTag("CR", top_cby[1]);
                        top_msg.SetTag("CG", top_cby[2]);
                        top_msg.SetTag("CB", top_cby[3]);
                        top_msg.Body = msg.From.User + ":" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                        top_msg.From = to_Jid;
                        top_msg.To = to_Jid;
                        RTBRecord_Show(top_msg, true);
                        #endregion
                        RTBRecord_Show(msg, false);
                        if (IsPlayMsg)
                        {
                            if (CSS.IM.UI.Util.Path.MsgSwitch)
                                SoundPlayEx.MsgPlay(CSS.IM.UI.Util.Path.MsgPath);

                        }
                        break;
                    case 1://收到对方的请求要过行视频功能服务,初始化本地的视频
                        this.Invoke(AcceptInit, new object[] { msg });
                        break;
                    case 2://我发送视频请求后,对方告诉我视频初使化完成,进行自己本地的视频初使化
                        this.Invoke(ReturnAcceptInit, new object[] { msg });
                        break;
                    case 3://对方给我发送视频请求,我初使化本地视频服务,告诉对方,对方也初使化视频服务了,我打开视频功能
                        this.Invoke(AcceptOpen, new object[] { msg });
                        break;
                    case 4:
                        BaseRemotUDPPort = msg.GetTagInt("BPort");
                        BaseRemotUDPIP = IPAddress.Parse(msg.GetTag("BIP"));
                        bool isSend = msg.GetTagBool("isSend");
                        if (isSend)
                        {
                            CSS.IM.XMPP.protocol.client.Message fmsg = new CSS.IM.XMPP.protocol.client.Message();
                            fmsg.SetTag("m_type", 4);
                            fmsg.Type = MessageType.chat;
                            fmsg.To = to_Jid;
                            fmsg.SetTag("BPort", BaseLocalUDPPort);
                            fmsg.SetTag("BIP", Program.LocalHostIP.ToString());
                            fmsg.SetTag("isSend", false);
                            fmsg.Body = "falg";
                            _connection.Send(fmsg);
                        }
                        sendSelfImage();
                        break;
                    case 5://视频释放
                        if (VideoRemotUDPPort != -1)
                        {
                            //avForm.isBtn_hangup = true;

                            if (avForm != null && !avForm.IsDisposed)
                            {
                                avForm.isBtn_hangup = true;
                                avForm.AVClose();
                            }
                            if (ravForm != null && !ravForm.IsDisposed)
                            {
                                ravForm.isBtn_hangup = true;
                                ravForm.AVClose();
                            }
                        }
                        break;
                    case 6://传文件
                        BaseRemotUDPPort = msg.GetTagInt("BPort");
                        BaseRemotUDPIP = IPAddress.Parse(msg.GetTag("BIP"));

                        CSS.IM.XMPP.protocol.client.Message lmsg = new CSS.IM.XMPP.protocol.client.Message();
                        lmsg.SetTag("m_type", 7);//告诉对方要发送文件啦
                        lmsg.Type = MessageType.chat;
                        lmsg.To = to_Jid;
                        lmsg.SetTag("BPort", BaseLocalUDPPort);
                        lmsg.SetTag("BIP", Program.LocalHostIP.ToString());
                        lmsg.SetTag("isSend", false);
                        lmsg.SetTag("File", msg.GetTag("File").ToString());
                        lmsg.Body = "falg";
                        _connection.Send(lmsg);

                        break;
                    case 7:
                        BaseRemotUDPPort = msg.GetTagInt("BPort");
                        BaseRemotUDPIP = IPAddress.Parse(msg.GetTag("BIP"));
                        this.Invoke(FileSendInitEvent, msg.GetTag("File").ToString());
                        break;
                }
            }
            catch (Exception)
            {

            }
        }
Ejemplo n.º 8
0
        private void ItemSaveToButtonClick(object sender, EventArgs e)
        {
            FileTransfersItem item = sender as FileTransfersItem;
            RequestSendFileEventArgs rse = item.Tag as RequestSendFileEventArgs;
            if (item.Style == FileTransfersItemStyle.ReadyReceive)
            {
                FolderBrowserDialog fbd = new FolderBrowserDialog();
                if (fbd.ShowDialog() == DialogResult.OK)
                {
                    rse.Path = fbd.SelectedPath + "\\";
                    this.AppendSystemRtf(string.Format("同意接收文件 {0}。", rse.TraFransfersFileStart.FileName));
                    ControlTag tag = new ControlTag(
                         rse.TraFransfersFileStart.MD5,
                         rse.TraFransfersFileStart.FileName,
                         rse.RemoteIP);
                    item.Tag = tag;
                    item.Style = FileTransfersItemStyle.Cancel;
                    item.CancelButtonClick += new EventHandler(ItemCancelButtonClick2);
                    item.Start();
                    udpReceiveFile.AcceptReceive(rse);
                }
            }
            else
            {
                FolderBrowserDialog fbd = new FolderBrowserDialog();
                if (fbd.ShowDialog() == DialogResult.OK)
                {
                    rse.Path = fbd.SelectedPath + "\\";
                    this.AppendSystemRtf(string.Format("同意接收文件 {0}。", rse.ftpClient.fileTransfersItem.FileName));
                    ControlTag tag = new ControlTag(
                        rse.ftpClient.fileTransfersItem.Name,
                        rse.ftpClient.fileTransfersItem.FileName,
                        null);
                    tag.ftpClient = rse.ftpClient;
                    item.Tag = tag;
                    item.Style = FileTransfersItemStyle.Cancel;
                    DownloadFile downloadFile = new DownloadFile(this, rse.ftpClient);
                    downloadFile.receivePath = fbd.SelectedPath + "\\";
                    Thread pushThread = new Thread(downloadFile.GetFile);
                    pushThread.Start(rse.ftpClient.fileTransfersItem.Name);

                    CSS.IM.XMPP.protocol.client.Message fmsg = new CSS.IM.XMPP.protocol.client.Message();
                    fmsg.Type = MessageType.chat;
                    fmsg.To = TO_Jid;
                    fmsg.SetTag("m_type", 9);
                    fmsg.SetTag("FileName", rse.ftpClient.fileTransfersItem.FileName);
                    fmsg.From = XmppConn.MyJID;
                    fmsg.Body = "离线文件" + rse.ftpClient.fileTransfersItem.FileName + "开始接收。";
                    XmppConn.Send(fmsg);
                }
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 对方同意视频,并初使化视频后,本地也进行视频初使化
        /// </summary>
        /// <param name="msg"></param>
        void ReturnAcceptMethod(XMPP.protocol.client.Message msg)
        {
            UserInfo user1;
            UserInfo user2;
            CSS.IM.XMPP.protocol.client.Message res_msg;
            VideoRemotUDPPort = msg.GetTagInt("UDPPort");
            VideoRemotUDPIP = IPAddress.Parse(msg.GetTag("UDPIP"));

            user1 = new UserInfo();
            user1.LocalIP = VideoRemotUDPIP;
            user1.LocalPort = VideoRemotUDPPort;

            avForm.SetRemoteAddress(user1, VideoRemotUDPPort);

            user2 = new UserInfo();
            user2.LocalIP = Program.LocalHostIP;
            user2.LocalPort = int.Parse(LocalVideoUDPPort);

            avForm.SetLocalAddress(user2);

            avForm.iniAV(VideoSizeModel.W320_H240);

            res_msg = new CSS.IM.XMPP.protocol.client.Message();
            res_msg.Type = MessageType.chat;
            res_msg.To = to_Jid;
            res_msg.SetTag("m_type", 3);
            res_msg.Body = "falg";
            _connection.Send(res_msg);//告诉对我准备好了
        }
Ejemplo n.º 10
0
        private void sendFile(System.IO.FileInfo f)
        {
            CSS.IM.XMPP.protocol.client.Message fmsg = new CSS.IM.XMPP.protocol.client.Message();
            try
            {
                fmsg.SetTag("m_type", 6);//告诉对方要发送文件啦
                fmsg.Type = MessageType.chat;
                fmsg.To = to_Jid;
                fmsg.SetTag("BPort", BaseLocalUDPPort);
                fmsg.SetTag("BIP", Program.LocalHostIP.ToString());
                fmsg.SetTag("isSend", true);
                fmsg.SetTag("File", f.FullName.ToString());
                fmsg.Body = "falg";
                _connection.Send(fmsg);
                AppendSystemRtf("等待好友查看接收命令.");
            }
            catch (Exception)
            {

            }
        }
Ejemplo n.º 11
0
 /// <summary>
 /// 接收视频会话事件
 /// </summary>
 void ravForm_AgreeEvent()
 {
     CSS.IM.XMPP.protocol.client.Message res_msg = new CSS.IM.XMPP.protocol.client.Message();
     res_msg.Type = MessageType.chat;
     res_msg.To = to_Jid;
     res_msg.SetTag("m_type", 2);
     res_msg.SetTag("UDPPort", LocalVideoUDPPort);
     res_msg.SetTag("UDPIP", Program.LocalHostIP.ToString());
     res_msg.Body = "falg";
     if (_connection != null)
     {
         _connection.Send(res_msg);
     }
 }
Ejemplo n.º 12
0
        /// <summary>
        /// 发送视频通话事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_videoOpen_MouseClick(object sender, MouseEventArgs e)
        {
            if (!OnLine)
                return;

            try
            {
                if (avForm != null)
                    if (!avForm.IsDisposed)
                        return;

                if (ravForm != null)
                    if (!ravForm.IsDisposed)
                        return;

                avForm = new AVForm(to_Jid);
                avForm.AVCloseEvent += new AVForm.AVCloseDelegate(avForm_AVCloseEvent);
                LocalVideoUDPPort = avForm.aVcommunicationEx1.selfUDPPort.ToString();

                avForm.Show();
            }
            catch (Exception)
            {

            }

            CSS.IM.XMPP.protocol.client.Message msg = new CSS.IM.XMPP.protocol.client.Message();
            msg.Type = MessageType.chat;
            msg.To = to_Jid;
            msg.SetTag("m_type", 1);
            msg.SetTag("UDPPort", LocalVideoUDPPort);
            msg.SetTag("UDPIP", Program.LocalHostIP.ToString());
            msg.Body = "falg";
            _connection.Send(msg);
            //callSoundPlayer.PlayLooping();
            //SoundPlayEx.MsgPlay("call");
        }
Ejemplo n.º 13
0
        private void btn_send_Click(object sender, EventArgs e)
        {
            try
            {

                if (_connection == null)
                {
                    this.Close();
                }

                if (rtfSend.Text.Length > 1000)
                {
                    MsgBox.Show(this, "CSS&IM", "发送内容长度不能大于1000!", MessageBoxButtons.OK);
                    return;
                }

                if (rtfSend.GetImageInfo().Length == 0)
                {

                    if (!(rtfSend.Text.Trim().Length > 0))
                    {
                        return;
                    }
                }

                //RTBRecord.AppendTextAsRtf(_connection.Username + ":" + DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second + "\n", new Font(this.Font, FontStyle.Underline | FontStyle.Bold), CSS.IM.Library.ExtRichTextBox.RtfColor.Lime, CSS.IM.Library.ExtRichTextBox.RtfColor.White);
                //CSS.IM.XMPP.protocol.client.Message top_msg = new XMPP.protocol.client.Message();
                //top_msg.SetTag("FName", this.Font.Name);//获得字体名称
                //top_msg.SetTag("FSize", this.Font.Size);//字体大小
                //top_msg.SetTag("FBold", true);//是否粗体
                //top_msg.SetTag("FItalic", this.Font.Italic);//是否斜体
                //top_msg.SetTag("FStrikeout", this.Font.Strikeout);//是否删除线
                //top_msg.SetTag("FUnderline", true);//是否下划线

                //Color tcl = Color.Lime;//获取颜色
                //byte[] tcby = BitConverter.GetBytes(tcl.ToArgb());
                //top_msg.SetTag("CA", tcby[0]);
                //top_msg.SetTag("CR", tcby[1]);
                //top_msg.SetTag("CG", tcby[2]);
                //top_msg.SetTag("CB", tcby[3]);
                //top_msg.Body = _connection.Username + ":" + DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second ;
                //RTBRecord_Show(top_msg, true);

                CSS.IM.XMPP.protocol.client.Message msg = new CSS.IM.XMPP.protocol.client.Message();
                msg.Namespace = null;
                Font ft = rtfSend.Font;//获取字体
                msg.SetTag("FName", ft.Name);//获得字体名称
                msg.SetTag("FSize", ft.Size);//字体大小
                msg.SetTag("FBold", ft.Bold);//是否粗体
                msg.SetTag("FItalic", ft.Italic);//是否斜体
                msg.SetTag("FStrikeout", ft.Strikeout);//是否删除线
                msg.SetTag("FUnderline", ft.Underline);//是否下划线

                Color cl = rtfSend.ForeColor;//获取颜色
                byte[] cby = BitConverter.GetBytes(cl.ToArgb());
                msg.SetTag("CA", cby[0]);
                msg.SetTag("CR", cby[1]);
                msg.SetTag("CG", cby[2]);
                msg.SetTag("CB", cby[3]);

                msg.SetTag("m_type", 0);
                msg.Type = MessageType.groupchat;
                msg.To = new Jid(to_Jid.User, to_Jid.Server, null);
                msg.SetTag("face", rtfSend.GetImageInfo().ToString());
                msg.Body = rtfSend.Text;

                //保存要发送的图片;
                CSS.IM.Library.gifCollections tempGifs = this.rtfSend.GetExistGifs();
                foreach (MyPicture pic in tempGifs)
                {
                    PicQueue.add(pic);
                    this.rtfSend.gifs.Romove(pic);
                }

                rtfSend.ClearUndo();
                rtfSend.Clear();
                rtfSend.Text = String.Empty;

                try
                {
                    rtfSend.ImeMode = ImeMode.OnHalf;
                }
                catch (Exception)
                {
                }

                _connection.Send(msg);
                //RTBRecord_Show(msg, true);
            }
            catch
            {

            }
        }
Ejemplo n.º 14
0
        private void ItemCancelButtonClick2(object sender, EventArgs e)
        {
            FileTransfersItem item = sender as FileTransfersItem;
            if (item.Style == FileTransfersItemStyle.Cancel)
            {
                ControlTag tag = item.Tag as ControlTag;

                if (tag.ftpClient == null)
                {

                    udpReceiveFile.CancelReceive(tag.MD5, tag.RemoteIP);
                    fileTansfersContainer.RemoveItem(item);
                    item.Dispose();
                    this.AppendSystemRtf(string.Format("取消接收文件 {0}。", tag.FileName));
                }
                else
                {
                    tag.ftpClient.DisConnect(true);

                    CSS.IM.XMPP.protocol.client.Message fmsg = new CSS.IM.XMPP.protocol.client.Message();
                    fmsg.Type = MessageType.chat;
                    fmsg.To = TO_Jid;
                    fmsg.SetTag("m_type", 9);
                    fmsg.SetTag("FileName", item.FileName);
                    fmsg.From = XmppConn.MyJID;
                    fmsg.Body = "离线文件" + item.FileName + "拒绝接受。";
                    XmppConn.Send(fmsg);
                }
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 发送消息事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_send_Click(object sender, EventArgs e)
        {
            if (_connection == null)
            {
                MsgBox.Show(this, "CSS&IM", "网络连接异常,需要重新打开聊天会话!", MessageBoxButtons.OK);
                this.Close();
            }

            if (rtfSend.Text.Length>1000)
            {
                MsgBox.Show(this, "CSS&IM", "发送内容长度不能大于1000!", MessageBoxButtons.OK);
                return;
            }

            if (rtfSend.GetImageInfo().Length == 0)
            {

                if (!(rtfSend.Text.Trim().Length > 0))
                {
                    return;
                }
            }

            try
            {
                //RTBRecord.AppendTextAsRtf(_connection.Username + ":" + DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second + "\n", new Font(this.Font, FontStyle.Underline | FontStyle.Bold), CSS.IM.Library.ExtRichTextBox.RtfColor.Lime, CSS.IM.Library.ExtRichTextBox.RtfColor.White);

                #region 显示我自己发送的消息
                CSS.IM.XMPP.protocol.client.Message top_msg = new XMPP.protocol.client.Message();
                top_msg.SetTag("FName", this.Font.Name);//获得字体名称
                top_msg.SetTag("FSize", this.Font.Size);//字体大小
                top_msg.SetTag("FBold", true);//是否粗体
                top_msg.SetTag("FItalic", this.Font.Italic);//是否斜体
                top_msg.SetTag("FStrikeout", this.Font.Strikeout);//是否删除线
                top_msg.SetTag("FUnderline", true);//是否下划线

                Color top_cl = Color.Lime;//获取颜色
                byte[] top_cby = BitConverter.GetBytes(top_cl.ToArgb());
                top_msg.SetTag("CA", top_cby[0]);
                top_msg.SetTag("CR", top_cby[1]);
                top_msg.SetTag("CG", top_cby[2]);
                top_msg.SetTag("CB", top_cby[3]);
                top_msg.Body = _connection.Username + ":" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                top_msg.From = to_Jid;
                top_msg.To = to_Jid;
                RTBRecord_Show(top_msg, true);
                #endregion

                #region 发送的消息
                CSS.IM.XMPP.protocol.client.Message msg = new CSS.IM.XMPP.protocol.client.Message();

                Font ft = rtfSend.Font;//获取字体
                msg.SetTag("FName", ft.Name);//获得字体名称
                msg.SetTag("FSize", ft.Size);//字体大小
                msg.SetTag("FBold", ft.Bold);//是否粗体
                msg.SetTag("FItalic", ft.Italic);//是否斜体
                msg.SetTag("FStrikeout", ft.Strikeout);//是否删除线
                msg.SetTag("FUnderline", ft.Underline);//是否下划线

                Color cl = rtfSend.ForeColor;//获取颜色
                byte[] cby = BitConverter.GetBytes(cl.ToArgb());
                msg.SetTag("CA", cby[0]);
                msg.SetTag("CR", cby[1]);
                msg.SetTag("CG", cby[2]);
                msg.SetTag("CB", cby[3]);
                msg.SetTag("m_type", 0);
                msg.Type = MessageType.chat;
                msg.To = to_Jid;
                msg.SetTag("face", rtfSend.GetImageInfo().ToString());
                msg.Body = rtfSend.Text;
                msg.From = _connection.MyJID;
                RTBRecord_Show(msg, true);
                //保存要发送的图片;
                CSS.IM.Library.gifCollections tempGifs = this.rtfSend.GetExistGifs();
                foreach (MyPicture pic in tempGifs)
                {
                    //pic.Tag = Guid.NewGuid().ToString();
                    PicQueue.add(pic);
                    this.rtfSend.gifs.Romove(pic);
                }
                rtfSend.ClearUndo();
                rtfSend.Clear();
                rtfSend.Text = String.Empty;

                try
                {
                    rtfSend.ImeMode = ImeMode.OnHalf;
                }
                catch (Exception)
                {

                }

                _connection.Send(msg);

                CSS.IM.XMPP.protocol.client.Message fmsg = new CSS.IM.XMPP.protocol.client.Message();
                fmsg.SetTag("m_type", 4);
                fmsg.Type = MessageType.chat;
                fmsg.To = to_Jid;
                fmsg.SetTag("BPort", BaseLocalUDPPort);
                fmsg.SetTag("BIP", Program.LocalHostIP.ToString());
                fmsg.SetTag("isSend", true);
                fmsg.Body = "falg";
                fmsg.From = _connection.MyJID;
                _connection.Send(fmsg);
                #endregion
            }
            catch
            {

            }
            rtfSend.Focus();
        }
Ejemplo n.º 16
0
        private void ItemRefuseButtonClick(object sender, EventArgs e)
        {
            FileTransfersItem item = sender as FileTransfersItem;
            RequestSendFileEventArgs rse = item.Tag as RequestSendFileEventArgs;
            if (item.Style == FileTransfersItemStyle.ReadyReceive)
            {
                rse.Cancel = true;
                fileTansfersContainer.RemoveItem(item);
                item.Dispose();

                this.AppendSystemRtf(string.Format("拒绝接收文件 {0}。", rse.TraFransfersFileStart.FileName));
                udpReceiveFile.AcceptReceive(rse);
            }
            else
            {
                rse.ftpClient.DisConnect(true);
                Util.ReceiveFileManagerList.Remove(item.Name);
                fileTansfersContainer.RemoveItem(item);
                this.AppendSystemRtf(string.Format("接收离线文件 {0} 取消成功。", item.FileName));

                CSS.IM.XMPP.protocol.client.Message fmsg = new CSS.IM.XMPP.protocol.client.Message();
                fmsg.Type = MessageType.chat;
                fmsg.To = TO_Jid;
                fmsg.SetTag("m_type", 9);
                fmsg.SetTag("FileName", item.FileName);
                fmsg.From = XmppConn.MyJID;
                fmsg.Body = "离线文件" + item.FileName + "拒绝接受。";
                XmppConn.Send(fmsg);
            }
        }
Ejemplo n.º 17
0
 /// <summary>
 /// 关闭视频时
 /// </summary>
 void avForm_AVCloseEvent()
 {
     if (avForm != null && !avForm.IsDisposed)
         avForm.AVClose();
     if (ravForm != null && !ravForm.IsDisposed)
         ravForm.AVClose();
     CSS.IM.XMPP.protocol.client.Message msg = new CSS.IM.XMPP.protocol.client.Message();
     msg.Type = MessageType.chat;
     msg.To = TO_Jid;
     msg.SetTag("m_type", 5);
     XmppConn.Send(msg);
 }
Ejemplo n.º 18
0
 /// <summary>
 /// 接收视频会话事件
 /// </summary>
 void ravForm_AgreeEvent()
 {
     CSS.IM.XMPP.protocol.client.Message res_msg = new CSS.IM.XMPP.protocol.client.Message();
     res_msg.Type = MessageType.chat;
     res_msg.To = TO_Jid;
     res_msg.SetTag("m_type", 2);
     res_msg.SetTag("UDPPort", ListenVideoUDPPort);
     res_msg.SetTag("UDPIP", Program.LocalHostIP.ToString());
     if (XmppConn != null)
     {
         XmppConn.Send(res_msg);
     }
 }
Ejemplo n.º 19
0
        /// <summary>
        /// 发送事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_send_Click(object sender, EventArgs e)
        {
            if (XmppConn == null)
            {
                MsgBox.Show(this, "CSS&IM", "网络连接异常,需要重新打开聊天会话!", MessageBoxButtons.OK);
                this.Close();
            }

            if (rtfSend.Text.Length > 1000)
            {
                MsgBox.Show(this, "CSS&IM", "发送内容长度不能大于1000!", MessageBoxButtons.OK);
                return;
            }

            if (rtfSend.GetImageInfo().Length == 0)
            {

                if (!(rtfSend.Text.Trim().Length > 0))
                {
                    return;
                }
            }

            try
            {
                #region 显示我自己发送的消息
                CSS.IM.XMPP.protocol.client.Message top_msg = new XMPP.protocol.client.Message();
                top_msg.SetTag("FName", this.Font.Name);//获得字体名称
                top_msg.SetTag("FSize", this.Font.Size);//字体大小
                top_msg.SetTag("FBold", true);//是否粗体
                top_msg.SetTag("FItalic", this.Font.Italic);//是否斜体
                top_msg.SetTag("FStrikeout", this.Font.Strikeout);//是否删除线
                top_msg.SetTag("FUnderline", true);//是否下划线

                Color top_cl = Color.FromArgb(33, 119, 207);//获取颜色
                byte[] top_cby = BitConverter.GetBytes(top_cl.ToArgb());
                top_msg.SetTag("CA", top_cby[0]);
                top_msg.SetTag("CR", top_cby[1]);
                top_msg.SetTag("CG", top_cby[2]);
                top_msg.SetTag("CB", top_cby[3]);

                //(nikeName.Text != "" ? nikeName.Text : XmppConn.Username)
                //(Util.vcard.Nickname != "" ? Util.vcard.Nickname : XmppConn.Username)

                top_msg.Body = (Util.vcard.Nickname != "" ? Util.vcard.Nickname : XmppConn.Username) + "(" + XmppConn.Username + "):" + DateTime.Now.ToString("HH:mm:ss");
                top_msg.From = TO_Jid;
                top_msg.To = TO_Jid;
                RTBRecord_Show(top_msg, true);
                #endregion

                #region 发送的消息
                CSS.IM.XMPP.protocol.client.Message msg = new CSS.IM.XMPP.protocol.client.Message();

                Font ft = rtfSend.Font;//获取字体
                msg.SetTag("FName", ft.Name);//获得字体名称
                msg.SetTag("FSize", ft.Size);//字体大小
                msg.SetTag("FBold", ft.Bold);//是否粗体
                msg.SetTag("FItalic", ft.Italic);//是否斜体
                msg.SetTag("FStrikeout", ft.Strikeout);//是否删除线
                msg.SetTag("FUnderline", ft.Underline);//是否下划线

                Color cl = rtfSend.ForeColor;//获取颜色
                byte[] cby = BitConverter.GetBytes(cl.ToArgb());
                msg.SetTag("CA", cby[0]);
                msg.SetTag("CR", cby[1]);
                msg.SetTag("CG", cby[2]);
                msg.SetTag("CB", cby[3]);
                msg.SetTag("m_type", 0);
                msg.Type = MessageType.chat;
                msg.To = TO_Jid;
                msg.SetTag("face", rtfSend.GetImageInfo().ToString());
                msg.Body = rtfSend.Text;
                msg.From = XmppConn.MyJID;
                RTBRecord_Show(msg, true);

                //保存要发送的图片;
                CSS.IM.Library.gifCollections tempGifs = this.rtfSend.GetExistGifs();
                foreach (CSS.IM.Library.MyPicture pic in tempGifs)
                {
                    PicQueue.add(pic);
                    this.rtfSend.gifs.Romove(pic);
                }

                rtfSend.CloseImage();

                rtfSend.ClearUndo();
                rtfSend.Clear();
                rtfSend.Text = String.Empty;

                try
                {
                    rtfSend.ImeMode = ImeMode.OnHalf;
                }
                catch (Exception)
                {

                }
                XmppConn.Send(msg);

                //发送图片协议
                //CSS.IM.XMPP.protocol.client.Message fmsg = new CSS.IM.XMPP.protocol.client.Message();
                //fmsg.SetTag("m_type", 4);
                //fmsg.Type = MessageType.chat;
                //fmsg.To = TO_Jid;
                //fmsg.SetTag("BPort", ListenBasicUDPPort);
                //fmsg.SetTag("BIP", Program.LocalHostIP.ToString());
                //fmsg.SetTag("isSend", true);
                //fmsg.From = XmppConn.MyJID;
                //XmppConn.Send(fmsg);
                //ftp发送图片
                sendSelfImage();
                #endregion

            }
            catch
            {

            }
            rtfSend.Focus();

            System.GC.Collect();
        }
Ejemplo n.º 20
0
 /// <summary>
 /// 视频请求窗体关闭的事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void red5MsgSend_FormClosing(object sender, FormClosingEventArgs e)
 {
     CSS.IM.XMPP.protocol.client.Message msg = new CSS.IM.XMPP.protocol.client.Message();
     msg.Type = MessageType.chat;
     msg.To = TO_Jid;
     msg.SetTag("m_type", 13);
     XmppConn.Send(msg);
 }
Ejemplo n.º 21
0
        /// <summary>
        /// 视频发送请求
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_videoOpen_Click(object sender, EventArgs e)
        {
            if (!OnLine)
                return;

            string keyValue=Guid.NewGuid().ToString().Replace("-","");

            try
            {
                //if (avForm != null)
                //    if (!avForm.IsDisposed)
                //        return;

                //if (ravForm != null)
                //    if (!ravForm.IsDisposed)
                //        return;

                //avForm = new CSS.IM.App.Controls.AVForm(TO_Jid);
                //avForm.AVCloseEvent += new CSS.IM.App.Controls.AVForm.AVCloseDelegate(avForm_AVCloseEvent);
                //ListenVideoUDPPort = avForm.aVcommunicationEx1.selfUDPPort;

                //avForm.Show();

                if (red5MsgSend != null)
                    if (!red5MsgSend.IsDisposed)
                        return;

                if (red5MsgReceive != null)
                    if (!red5MsgReceive.IsDisposed)
                        return;

                string serUrl = @"http://" + Program.ServerIP + ":7070/redfire/video/redfire_2way.html?me={0}&you={1}&key={2}";
                red5MsgSend = new Red5Msg();
                red5MsgSend.FriendName = "正在与[" + TO_Jid.User + "]视频通话中";
                red5MsgSend.FormClosing += new FormClosingEventHandler(red5MsgSend_FormClosing);
                red5MsgSend.Cell(string.Format(serUrl, XmppConn.MyJID.User, TO_Jid.User, keyValue));
                red5MsgSend.Show();

                CSS.IM.XMPP.protocol.client.Message msg = new CSS.IM.XMPP.protocol.client.Message();
                msg.Type = MessageType.chat;
                msg.To = TO_Jid;
                msg.SetTag("m_type", 11);
                msg.SetTag("me", XmppConn.MyJID.User);
                msg.SetTag("you", TO_Jid.User);
                msg.SetTag("key", keyValue);
                XmppConn.Send(msg);

                this.AppendSystemRtf("向" + TO_Jid.User+"发送了视频请求,等待回应");

            }
            catch (Exception)
            {

            }

            //CSS.IM.XMPP.protocol.client.Message msg = new CSS.IM.XMPP.protocol.client.Message();
            //msg.Type = MessageType.chat;
            //msg.To = TO_Jid;
            //msg.SetTag("m_type", 1);
            //msg.SetTag("UDPPort", ListenVideoUDPPort);
            //msg.SetTag("UDPIP", Program.LocalHostIP.ToString());
            //XmppConn.Send(msg);

            ////callSoundPlayer.PlayLooping();
            ////SoundPlayEx.MsgPlay("call");
        }
Ejemplo n.º 22
0
        /// <summary>
        /// 发送文件事件
        /// </summary>
        /// <param name="f"></param>
        private void sendFile(System.IO.FileInfo f)
        {
            CSS.IM.XMPP.protocol.client.Message fmsg = new CSS.IM.XMPP.protocol.client.Message();
            if (OnLine)//如果在线
            {
                try
                {
                    fmsg.SetTag("m_type", 6);//告诉对方要发送文件啦
                    fmsg.Type = MessageType.chat;
                    fmsg.To = TO_Jid;
                    fmsg.SetTag("BPort", udpSendFile.Port);
                    fmsg.SetTag("BIP", Program.LocalHostIP.ToString());
                    fmsg.SetTag("isSend", true);
                    fmsg.SetTag("File", f.FullName.ToString());
                    XmppConn.Send(fmsg);
                    AppendSystemRtf("等待好友查看接收命令.");
                }
                catch (Exception)
                {

                }
            }
            else//如果
            {
                this.Invoke(FileSendInitEvent, f.FullName.ToString());
            }
            //this.Invoke(FileSendInitEvent, f.FullName.ToString());
        }
Ejemplo n.º 23
0
        private void ftpClient_GetFileSucceedEvent(FTPClient sender, string args)
        {
            try
            {
                BeginInvoke(new MethodInvoker(delegate()
                {
                    fileTansfersContainer.RemoveItem(sender.fileTransfersItem.Name);
                }));
                Util.ReceiveFileManagerList.Remove(sender.fileTransfersItem.Name);
                this.AppendSystemRtf(string.Format(@"文件<file:\\{0}>接收完成。", sender.fileTransfersItem.receivePath + sender.fileTransfersItem.FileName));

                CSS.IM.XMPP.protocol.client.Message fmsg = new CSS.IM.XMPP.protocol.client.Message();
                fmsg.Type = MessageType.chat;
                fmsg.To = TO_Jid;
                fmsg.SetTag("m_type", 9);
                fmsg.SetTag("FileName", sender.fileTransfersItem.FileName);
                fmsg.From = XmppConn.MyJID;
                fmsg.Body = "离线文件" + sender.fileTransfersItem.FileName + "接收成功。";
                XmppConn.Send(fmsg);
            }
            catch (Exception)
            {

            }
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Change the subject of a room
        /// </summary>
        /// <param name="room"></param>
        /// <param name="newSubject"></param>
        /// <param name="body"></param>
        public void ChangeSubject(Jid room, string newSubject, string body)
        {
            Message msg = new Message();
            msg.Type = MessageType.groupchat;
            msg.To = room;
            msg.Subject = newSubject;

            if (body != null)
                msg.Body = body;

            m_connection.Send(msg);
        }
Ejemplo n.º 25
0
        private void ftpClient_ImagePushFileSucceedEvent(FTPClient sender, string args)
        {
            CSS.IM.XMPP.protocol.client.Message fmsg = new CSS.IM.XMPP.protocol.client.Message();
            fmsg.Type = MessageType.chat;
            fmsg.To = TO_Jid;
            fmsg.SetTag("m_type", 10);
            fmsg.SetTag("FileName", args);
            fmsg.SetTag("Path", sender.FtpPath);
            fmsg.From = XmppConn.MyJID;
            fmsg.Body = "发送屏幕截图";
            XmppConn.Send(fmsg);

            System.Diagnostics.Debug.WriteLine("图片上传完成:"+args);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Invite multiple contacts to a chatroom
        /// </summary>
        /// <param name="jids"></param>
        /// <param name="room"></param>
        /// <param name="reason"></param>
        public void Invite(Jid[] jids, Jid room, string reason)
        {
            Message msg = new Message();
            msg.To = room;

            User user = new User();
            foreach (Jid jid in jids)
            {
                if (reason != null)
                    user.AddChild(new Invite(jid, reason));
                else
                    user.AddChild(new Invite(jid));
            }

            msg.AddChild(user);

            m_connection.Send(msg);
        }
Ejemplo n.º 27
0
        /// <summary>
        /// 发送消息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_send_Click(object sender, EventArgs e)
        {
            try
            {

                if (XmppConn == null)
                {
                    this.Close();
                }

                if (rtfSend.Text.Length > 1000)
                {
                    CSS.IM.UI.Form.MsgBox.Show(this, "CSS&IM", "发送内容长度不能大于1000!", MessageBoxButtons.OK);
                    return;
                }

                if (rtfSend.GetImageInfo().Length == 0)
                {

                    if (!(rtfSend.Text.Trim().Length > 0))
                    {
                        return;
                    }
                }

                CSS.IM.XMPP.protocol.client.Message msg = new CSS.IM.XMPP.protocol.client.Message();
                msg.Namespace = null;
                Font ft = rtfSend.Font;//获取字体
                msg.SetTag("FName", ft.Name);//获得字体名称
                msg.SetTag("FSize", ft.Size);//字体大小
                msg.SetTag("FBold", ft.Bold);//是否粗体
                msg.SetTag("FItalic", ft.Italic);//是否斜体
                msg.SetTag("FStrikeout", ft.Strikeout);//是否删除线
                msg.SetTag("FUnderline", ft.Underline);//是否下划线

                Color cl = rtfSend.ForeColor;//获取颜色
                byte[] cby = BitConverter.GetBytes(cl.ToArgb());
                msg.SetTag("CA", cby[0]);
                msg.SetTag("CR", cby[1]);
                msg.SetTag("CG", cby[2]);
                msg.SetTag("CB", cby[3]);

                msg.SetTag("m_type", 0);
                msg.Type = MessageType.groupchat;
                msg.To = new Jid(TO_Jid.User, TO_Jid.Server, null);
                msg.SetTag("face", rtfSend.GetImageInfo().ToString());
                msg.Body = rtfSend.Text;

                //保存要发送的图片;
                CSS.IM.Library.gifCollections tempGifs = this.rtfSend.GetExistGifs();
                foreach (CSS.IM.Library.MyPicture pic in tempGifs)
                {
                    PicQueue.add(pic);
                    this.rtfSend.gifs.Romove(pic);
                }

                rtfSend.ClearUndo();
                rtfSend.Clear();
                rtfSend.Text = String.Empty;

                try
                {
                    rtfSend.ImeMode = ImeMode.OnHalf;
                }
                catch (Exception)
                {
                }

                //发送自己的昵称
                if (Util.vcard.Nickname == null)
                {
                    msg.SetTag("NickName", XmppConn.MyJID.User);
                }
                else
                {
                    msg.SetTag("NickName", Util.vcard.Nickname.Trim().Length > 0 ? Util.vcard.Nickname : XmppConn.MyJID.User);
                }

                XmppConn.Send(msg);
            }
            catch
            {

            }

            System.GC.Collect();
        }