public void Start()
 {
     xmppServer = new XmppServer();
     JabberConfiguration.Configure(xmppServer);
     xmppServer.StartListen();
     host = new ServiceHost(new JabberService(xmppServer));
     host.Open();
 }
예제 #2
0
 protected override XElement ProcessRequest(XmppServer server, Jid jid, NameValueCollection values)
 {
     var user = values["user"];
     if (!string.IsNullOrEmpty(user))
     {
         jid = GetJid(user);
     }
     var session = server.SessionManager.GetSession(jid);
     return new XElement("availible", session != null && session.Available);
 }
예제 #3
0
 public void Stop()
 {
     if (xmppServer != null)
     {
         xmppServer.StopListen();
         xmppServer = null;
     }
     if (host != null)
     {
         host.Close();
         host = null;
     }
 }
예제 #4
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");
        }
예제 #5
0
 public JabberService(XmppServer xmppServer)
 {
     _xmppServer = xmppServer;
     _reverseJabberServiceClient = new ReverseJabberServiceClient();
 }
예제 #6
0
 public JabberService(XmppServer xmppServer)
 {
     _xmppServer = xmppServer;
     signalrServiceClient = new SignalrServiceClient();
 }
예제 #7
0
 protected override XElement ProcessRequest(XmppServer server, Jid jid, NameValueCollection values)
 {
     return new XElement("unread", server.StorageManager.OfflineStorage.GetOfflineMessagesCount(jid));
 }
예제 #8
0
 protected override XElement ProcessRequest(XmppServer server, Jid jid, NameValueCollection values)
 {
     return new XElement("token", server.AuthManager.GetUserToken(jid.User));
 }
예제 #9
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");
        }
예제 #10
0
 protected abstract XElement ProcessRequest(XmppServer server, Jid username, NameValueCollection values);
예제 #11
0
 public JabberService(XmppServer xmppServer)
 {
     this.xmppServer = xmppServer;
     CurrentXmppServer = xmppServer;
 }