public void Start() { xmppServer = new XmppServer(); JabberConfiguration.Configure(xmppServer); xmppServer.StartListen(); host = new ServiceHost(new JabberService(xmppServer)); host.Open(); }
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); }
public void Stop() { if (xmppServer != null) { xmppServer.StopListen(); xmppServer = null; } if (host != null) { host.Close(); host = null; } }
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"); }
public JabberService(XmppServer xmppServer) { _xmppServer = xmppServer; _reverseJabberServiceClient = new ReverseJabberServiceClient(); }
public JabberService(XmppServer xmppServer) { _xmppServer = xmppServer; signalrServiceClient = new SignalrServiceClient(); }
protected override XElement ProcessRequest(XmppServer server, Jid jid, NameValueCollection values) { return new XElement("unread", server.StorageManager.OfflineStorage.GetOfflineMessagesCount(jid)); }
protected override XElement ProcessRequest(XmppServer server, Jid jid, NameValueCollection values) { return new XElement("token", server.AuthManager.GetUserToken(jid.User)); }
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"); }
protected abstract XElement ProcessRequest(XmppServer server, Jid username, NameValueCollection values);
public JabberService(XmppServer xmppServer) { this.xmppServer = xmppServer; CurrentXmppServer = xmppServer; }