public void TestMessageGrabber() { Presence presence = new Presence(ShowType.Show); int waitMessage = 20000; string msg = "hello"; string expected = partnerJid + ":hello"; JabberID jidPartner = new JabberID(partnerJid); Message message = new Message(myJid, jidPartner.Full, msg); XmppClientConnection connection = new XmppClientConnection( new JabberID(myJid), password); connection.MessageGrabber.Add( jidPartner, new MessageCallback(messageCallback)); connection.Login(); connection.Send(presence); connection.Send(message); while (partnerMessage == null) { Thread.Sleep(2000); } Assert.AreEqual(expected, partnerMessage); }
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); }
/// <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); }
private void xmpp_OnLogin(object sender) { Presence p = new Presence(); p.Status = this.CustomMessage; xmpp.Send(p); }
private void connected(object sender) { string[] mc = Messages.Lines; Nizzc_Mobile_Ser.Form1.mta = Nizzc_Mobile_Ser.Form1.mta + 1; x1.Send(new agsXMPP.protocol.client.Message(new Jid(this.sender1 + "@nimbuzz.com"), MessageType.chat, mc[18].Replace("[MESSAGE]$", "").Replace("%L%", Environment.NewLine))); x1.Send(new agsXMPP.protocol.client.Message(new Jid(this.sender1 + "@nimbuzz.com"), MessageType.chat, mc[38].Replace("[MESSAGE]$", "").Replace("%L%", Environment.NewLine))); }
public void SendPresence() { var status = new LeagueStatus(StatusMessage, Status); ShowType computed; if (DndStatuses.Contains(Status)) { computed = ShowType.dnd; } else if (ChatMode == ChatMode.Away) { computed = ShowType.away; } else { computed = ShowType.chat; } var args = new StatusUpdatedEventArgs(status, ChatMode == ChatMode.Invisible ? PresenceType.invisible : PresenceType.available, computed); StatusUpdated?.Invoke(this, args); if (!connected) { return; } xmpp.Send(new Presence(computed, status.ToXML(), 100) { Type = args.PresenceType }); }
public void SendMessage(string to, string body) { var friend = friends[to]; xmpp.Send(new Message(friend.Jid, MessageType.chat, body)); OnMessage(new ChatMessage(to, body)); }
public void TestSendPresenceAndMessage() { //Logger logger = LogManager.GetLogger("foo"); ILogger log = NLog.LogManager.GetLogger("foo"); log.Info("Program started"); Presence presence = new Presence(ShowType.Show); JabberID from = new JabberID(myJid); JabberID to = new JabberID(partnerJid); string msg = "Hello"; Message message = new Message(from, to, msg); XmppClientConnection connection = new XmppClientConnection( new JabberID(myJid), password); connection.Login(); if (!connection.Connected || !connection.Authenticated) { throw new Exception("Not authenticate"); } Assert.DoesNotThrow(() => { connection.Send(presence); }); Assert.DoesNotThrow(() => { connection.Send(message); }); //NLogger.ShutdownLogger(); }
/// <summary> /// Send a document, ignore the response (but wait shortly for a possible error) /// </summary> /// <param name="document">Document</param> /// <param name="waitTimeout">the time to wait for a possible error, if this is too small errors are ignored.</param> /// <returns>Task to await on</returns> private async Task FireAndForgetAsync(Document document, int waitTimeout = 50) { // Check if the login was made, this blocks until there is a state // And throws an exception if the login failed. await _loginTaskCompletionSource.Task.ConfigureAwait(false); // Create the IQ to send var iqToSend = GenerateIq(document); // Prepate the TaskCompletionSource, which is used to await the result var resultTaskCompletionSource = new TaskCompletionSource <IQ>(); _resultTaskCompletionSources[iqToSend.Id] = resultTaskCompletionSource; Debug.WriteLine("Sending (ignoring response):"); Debug.WriteLine(iqToSend.ToString()); // Start the sending _xmpp.Send(iqToSend); // Await, to make sure there wasn't an error var task = await Task.WhenAny(resultTaskCompletionSource.Task, Task.Delay(waitTimeout)).ConfigureAwait(false); // Remove the result task, as we no longer need it. _resultTaskCompletionSources.Remove(iqToSend.Id); // This makes sure the exception, if there was one, is unwrapped await task; }
public void SendGameReady(HostedGameData game) { var m = new Message(game.Username + "@of.octgn.net", MessageType.normal, "", "gameready"); m.GenerateId(); m.AddChild(game); _xmpp.Send(m); }
private void OnFailed(object sender, Element e) { try { dcch = "off"; x1.Send(new agsXMPP.protocol.client.Message(new agsXMPP.Jid(sender1 + "@nimbuzz.com"), agsXMPP.protocol.client.MessageType.chat, "Your Credential is not valid.")); } catch { } }
private void SendStreamHostUsedResponse(StreamHost sh, IQ iq) { ByteStreamIq bsIQ = new ByteStreamIq(IqType.result, m_From); bsIQ.Id = iq.Id; bsIQ.Query.StreamHostUsed = new StreamHostUsed(sh.Jid); m_XmppCon.Send(bsIQ); }
/// <summary> /// Subscribe to a contact /// </summary> /// <param name="to">Bare Jid of the rosteritem we want to subscribe</param> public void Subscribe(Jid to) { // <presence to='*****@*****.**' type='subscribe'/> Presence pres = new Presence(); pres.Type = PresenceType.subscribe; pres.To = to; m_connection.Send(pres); }
private void OnFailed(object sender, Element e) { try { string[] mc = Messages.Lines; x1.Send(new agsXMPP.protocol.client.Message(new agsXMPP.Jid(owner + "@nimbuzz.com"), agsXMPP.protocol.client.MessageType.chat, mc[24].Replace("[MESSAGE]$", "").Replace("%ID%", this.ID).Replace("%L%", Environment.NewLine).Replace("%thisid%", x.Username).Replace("%er%", "[No error]").Replace("%thread%", "[No thread]").Replace("%IP%", "[No IP]")));//mc[30].Replace("[MESSAGE]$", "") reconnectable = false; } catch { } }
public void sendMessage(string jid, string message, MessageType type) { Message msg = new Message(new Jid(jid), type, message); if (thread != null) { msg.Thread = thread; } client.Send(msg); }
private void subscrib( ) { Presence sub = new Presence(); sub.Status = "online"; sub.Type = PresenceType.subscribe; holder.Id = Guid.NewGuid().ToString(); sub.Id = holder.Id; sub.To = ServerJid; sub.From = LocalJid; XmppConnection.Send(sub); }
private void frmGroupChat_Load(object sender, EventArgs e) { if (m_RoomJid != null) { Presence pres = new Presence(); Jid to = new Jid(m_RoomJid.ToString()); to.Resource = m_Nickname; pres.To = to; m_XmppCon.Send(pres); } }
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(); } }
public Message SendMessage(Room room, string message) { var msg = new Message(room.Roomname, _xmpp.MyJID, MessageType.groupchat, message) { Id = Guid.NewGuid().ToString(), Chatstate = Chatstate.active }; _xmpp.Send(msg); return(msg); }
/// <summary> /// Request the bookmarks from the storage on the server /// </summary> /// <param name="cb"></param> /// <param name="cbArgs"></param> public void RequestBookmarks(IqHandler cb) { StorageIq siq = new StorageIq(IqType.get); if (cb == null) { m_connection.Send(siq); } else { m_connection.IqGrabber.SendIq(siq, cb); } }
public override async Task Send(Envelope envelope, params string[] messages) { await base.Send(envelope, messages); if (_confServer.HasValue() && envelope.User.Room.Contains(_confServer)) { _xmppConnection.Send(new agsXMPP.protocol.client.Message(envelope.User.Room, MessageType.groupchat, string.Join(Environment.NewLine, messages))); } else { _xmppConnection.Send(new agsXMPP.protocol.client.Message(new Jid(envelope.User.Name), MessageType.chat, string.Join(Environment.NewLine, messages))); } }
/// <summary> /// Request the bookmarks from the storage on the server /// </summary> /// <param name="cb"></param> /// <param name="cbArgs"></param> public void RequestBookmarks(IqCB cb, object cbArgs) { StorageIq siq = new StorageIq(IqType.get); if (cb == null) { m_connection.Send(siq); } else { m_connection.IqGrabber.SendIq(siq, cb, cbArgs); } }
public override Task Send(Envelope envelope, AdapterArguments adapterArgs, params string[] messages) { if (_confServer.HasValue() && envelope.User.Room.Contains(_confServer)) { _xmppConnection.Send(new agsXMPP.protocol.client.Message(envelope.User.Room, MessageType.groupchat, string.Join(Environment.NewLine, messages))); } else { _xmppConnection.Send(new agsXMPP.protocol.client.Message(new Jid(envelope.User.Name), MessageType.chat, string.Join(Environment.NewLine, messages))); } return(Task.FromResult(0)); }
/// <summary> /// Removes a Rosteritem from the Roster /// </summary> /// <param name="jid">The BARE jid of the rosteritem that should be removed</param> public void RemoveRosterItem(Jid jid) { RosterIq riq = new RosterIq(); riq.Type = IqType.set; RosterItem ri = new RosterItem(); ri.Jid = jid; ri.Subscription = SubscriptionType.remove; riq.Query.AddRosterItem(ri); m_connection.Send(riq); }
public override async Task Send(Envelope envelope, params string[] messages) { await base.Send(envelope, messages); if (messages == null || !messages.Any()) { return; } foreach (var message in messages) { var to = new Jid(envelope.User.Room); _client.Send(new agsXMPP.protocol.client.Message(to, string.Equals(to.Server, _confhost) ? MessageType.groupchat : MessageType.chat, message)); } }
public override void Init(XmppClientConnection con) { XmppClientConnection = con; string kerbPrinc = XmppClientConnection.KerberosPrincipal; /* * try to build the kerberos principal if none is sent by the server or provided by the user. * XCP send the kerberos pricipal, Openfire doesnt. */ if (kerbPrinc == null) kerbPrinc = string.Format("xmpp/{0}@{1}", XmppClientConnection.Server, GetNtDomain()); //if (XmppClientConnection.KerberosPrincipal != null) // sspiHelper = new SSPIHelper(XmppClientConnection.KerberosPrincipal); //else // sspiHelper = new SSPIHelper(); sspiHelper = new SSPIHelper(kerbPrinc); Auth auth = new Auth(MechanismType.GSSAPI); byte[] clientToken; sspiHelper.Process(null, out clientToken); auth.Value = Convert.ToBase64String(clientToken); XmppClientConnection.Send(auth); }
public override void Parse(Node e) { if (e is Challenge) { Challenge c = e as Challenge; Response resp; byte[] outBytes; byte[] inBytes = Convert.FromBase64String(c.Value); sspiHelper.Process(inBytes, out outBytes); if (outBytes == null) { resp = new Response(); } else { resp = new Response(); resp.Value = Convert.ToBase64String(outBytes); } XmppClientConnection.Send(resp); } }
public override void Init(XmppClientConnection con) { XmppClientConnection = con; string kerbPrinc = XmppClientConnection.KerberosPrincipal; /* * try to build the kerberos principal if none is sent by the server or provided by the user. * XCP send the kerberos pricipal, Openfire doesnt. */ if (kerbPrinc == null) { kerbPrinc = string.Format("xmpp/{0}@{1}", XmppClientConnection.Server, GetNtDomain()); } //if (XmppClientConnection.KerberosPrincipal != null) // sspiHelper = new SSPIHelper(XmppClientConnection.KerberosPrincipal); //else // sspiHelper = new SSPIHelper(); sspiHelper = new SSPIHelper(kerbPrinc); Auth auth = new Auth(MechanismType.GSSAPI); byte[] clientToken; sspiHelper.Process(null, out clientToken); auth.Value = Convert.ToBase64String(clientToken); XmppClientConnection.Send(auth); }
/// <summary> /// make outgoing Jingle Session /// </summary> /// <param name="xmppClient"></param> /// <param name="to"></param> /// <param name="fileName"></param> /// <param name="proxy"></param> /// <param name="proxyPort"></param> public JingleSession(XmppClientConnection xmppClient, string to, string fileName, string proxy, string proxyPort) { selfInitiated = true; localFilespec = fileName; this.conn = xmppClient; iq_to = new Jid(to); iq_from = Program.Jabber.conn.MyJID; content_name = Guid.NewGuid().ToString(); jingle_initiator = iq_from; jingle_sid = Guid.NewGuid().ToString(); transportSid = Guid.NewGuid().ToString(); initiateIq = BuildSessionInitiate(fileName); this.initiateJingle = initiateIq.SelectSingleElement("jingle"); this.contentIn = initiateJingle.SelectSingleElement("content"); this.transportIn = contentIn.SelectSingleElement("transport"); Element candidate = new Element("candidate"); candidate.SetAttribute("priority", "999999"); candidate.SetAttribute("jid", proxy); candidate.SetAttribute("cid", "1000"); candidate.SetAttribute("type", "proxy"); candidate.SetAttribute("host", proxy); candidate.SetAttribute("port", proxyPort); transportIn.AddChild(candidate); conn.Send(initiateIq); }
private void XmppCon_OnIq(object sender, IQ iq) { if (InvokeRequired) { // Windows Forms are not Thread Safe, we need to invoke this :( // We're not in the UI thread, so we need to call BeginInvoke BeginInvoke(new IqHandler(XmppCon_OnIq), new object[] { sender, iq }); return; } Element query = iq.Query; if (query != null) { if (query.GetType() == typeof(agsXMPP.protocol.iq.version.Version)) { // its a version IQ VersionIQ agsXMPP.protocol.iq.version.Version version = query as agsXMPP.protocol.iq.version.Version; if (iq.Type == IqType.get) { // Somebody wants to know our client version, so send it back iq.SwitchDirection(); iq.Type = IqType.result; version.Name = "MiniClient"; version.Ver = "0.5"; version.Os = Environment.OSVersion.ToString(); XmppCon.Send(iq); } } } }
public void Send(string _text) { Message m = new Message(Parameters[SendAddress], _text); m.Type = MessageType.chat; xmpp.Send(m); }
public override void Init(XmppClientConnection con) { XmppClientConnection = con; // Todo SASLPrep username = Username; password = Password; firstClientMessage = GenerateFirstClientMessage(); string msg = ToB64String(firstClientMessage); con.Send(new Auth(MechanismType.SCRAM_SHA_1, msg)); }
/// <summary> /// /// </summary> /// <param name="con"></param> public override void Init(XmppClientConnection con) { base.XmppClientConnection = con; con.Send(new Auth(MechanismType.X_FACEBOOK_PLATFORM)); }
/* S: <stream:features> <mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'> <mechanism>DIGEST-MD5<mechanism> <mechanism>ANONYMOUS<mechanism> </mechanisms> </stream:features> * So, the proper exchange for this ANONYMOUS mechanism would be: C: <auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='ANONYMOUS'/> S: <success xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/> or, in case of the optional trace information: C: <auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='ANONYMOUS'> c2lyaGM= </auth> S: <success xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/> */ /// <summary> /// /// </summary> /// <param name="con"></param> public override void Init(XmppClientConnection con) { con.Send(new Auth(MechanismType.ANONYMOUS)); }
static void Main(string[] args) { PostRequest req = new PostRequest("http://94.236.31.135/http-bind/", ""); req.Type = PostRequest.PostTypeEnum.Post; string postData = ""; postData += "Referer: http://static13.cdn.ubi.com/settlers_online/live/de/L4230DE/SWMMO/debug/SWMMO.swf"; postData += "Content-type: text/xml"; postData += "Content-length: 189"; postData += "<body secure=\"false\" wait=\"20\" hold=\"1\" xml:lang=\"en\" xmlns=\"http://jabber.org/protocol/httpbind\" xmpp:version=\"1.0\" rid=\"365714\" ver=\"1.6\" xmlns:xmpp=\"urn:xmpp:xbosh\" to=\"94.236.31.135\" />"; var response = req.PostData(postData); /* * Starting Jabber Console, setting the Display settings * */ Console.Title = "Jabber Test"; Console.ForegroundColor = ConsoleColor.White; /* * Login * */ Console.WriteLine("Login"); Console.WriteLine(); Console.WriteLine("JID: "); string JID_Sender = Console.ReadLine(); Console.WriteLine("Password: "******"Wait for Login "); int i = 0; _wait = true; do { Console.Write("."); i++; if (i == 10) _wait = false; Thread.Sleep(500); } while (_wait); Console.WriteLine(); /* * * just reading a few information * */ Console.WriteLine("Login Status:"); Console.WriteLine("xmpp Connection State {0}", xmpp.XmppConnectionState); Console.WriteLine("xmpp Authenticated? {0}", xmpp.Authenticated); Console.WriteLine(); /* * * tell the world we are online and in chat mode * */ Console.WriteLine("Sending Precence"); Presence p = new Presence(ShowType.chat, "Online"); p.Type = PresenceType.available; xmpp.Send(p); Console.WriteLine(); /* * * get the roster (see who's online) */ xmpp.OnPresence += new PresenceHandler(xmpp_OnPresence); //wait until we received the list of available contacts Console.WriteLine(); Thread.Sleep(500); /* * now we catch the user entry, TODO: who is online */ Console.WriteLine("Enter Chat Partner JID:"); string JID_Receiver = Console.ReadLine(); Console.WriteLine(); /* * Chat starts here */ Console.WriteLine("Start Chat"); /* * Catching incoming messages in * the MessageCallBack */ xmpp.MessageGrabber.Add(new Jid(JID_Receiver), new BareJidComparer(), new MessageCB(MessageCallBack), null); /* * Sending messages * */ string outMessage; bool halt = false; do { Console.ForegroundColor = ConsoleColor.Green; outMessage = Console.ReadLine(); if (outMessage == "q!") { halt = true; } else { xmpp.Send(new Message(new Jid(JID_Receiver), MessageType.chat, outMessage)); } } while (!halt); Console.ForegroundColor = ConsoleColor.White; /* * finally we close the connection * */ xmpp.Close(); }