Beispiel #1
0
        protected override XElement ProcessRequest(XmppServer server, Jid jid, NameValueCollection values)
        {
            var to = values["to"];
            var subject = values["subject"];
            var text = values["message"];

            if (!string.IsNullOrEmpty(to) && !string.IsNullOrEmpty(text))
            {
                var jidTo = GetJid(to);
                text = ModifyJabberNotification(text);
                var message = new Message(
                    jidTo,
                    new Jid(CoreContext.TenantManager.GetCurrentTenant().TenantDomain),
                    MessageType.headline,
                    text,
                    subject ?? "") { XDelay = new Delay() { Stamp = DateTime.UtcNow } };

                var session = server.SessionManager.GetSession(jid);
                if (session != null)
                {
                    var sender = (IXmppSender)server.GetService(typeof(IXmppSender));
                    sender.SendTo(session, message);
                }
                else
                {
                    server.StorageManager.OfflineStorage.SaveOfflineMessages(message);
                }
                var archive = server.StorageManager.GetStorage<DbMessageArchive>("archive");
                if (archive != null) archive.SaveMessages(message);
            }
            else
            {
                throw new ArgumentException("argument count mismatch");
            }
            return new XElement("ok");
        }
Beispiel #2
0
        protected override XElement ProcessRequest(XmppServer server, Jid jid, NameValueCollection values)
        {
            var to = values["to"];
            var from = values["from"];
            var command = values["command"];
            if (string.IsNullOrEmpty(from) || string.IsNullOrEmpty(to) || string.IsNullOrEmpty(command)) throw new ArgumentException("argument count mismatch");

            var jidTo = GetJid(to);
            var iq = new IQ(IqType.set, GetJid(from), jidTo)
            {
                Query = new Command(command)
            };

            var session = server.SessionManager.GetSession(jidTo);
            if (session != null)
            {
                var sender = (IXmppSender)server.GetService(typeof(IXmppSender));
                sender.SendTo(session, iq);
            }
            return new XElement("ok");
        }