コード例 #1
0
        public void should_parse_room_message_into_proper_type()
        {
            var message = new agsXMPP.protocol.client.Message() {From = "[email protected]/Dharma Soft", Body = "Message Body"};

            var xmppMessage = MessageFactory.Create(message);
            Assert.That(xmppMessage.MessageType,Is.EqualTo(MessageType.RoomMessage));
        }
コード例 #2
0
 public void Execute(Message message)
 {
     if(_directory.RemoveSubscriber(message.From.Bare))
     {
         _communicator.SendMessage(message.From.Bare,REMOVED_CONFIRMATION_MESSAGE);
     }
 }
コード例 #3
0
ファイル: MessageUtil.cs プロジェクト: Irdis/VSTalk
 public static bool IsContentMessage(Message msg)
 {
     //A "content message" -- that is, a message stanza whose primary meaning is contained in
     //standard messaging content such as the XMPP <body/> or any other properly-namespaced child
     //element(s) other than those defined for chat state notifications in this specification.
     return !string.IsNullOrEmpty(msg.Body) || msg.HasTag(XamlBody.TAG);
 }
コード例 #4
0
ファイル: XMPPClass.cs プロジェクト: cupid0426/MyProject
 /// <summary>
 /// 命令发送
 /// </summary>
 /// <param name="ToServerName"></param>
 /// <param name="strCommand"></param>
 public void SendCommand(string ToServerName, string strCommand)
 {
     agsXMPP.Jid jid = new agsXMPP.Jid(ToServerName);
     agsXMPP.protocol.client.Message sendMsg = new agsXMPP.protocol.client.Message(jid, MessageType.chat, strCommand);
     objXmpp.Send(sendMsg);
     LogTrace(ToServerName + " " + strCommand);
 }
コード例 #5
0
 private void ConnectionOnMessage(object sender, Message msg)
 {
     OnMessageReceived(new MessageReceivedArgs
     {
         Message = Create(msg)
     });
 }
コード例 #6
0
        private void OnMessage(object sender, agsXMPP.protocol.client.Message message)
        {
            if (!String.IsNullOrEmpty(message.Body) && message.From.Resource != _username)
            {
                string user = string.Format("{0}@{1}/{2}", message.From.User, message.From.Server, message.From.Resource);

                var content = message.Body.Trim();

                if (message.From.Server != _confServer && !content.StartsWith(Robot.Alias ?? Robot.Name, StringComparison.OrdinalIgnoreCase))
                {
                    content = string.Concat(Robot.Alias ?? Robot.Name, " ", content);
                }

                Logger.Info(string.Format("[{0}] {1}: {2}", DateTime.Now, user, content));

                var userObj = Robot.GetUser(message.Id, user, message.From.Bare, Id);

                if (userObj.Name != _username)
                {
                    Task.Run(() =>
                    {
                        Robot.Receive(new TextMessage(userObj, content));
                    });
                }
            }
        }
コード例 #7
0
ファイル: Message.cs プロジェクト: phiree/dzdocs
        private void Message1()
        {
            // transient message (will not be stored offline if the server support AMP)

            /*
            <message to='*****@*****.**'
                     from='[email protected]/elsinore'
                     type='chat'
                     id='chatty1'>
              <body>Who&apos;s there?</body>
              <amp xmlns='http://jabber.org/protocol/amp'>
                <rule action='drop' condition='deliver' value='stored'/>
              </amp>
            </message>
            */

            agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message();
            msg.To = new Jid("*****@*****.**");
            msg.From = new Jid("[email protected]/elsinore");
            msg.Type = MessageType.chat;
            msg.Id = "chatty1";

            msg.Body = "Who&apos;s there?";

            Amp amp = new Amp();
            Rule rule = new Rule(Condition.Deliver, "stored", agsXMPP.protocol.extensions.amp.Action.drop);
            amp.AddRule(rule);

            msg.AddChild(amp);

            Program.Print(msg);
        }
コード例 #8
0
ファイル: Form2.cs プロジェクト: phiree/dzdocs
        //������Ϣ
        private void button2_Click(object sender, EventArgs e)
        {
            agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message();

            if (listBox1.SelectedIndex > 0)
            {
                msg.Type = MessageType.chat;
                msg.Body = richTextBox2.Text;
                msg.From = new Jid(con.Username, "localhost", "resource");
                msg.To = new Jid(name, "localhost", con.Username);

                con.Send(msg);

                richTextBox2.Text = "";
            }
            else
            {
                msg.Type = MessageType.groupchat;
                msg.Body = richTextBox2.Text;
                msg.From = new Jid(con.Username, "localhost", "resource");
                msg.To = new Jid(con.Server, "localhost", con.Username);

                con.Send(msg);

                richTextBox2.Text = "";
            }
        }
コード例 #9
0
ファイル: Form1.cs プロジェクト: foxundermoon/MessageService
 private void button2_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrWhiteSpace(textBox4.Text))
     {
         MessageBox.Show("要发送到的uid不能为空!");
     }
     else if (string.IsNullOrWhiteSpace(textBox2.Text))
     {
         MessageBox.Show("消息不能为空!");
     }
     else
     {
         try
         {
             int    touid        = int.Parse(textBox4.Text);
             string JID_RECEIVER = touid + "@10.80.5.254";
             agsXMPP.protocol.client.Message m = new agsXMPP.protocol.client.Message(new Jid(JID_RECEIVER), MessageType.chat, textBox2.Text);
             m.To   = new Jid(JID_RECEIVER);
             m.From = selfJid;
             xmpp.Send(m);
         }catch (FormatException fe)
         {
             MessageBox.Show("要发送到的uid只能是数字");
         }
     }
 }
コード例 #10
0
        public void ProcessMessage(Message message)
        {
            if (!CanProcess(message))
                return;

            ChatMember from = _directory.LookUp(message.From.Bare);

            if (from == null)
                return;

            if (from.ActiveInChat)
            {
                IEnumerable<ChatMember> recipients = _directory.GetToListForSubscriber(message.From.Bare);

                foreach (ChatMember member in recipients)
                {
                    if (member.ActiveInChat)
                    {
                        _communicator.SendMessage(member.Jid, string.Format("[\"{0}\"] {1}", from.Alias, message.Body));
                    }
                }
            }
            else
            {
                _communicator.SendMessage(from.Jid, NOT_ACTIVE_IN_CHAT_MESSAGE);
            }
        }
コード例 #11
0
ファイル: XmppHostBase.cs プロジェクト: micahlmartin/RPS-Xmpp
        protected virtual void ProcessMessage(Message message)
        {
            if (message.Body == null) return;

            try
            {
                var msgObj = MessageFactory.GetMessageFromXml(message.Body);
                if (msgObj == null) return;

                var msgType = msgObj.GetType();

                if (msgType == typeof(GameStartMessage))
                    ProcessGameStartMessage(message.From, (GameStartMessage)msgObj);
                if (msgType == typeof(GameOverMessage))
                    ProcessGameOverMessage(message.From, (GameOverMessage)msgObj);
                if (msgType == typeof(TurnResultMessage))
                    ProcessTurnResultMessage(message.From, (TurnResultMessage)msgObj);
                if (msgType == typeof(TurnStartMessage))
                    ProcessTurnStartMessage(message.From, (TurnStartMessage)msgObj);
                if (msgType == typeof(RegistrationCompleteMessage))
                    ProcessRegistrationCompleteMessage(message.From);
                if (msgType == typeof(TournamentStartedMessage))
                    ProcessTournamentStartedMessage(message.From, (TournamentStartedMessage)msgObj);
                if (msgType == typeof(PlayerMoveMessage))
                    ProcessPlayerMoveMessage(message.From, (PlayerMoveMessage)msgObj);
                if (msgType == typeof(RegisterMessage))
                    ProcessRegisterMessage(message.From);
            }
            catch (Exception) { }
        }
コード例 #12
0
ファイル: Util.cs プロジェクト: Br3nda/sfdocsamples
        /// <summary>
        /// Al usuario B le llega un mensaje y levanta un formulario drmChat
        /// </summary>
        /// <param name="msg">Message enviado por A</param>
        public void SwitchMessage(agsXMPP.protocol.client.Message msg)
        {
            if (msg.Type == MessageType.groupchat)
            {
                return;
            }

            if (msg.Body != null)//--> es un chat
            {
                frmChat f = null;
                if (ChatForms.ContainsKey(msg.From.Bare))
                {
                    f = (frmChat)ChatForms[msg.From.Bare];
                    f.Show();
                }
                else
                {
                    RosterNode rn   = RosterControl.GetRosterItem(msg.From);
                    string     nick = msg.From.Bare;
                    if (rn != null)
                    {
                        nick = rn.Text;
                    }

                    f = new frmChat(msg.From, nick);
                    f.Show();
                    f.IncomingMessage(msg);
                }
            }
            if (msg.HasTag(typeof(Comand)))
            {
            }
        }
コード例 #13
0
        private void xmpp_OnMessage(object sender, agsXMPP.protocol.client.Message msg)
        {
            new Task(delegate
            {
                //ignore empty messages
                if (msg.Body.IsNullOrEmpty() || msg.Error != null)
                {
                    return;
                }

                //get the message's sender, remove XMPP resource from the message
                var messageSender = msg.From.ToString();
                messageSender     = messageSender.Contains("/") ? messageSender.Substring(0, messageSender.IndexOf("/")) : messageSender;

                //if messages bounced and sender is this client itself, ignore the message
                if (messageSender.ToLower() == String.Format("{0}@{1}", this.Username, this.Server).ToLower())
                {
                    logger.Warn("Bounced message revceived. Ignoring");
                    return;
                }

                logger.Info("Received message from {0}", messageSender);

                //Raise MessageReceived event
                this.onMessageReceived(messageSender, msg.Body);
            }).Start();
        }
コード例 #14
0
        private void MessageCallBack(object sender, Message msg, object data)
        {
            if (msg.Body != null)
            {
                var payload = new MessagePayload();
                payload.Attachments = new List<MessagePayloadAttachment>();
                if (!msg.Body.Contains("@everyone"))
                {
                    msg.Body = string.Concat("@everyone: ", msg.Body);
                }
                payload.Attachments.Add(new MessagePayloadAttachment()
                {
                    Text = msg.Body.Replace("@everyone", "@channel"),
                    Title = string.Format("{0}: Message from {1}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "Marvin"),
                    Colour = "#ff0066"
                });
                Plugin.SendToRoom(payload, Properties.Settings.Default.FleetRoomName, Properties.Settings.Default.SlackWebhook, Properties.Settings.Default.FleetBotName);

                if (msg.Body.Contains("bog_all"))
                {
                    foreach (var hook in Properties.Settings.Default.DiscordLinkSlackWebhooks)
                    {
                        Plugin.SendToRoom(payload, Properties.Settings.Default.FleetRoomName, hook, Properties.Settings.Default.FleetBotName);
                    }
                }
            }
        }
コード例 #15
0
ファイル: HipChatService.cs プロジェクト: Olezhka/Hipbot
        private void Say(Room room, string message, bool html)
        {
            Msg msg;

            if (room.IsChat)
            {
                var to = new Jid(room.JabberId, "chat.hipchat.com", string.Empty);

                msg = new Msg(to, current.JabberId, MessageType.chat, message);
            }
            else
            {
                Out.WriteLine("{0:HH:mm:ss} [{1}] {2}", DateTime.Now, current.Name, message);

                var to = new Jid(room.JabberId, "conf.hipchat.com", string.Empty);

                msg = new Msg(to, current.JabberId, MessageType.groupchat, message);
            }

            if (html)
            {
                msg.Html            = new Html();
                msg.Html.Body       = new Body();
                msg.Html.Body.Value = message;
            }

            Out.WriteLine(msg.ToString());

            connection.Send(msg);
        }
コード例 #16
0
        public bool CanProcess(Message message)
        {
            if (message == null)
                return false;

            return !string.IsNullOrEmpty(CommandProcessor.GetCommandFromMessage(message.Body));
        }
コード例 #17
0
ファイル: frmGroupChat.cs プロジェクト: Br3nda/sfdocsamples
        /// <summary>
        /// Procesar llegada de mensaje
        /// </summary>
        /// <param name="msg"></param>
        private void IncomingMessage(agsXMPP.protocol.client.Message msg)
        {
            if (msg.Type == MessageType.error)
            {
                //TODO: HAY QUE MANEJAR EL ERROR AQUI
                return;
            }

            if (msg.Subject != null)//------------> SI CAMBIA EL ASUNTO
            {
                txtSubject.Text = msg.Subject;

                rtfChat.SelectionColor = Color.DarkGreen;
                // El Nickname del que envia esta en el GroupChat, en el Jid.Resource
                rtfChat.AppendText(msg.From.Resource + " changed subject: ");
                rtfChat.SelectionColor = Color.Black;
                rtfChat.AppendText(msg.Subject);
                rtfChat.AppendText("\r\n");
            }
            else
            {
                if (msg.Body == null)
                {
                    return;
                }

                rtfChat.SelectionColor = Color.Red;
                // The Nickname of the sender is in GroupChat in the Resource of the Jid
                rtfChat.AppendText(msg.From.Resource + " said: ");
                rtfChat.SelectionColor = Color.Black;
                rtfChat.AppendText(msg.Body);
                rtfChat.AppendText("\r\n");
            }
        }
コード例 #18
0
ファイル: XamlMessageBuilder.cs プロジェクト: Irdis/VSTalk
        public Message Create(FlowDocument document)
        {
            var xdoc = new XmlDocument();
            xdoc.LoadXml(XamlWriter.Save(document));

            var newAttr = xdoc.CreateAttribute("xml:space");
            newAttr.Value = "preserve";

            xdoc.DocumentElement.Attributes.Append(newAttr);
            var sb = new StringBuilder(xdoc.OuterXml);
            //see: http://stackoverflow.com/questions/2624068/wpf-richtextbox-xamlwriter-behaviour
            var xamlPart = sb.Replace("{}{", "{").ToString();

            var txtPart = new TextRange(document.ContentStart, document.ContentEnd)
                    .Text
                    .TrimEnd();
            var xaml = new XamlBody();
            xaml.Content = xamlPart;
            var msg = new Message
            {
                    Body = txtPart,
            };
            msg.AddChild(xaml);
            return msg;
        }
コード例 #19
0
 private void listUsers_MouseDoubleClick(object sender, MouseEventArgs e)
 {
     if (listUsers.SelectedItems.Count > 0 && listUsers.SelectedItems[0] != null)
     {
         initFormDialog();
         string name     = listUsers.SelectedItems[0].Text;
         string jid      = listUsers.SelectedItems[0].Name;
         int    indexTab = findTagPage(jid);
         List <agsXMPP.protocol.client.Message> msgsWait = waitList.FindAll(item => item.From.Bare == jid);//получает все сообщения из списка ожидающих сообщений с нужным jid
         if (indexTab == -1)
         {
             createTabPage(name, jid);//, getHistoryFromDB(jid));
             tabsDialog.SelectedIndex = tabsDialog.TabPages.Count - 1;
         }
         else
         {
             tabsDialog.SelectedIndex = indexTab;
         }
         indexTab = tabsDialog.SelectedIndex;
         //добавляем сообщения из ожидания в диалог
         for (int i = msgsWait.Count - 1; i >= 0; i--)
         {
             agsXMPP.protocol.client.Message msgWait = msgsWait[i];
             ((TextBox)tabsDialog.TabPages[indexTab].Controls[0]).AppendText(formateString(msgWait.From.Bare, msgWait.Body));
             waitList.Remove(msgWait);
         }
     }
 }
コード例 #20
0
 /// <summary>
 /// Отправляет сообщение к собеседнику с заданным jid и выводит его в textbox с чатом, а также добавляет в историю(в бд)
 /// </summary>
 /// <param name="toJid">jid получателя</param>
 /// <param name="dialog">textbox с чатом</param>
 /// <param name="message">сообщение</param>
 public void SendTextMessage(Jid toJid, RichTextBox dialog, string message)
 {
     agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message(toJid, MessageType.chat, message);
     xmpp.Send(msg);
     addMessToDialog(nickname, message, dialog, Settings.myColor);
     //addMessageToHistoryDB(mainJid.Bare, mainJid.Resource, toJid.Bare, toJid.Resource, message);
 }
コード例 #21
0
        void XmppConnection_OnMessage(object sender, Message msg)
        {
            if (!roomName.Contains(msg.From.User))
                return;

            if (msg.From.Resource == Client.LoginPacket.AllSummonerData.Summoner.Name)
                return;

            Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
            {
                if (msg.Body == "This room is not anonymous")
                    return;

                var tr = new TextRange(ChatText.Document.ContentEnd, ChatText.Document.ContentEnd)
                {
                    Text = msg.From.Resource + ": "
                };
                tr.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Turquoise);

                tr = new TextRange(ChatText.Document.ContentEnd, ChatText.Document.ContentEnd)
                {
                    Text = msg.Body.Replace("<![CDATA[", "").Replace("]]>", string.Empty) + Environment.NewLine
                };
                tr.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.White);

                ChatText.ScrollToEnd();
            }));
        }
コード例 #22
0
 private void SendTextMessage(string toJid, TextBox dialog, string message)
 {
     agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message(new Jid(toJid), MessageType.chat, message);
     xmpp.Send(msg);
     dialog.AppendText(formateString(nickname, message));
     addMessageToDB(mainJid.Bare, toJid, message);
 }
コード例 #23
0
        private void IncomingMessage(agsXMPP.protocol.client.Message msg)
        {
            if (msg.Type == MessageType.error)
            {
                //Handle errors here
                // we dont handle them in this example
                return;
            }
            if (msg.Subject != null)
            {
                txtSubject.Text = msg.Subject;

                rtfChat.SelectionColor = Color.DarkGreen;
                // The Nickname of the sender is in GroupChat in the Resource of the Jid
                rtfChat.AppendText(msg.From.Resource + " изменил тему: ");
                rtfChat.SelectionColor = Color.Black;
                rtfChat.AppendText(msg.Subject);
                rtfChat.AppendText("\r\n");
            }
            else
            {
                if (msg.Body == null)
                {
                    return;
                }

                rtfChat.SelectionColor = Color.Blue;//(msg.Nickname.InnerXml == nickname) ? Color.Green : Color.Red;
                // The Nickname of the sender is in GroupChat in the Resource of the Jid
                rtfChat.AppendText(msg.From.Resource + " : ");
                rtfChat.SelectionColor = Color.Black;
                rtfChat.AppendText(msg.Body);
                rtfChat.AppendText("\r\n");
            }
        }
コード例 #24
0
ファイル: mainForm.cs プロジェクト: SSaimon69/MSGOK
        void recieveMsg(agsXMPP.protocol.client.Message msg)
        {
            if (curUser != null && msg.From.Equals(curUser.Jid))  //Если написал тот пользователь, с кем сейчас диалог
            {
                richTextBox1.SelectionColor = Color.Red;
                richTextBox1.AppendText(curUser.Name + ": ");
                richTextBox1.SelectionColor = Color.Black;
                richTextBox1.AppendText(msg.Body + "\n");
            }
            else
            {
                xDoc.Load("src.xml");
                XmlElement xRoot = xDoc.DocumentElement;

                XmlNode node = xRoot.SelectSingleNode("user[@JID='" + msg.From + "']");

                if (node == null)
                {
                    XmlElement   userElem = xDoc.CreateElement("user");
                    XmlElement   textUser = xDoc.CreateElement("text");
                    XmlElement   rtfUser  = xDoc.CreateElement("rtf");
                    XmlAttribute jidAttr  = xDoc.CreateAttribute("JID");

                    jidAttr.AppendChild(xDoc.CreateTextNode(msg.From.ToString()));
                    userElem.Attributes.Append(jidAttr);

                    newMsgBox.SelectionColor = Color.Red;
                    newMsgBox.AppendText(getNameByJID(msg.From) + ": ");
                    newMsgBox.SelectionColor = Color.Black;
                    newMsgBox.AppendText(msg.Body + "\n");

                    textUser.InnerText = newMsgBox.Text;
                    rtfUser.InnerText  = newMsgBox.Rtf;

                    newMsgBox.Clear();

                    userElem.AppendChild(textUser);
                    userElem.AppendChild(rtfUser);

                    xRoot.AppendChild(userElem);
                }
                else
                {
                    newMsgBox.Rtf = node.SelectSingleNode("rtf").InnerText;

                    newMsgBox.SelectionColor = Color.Red;
                    newMsgBox.AppendText(getNameByJID(msg.From) + ": ");
                    newMsgBox.SelectionColor = Color.Black;
                    newMsgBox.AppendText(msg.Body + "\n");

                    node.SelectSingleNode("text").InnerText = newMsgBox.Text;
                    node.SelectSingleNode("rtf").InnerText  = newMsgBox.Rtf;

                    newMsgBox.Clear();
                }
                addUnRead(msg.From.ToString());
                xDoc.Save("src.xml");
            }
        }
コード例 #25
0
ファイル: RibbonFormChat.cs プロジェクト: hamachan123/chat
 public void IncomingMessage(Message message)
 {
     chatRichTextBoxShow.SelectionColor = Color.Indigo;
     chatRichTextBoxShow.AppendText(_nickName + " said:");
     chatRichTextBoxShow.SelectionColor = Color.Olive;
     chatRichTextBoxShow.AppendText(message.Body);
     chatRichTextBoxShow.AppendText("\r\n");
 }
コード例 #26
0
 /// <summary>
 /// Changing the subject in a chatroom
 /// in MUC rooms this could return an error when you are a normal user and not allowed
 /// to change the subject.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void cmdChangeSubject_Click(object sender, EventArgs e)
 {
     agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message();
     msg.Type    = MessageType.groupchat;
     msg.To      = roomJid;
     msg.Subject = txtSubject.Text;
     xmpp.Send(msg);
 }
コード例 #27
0
ファイル: RibbonFormChat.cs プロジェクト: hamachan123/chat
 private void OutMessage(Message message)
 {
     chatRichTextBoxShow.SelectionColor = Color.MidnightBlue;
     chatRichTextBoxShow.AppendText("Me said:");
     chatRichTextBoxShow.SelectionColor = Color.RosyBrown;
     chatRichTextBoxShow.AppendText(message.Body);
     chatRichTextBoxShow.AppendText("\r\n");
 }
コード例 #28
0
 private void cmdSend_Click()
 {
     // Send a message
     agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message();
     msg.Type = agsXMPP.protocol.client.MessageType.chat;
     msg.To = new Jid("");
     msg.Body = "";
 }
コード例 #29
0
ファイル: Client.cs プロジェクト: nubuntu/mychitchat
 void JabberClient_OnMessage(object sender, agsXMPP.protocol.client.Message msg)
 {
     Log.Debug(String.Format("New jabber message from {0}: {1}", msg.From.ToString(), msg.Body));
     if (msg.Type == MessageType.chat && msg.From != null && msg.From != new Jid(_jabberConnection.identity.jabberID.full))
     {
         OnMessage(new Message(msg, DirectionTypes.Incoming, DateTime.Now));
     }
 }
コード例 #30
0
 private void OutgoingMessage(agsXMPP.protocol.client.Message msg)
 {
     rtfChat.SelectionColor = Color.Blue;
     rtfChat.AppendText("Me said: ");
     rtfChat.SelectionColor = Color.Black;
     rtfChat.AppendText(msg.Body);
     rtfChat.AppendText("\r\n");
 }
コード例 #31
0
 public void IncomingMessage(agsXMPP.protocol.client.Message msg)
 {
     rtfChat.SelectionColor = Color.Red;
     rtfChat.AppendText(_nickname + " said: ");
     rtfChat.SelectionColor = Color.Black;
     rtfChat.AppendText(msg.Body);
     rtfChat.AppendText("\r\n");
 }
コード例 #32
0
ファイル: FurikoMessage.cs プロジェクト: nimdraugsael/furiko
 public FurikoMessage(Message _msg)
 {
     DateTime now = DateTime.Now;
     //time = now.ToString("yyyy-MM-dd HH:mm:ss");
     time = DateTime.Now;
     with = _msg.From.Bare;
     jid = _msg.From.Bare;
     body = _msg.Body;
 }
コード例 #33
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="msg"></param>
 /// <param name="data"></param>
 private void MessageCallback(object sender, agsXMPP.protocol.client.Message msg, object data)
 {
     BeginInvoke(new MethodInvoker(delegate {
         if (msg.Type == MessageType.groupchat)
         {
             IncomingMessage(msg);
         }
     }));
 }
コード例 #34
0
        private void MessageCallback(object sender, agsXMPP.protocol.client.Message msg, object data)
        {
            if (msg.Body == null)
            {
                return;
            }

            IncomingMessage(msg);
        }
コード例 #35
0
ファイル: frmMain.cs プロジェクト: Br3nda/sfdocsamples
        private void btnBroadCast_Click(object sender, EventArgs e)
        {
            agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message();
            msg.Subject = "Mensaje a todos";

            msg.To   = new Jid(string.Concat("all@broadcast.", Util.storage.StorageObject.Server));
            msg.Body = "Hola a todos";
            Util.XmppServices.XmppCon.Send(msg);
        }
コード例 #36
0
 private IMessage Create(Message msg)
 {
     return new FeedMessage
     {
         XmppMessage = msg,
         Date = DateTime.Now,
         ClientId = _client.Id
     };
 }
コード例 #37
0
 public void OnMessage(object sender, Message msg)
 {
     if (msg.Type == MessageType.chat)
     {
         messages.Enqueue(msg);
         messageEvent.Set();
         //currentChat = msg.CreateNewThread();
     }
 }
コード例 #38
0
ファイル: TextMessageBuilder.cs プロジェクト: Irdis/VSTalk
 public Message Create(FlowDocument document)
 {
     var body = new TextRange(document.ContentStart, document.ContentEnd)
             .Text
             .TrimEnd(Environment.NewLine.ToCharArray());
     var msg = new Message();
     msg.Body = body;
     return msg;
 }
コード例 #39
0
 private void button2_Click_1(object sender, EventArgs e)
 {
     agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message();
     msg.Type = MessageType.groupchat;
     msg.To = Roomjid;
     msg.Body = textBox2.Text;
     dbcon.Send(msg);
     textBox2.Clear();
 }
コード例 #40
0
        //Blink and add to notification list if messaged
        private void XmppConnection_OnMessage(object sender, Message msg)
        {
            //If is special message, don't show popup
            if (msg.Subject != null)
            {
                Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                {
                    var subject = (ChatSubjects)Enum.Parse(typeof(ChatSubjects), msg.Subject, true);

                    if ((subject == ChatSubjects.PRACTICE_GAME_INVITE ||
                         subject == ChatSubjects.GAME_INVITE) &&
                        Client.NotificationContainer.Visibility != Visibility.Visible)
                    {
                        NotificationButton.Content = ".";
                    }
                }));
                return;
            }

            if (!Client.AllPlayers.ContainsKey(msg.From.User) || string.IsNullOrWhiteSpace(msg.Body))
                return;
            if (msg.Body.ToLower().Contains("elo") && msg.Body.ToLower().Contains("boost"))
                return;

            ChatPlayerItem chatItem = Client.AllPlayers[msg.From.User];
            Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
            {
                NotificationChatPlayer player =
                    ChatListView.Items.Cast<object>()
                        .Where(i => i.GetType() == typeof(NotificationChatPlayer))
                        .Cast<NotificationChatPlayer>()
                        .FirstOrDefault(x => x.PlayerName == chatItem.Username);

                if (player == null)
                {
                    player = new NotificationChatPlayer
                    {
                        Tag = chatItem,
                        PlayerName = chatItem.Username,
                        Margin = new Thickness(1, 0, 1, 0),
                        PlayerLabelName = { Content = chatItem.Username }
                    };
                    Client.ChatListView.Items.Add(player);
                }

                if (Client.ChatItem != null)
                {
                    if ((string)Client.ChatItem.PlayerLabelName.Content != chatItem.Username)
                    {
                        player.BlinkRectangle.Visibility = Visibility.Visible;
                    }
                }
                else
                    player.BlinkRectangle.Visibility = Visibility.Visible;
            }));
        }
コード例 #41
0
ファイル: frmMain.cs プロジェクト: Br3nda/sfdocsamples
        void XmppCon_OnMessage(object sender, agsXMPP.protocol.client.Message msg)
        {
            if (InvokeRequired)
            {
                BeginInvoke(new MessageHandler(XmppCon_OnMessage), new object[] { sender, msg });
                return;
            }

            Util.XmppServices.SwitchMessage(msg);
        }
コード例 #42
0
        static void HipchatClient_OnMessage(object sender, Message msg)
        {
            HipchatRoom room = Rooms.FirstOrDefault(rm => rm.RoomId.Bare.StartsWith(msg.From.Bare, StringComparison.CurrentCultureIgnoreCase));

            if (room == null)
            {
                return;
            }
            Window.AddItem(msg.Body, msg.From.Resource, room.Name);
        }
コード例 #43
0
ファイル: frmGroupChat.cs プロジェクト: phiree/dzdocs
        /// <summary>
        /// Changing the subject in a chatroom
        /// in MUC rooms this could return an error when you are a normal user and not allowed
        /// to change the subject.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdChangeSubject_Click(object sender, EventArgs e)
        {
            agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message();

            msg.Type = MessageType.groupchat;
            msg.To = m_RoomJid;
            msg.Subject = txtSubject.Text;

            m_XmppCon.Send(msg);
        }
コード例 #44
0
        public void ProcessMessage(Message message)
        {
            if (!CanProcess(message))
                return;

            string commandString = CommandProcessor.GetCommandFromMessage(message.Body);
            ICommand command = Array.Find(_commands, c => c.CommandName == commandString.ToLower());
            if(command != null)
                command.Execute(message);
        }
コード例 #45
0
ファイル: XmppChatRoom.cs プロジェクト: dustyburwell/jell
        private void OnMessage(object sender, Message msg)
        {
            if (m_listener == null)
            return;

             if (msg.From.Bare != Jid)
            return;

             m_listener.OnMessage(new ChatMessage(msg.From.Resource, msg.Body));
        }
コード例 #46
0
        static void MessageCallBack(object sender, agsXMPP.protocol.client.Message msg, object data)
        {
            if ((msg.Body != null) && (msg.Body.Contains(Properties.Settings.Default.AllianceGroup) ||
                                       msg.Body.Contains(Properties.Settings.Default.CorpGroup)
                                       ||
                                       msg.Body.Contains(Properties.Settings.Default.FCGroup)))
            {
                var lines       = msg.Body.Split(new[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);
                var senderLines = lines[0].Replace("**** This was broadcast by ", "").Replace(" EVE ****", "").Replace("@everyone", "").Split(new[] { " at " }, StringSplitOptions.RemoveEmptyEntries);
                var recipient   = lines[lines.Length - 1].Replace("**** Message sent to the ", "").Replace(" Group ****", "");

                var sendLines = new List <string>();
                //sendLines.Add(string.Format("Timestamp: {0}", senderLines[1]));
                sendLines.Add(string.Format("From: {0}", senderLines[0]));
                sendLines.Add(string.Format("To: {0}", recipient));

                for (var i = 1; i < lines.Length - 1; i++)
                {
                    sendLines.Add(lines[i]);
                }

                ConsoleWriteLine(string.Format("{0}>> {1}", msg.From.User, msg.Body), ConsoleColor.Red);

                var payload = new MessagePayload();
                payload.Text        = "@channel: Alliance Broadcast";
                payload.Attachments = new List <MessagePayloadAttachment>();
                //if (!msg.Body.Contains("@everyone"))
                //{
                //    sendLines.Insert(0, "@everyone");
                //}
                payload.Attachments.Add(new MessagePayloadAttachment()
                {
                    Text   = new Censor().CensorText(string.Join("\n", sendLines)),
                    Title  = string.Format("{0}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")),
                    Colour = "#ff0066"
                });
                if (msg.Body.Contains(Properties.Settings.Default.CorpGroup) || msg.Body.Contains(Properties.Settings.Default.AllianceGroup))
                {
                    Plugin.SendToRoom(payload, Properties.Settings.Default.Room, Properties.Settings.Default.SlackWebhook, Properties.Settings.Default.BroadcastName);

                    if (msg.Body.Contains(Properties.Settings.Default.AllianceGroup))
                    {
                        foreach (var webhook in Properties.Settings.Default.SharedWebhooks)
                        {
                            Plugin.SendToRoom(payload, Properties.Settings.Default.Room, webhook, Properties.Settings.Default.BroadcastName);
                        }
                    }
                }
                else if (msg.Body.Contains(Properties.Settings.Default.FCGroup))
                {
                    Plugin.SendToRoom(payload, Properties.Settings.Default.FCRoom, Properties.Settings.Default.SlackWebhook, Properties.Settings.Default.BroadcastName);
                }
            }
        }
コード例 #47
0
ファイル: ChatMessage.cs プロジェクト: ungood/BadaBingBot
        public ChatMessage(XmppClientConnection client, Message message)
        {
            this.client = client;

            Text = message.Body;
            From = message.From;
            IsGroupChat = message.Type == MessageType.groupchat;
            Username = IsGroupChat
                ? message.From.Resource
                : message.From.User;
        }
コード例 #48
0
ファイル: Program.cs プロジェクト: Dmdv/RemoteControl
        private static void SendChatMessage()
        {
            var msg = new Message
            {
                Type = MessageType.chat,
                To = new Jid("*****@*****.**"),
                Body = "Тестовое сообщение"
            };

            _xmppCon.Send(msg);
        }
コード例 #49
0
ファイル: Form1.cs プロジェクト: Reflej0/Chat_LoL
 private void button2_Click(object sender, EventArgs e) // Boton para enviar mensaje.
 {
     {
         agsXMPP.Jid JID = new Jid(ContactoSeleccionado);                             // Se crea un objeto tipo JID(usuario).
         agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message(); // Se crea un objeto tipo mensaje.
         msg.Type = MessageType.chat;                                                 // Se define el tipo de mensaje.
         msg.To   = JID;                                                              // Se define el destinatario.
         msg.Body = richTextBox1.Text;                                                // Se define el mensaje en sí.
         xmpp.Send(msg);                                                              // Se envía el mensaje.
     }
 }
コード例 #50
0
 public void Setup()
 {
     var to = new Jid("*****@*****.**");
     var from = new Jid("*****@*****.**");
     var msg = new Message(to, from, MessageType.groupchat, "slow clap");
     var eventObj = new GroupChatMessageArrived(msg, "testroom");
     _notifier = Substitute.For<IEventNotifier>();
     var handler = new GroupChatScriptHandler(_notifier);
     handler.ScriptFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "scripts");
     handler.Handle(eventObj);
 }
コード例 #51
0
ファイル: GameBot.cs プロジェクト: MagnusVortex/OCTGN
 public static void RefreshLists()
 {
     Trace.WriteLine("[Bot]RefreshList");
     var arr = _userList.ToArray();
     foreach(var u in arr)
     {
         var m = new Message(u , MessageType.normal , "" , "refresh");
         Xmpp.Send(m);
     }
     Trace.WriteLine("[Bot]RefreshListEnd");
 }
コード例 #52
0
 private void OnMessage4(object sender, agsXMPP.protocol.client.Message msg)
 {
     if (this.InvokeRequired)
     {
         this.BeginInvoke((Delegate) new MessageHandler(this.OnMessage4), sender, (object)msg);
     }
     else if (msg.Type == MessageType.groupchat && msg.From.Resource == "admin")
     {
         this.pictureBox5.Load(msg.Body.Replace("Enter the right answer to start chatting. ", ""));
     }
 }
コード例 #53
0
        private void cmdSend_Click(object sender, System.EventArgs e)
        {
            agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message();

            msg.Type = MessageType.chat;
            msg.To   = m_Jid;
            msg.Body = rtfSend.Text;

            _connection.Send(msg);
            OutgoingMessage(msg);
            rtfSend.Text = "";
        }
コード例 #54
0
 private void SendConfMessage(string message)
 {
     if (message.Length > 0)
     {
         agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message();
         msg.Type = MessageType.groupchat;
         msg.To   = roomJid;
         msg.Body = message;
         xmpp.Send(msg);
         textBoxSend.Clear();
     }
 }
コード例 #55
0
        public void XmppConnection_OnMessage(object sender, Message msg, object body)
        {
            if (!Client.AllPlayers.ContainsKey(msg.From.User) || string.IsNullOrWhiteSpace(msg.Body))
                return;

            var chatItem = Client.AllPlayers[msg.From.User];
            Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
            {
                if ((string)Client.ChatItem.PlayerLabelName.Content == chatItem.Username)
                    Update();
            }));
        }
コード例 #56
0
 public Message(agsXMPP.protocol.client.Message msg, DirectionTypes directionType, DateTime receivedTime)
 {
     this.InternalMessage  = msg;
     this.DateTimeReceived = receivedTime;
     this.DirectionType    = directionType;
     this.Unread           = (directionType == DirectionTypes.Incoming);
     this.MessageID        = Guid.NewGuid();
     this.InternalMessage  = msg;
     this.Replied          = false;
     base.Path             = MessageID.ToString();
     UpdateItemInfo();
 }
コード例 #57
0
        public void Process(Message message)
        {
            IMessageHandler[] messageHandlers = Array.FindAll(_messageHandlers, h => h.CanProcess(message));

            if (messageHandlers.Length > 0)
            {
                foreach (var handler in messageHandlers)
                {
                    handler.ProcessMessage(message);
                }
            }
        }
コード例 #58
0
        public void ProcessMessage(Message message)
        {
            MatchCollection matchCollection = _regEx.Matches(message.Body);

            ChatMember member = _directory.LookUp(message.From.Bare);

            foreach (var urlMatch in matchCollection)
            {
                LinkLog linkLog = new LinkLog {DateLogged = DateTime.Now, Url = urlMatch.ToString(), Sender = member};
                _linkLogger.SaveLog(linkLog);
            }
        }
コード例 #59
0
        private void cmdSend_Click(object sender, System.EventArgs e)
        {
            agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message();

            msg.Type = MessageType.chat;
            msg.To   = ownewrJid;
            msg.Body = rtfSend.Text;

            Util.XmppServices.XmppCon.Send(msg);
            OutgoingMessage(msg);
            rtfSend.Text = "";
        }
コード例 #60
0
        public void Foo()
        {
            LinkLoggerHandler handler = new LinkLoggerHandler(new MemberDirectory(), new LinkLogger());

            Assert.IsTrue(handler.CanProcess(new Message("*****@*****.**", "the is a www.google.com match")));
            Assert.IsTrue(handler.CanProcess(new Message("*****@*****.**", "the is a http://google.com match")));
            Message multiUrlMessage = new Message("*****@*****.**",
                                                  "the is a http://google.com www.cnn.com https://nyt.com match");
            Assert.IsTrue(handler.CanProcess(multiUrlMessage));
            Assert.IsFalse(handler.CanProcess(new Message("*****@*****.**", "this is not a processable message")));

            handler.ProcessMessage(multiUrlMessage);
        }