For IntelliJ IDEA,
Android Studio or Eclipse



/** * Creates a new presence with the given type and using the given XMPP address as recipient. * * @param to the recipient. * @param type the type. * @since 4.2 */ public Presence(Jid to, Type type) { this(type); setTo(to); }
Presence getJoinPresence(MultiUserChat multiUserChat) { final EntityFullJid jid = JidCreate.fullFrom(multiUserChat.getRoom(), nickname); joinPresence.setTo(jid); return joinPresence; }
Presence response = new Presence.Type.subscribed); response.setTo(address); sendPacket(response); Roster roster = mConnection.getRoster(); roster.createEntry(address, name, groups);
private void decline(String from) throws NotConnectedException { final Presence newp = new Presence(Presence.Type.unsubscribed); newp.setTo(from); connection.sendPacket(newp); }
/** * Handles the ?unsubscribe URI * * @param uri * the decoded uri */ public void handleUnsubscribe(URI uri) throws SmackException.NotConnectedException { String jid = retrieveJID(uri); Presence response = new Presence(Presence.Type.unsubscribe); response.setTo(jid); SparkManager.getConnection().sendStanza(response); }
/** * Send my presence for user * * @param jid * JID to send presence */ public void sendRealPresenceTo(String jid) throws SmackException.NotConnectedException { Presence presence = SparkManager.getWorkspace().getStatusBar().getPresence(); Presence pack = new Presence(presence.getType(), presence.getStatus(), 1, presence.getMode()); pack.setTo(jid); SparkManager.getConnection().sendStanza(pack); }
Presence presence = new Presence(Presence.Type.available); presence.setTo(roomJID); //Setting MaxStanzas to 0 MUCInitialPresence m = new MUCInitialPresence(); History h = new History(); h.setMaxStanzas(0); m.setHistory(h); presence.addExtension(m); try { connection.sendStanza(presence); } catch (NotConnectedException e) { }
/** * Send Unavailable (offline status) to jid . * * @param jid * JID to send offline status */ public void sendUnavailableTo(String jid) throws SmackException.NotConnectedException { Presence pack = new Presence(Presence.Type.unavailable); pack.setTo(jid); SparkManager.getConnection().sendStanza(pack); }
Presence presence = (Presence) packet; Presence presence_request = new Presence(Presence.Type.subscribed); presence_request.setTo(presence.getFrom()); presence_request.setType(Presence.Type.subscribed); presence_request.setFrom("current_logged_in_user"); connection.sendPacket(presence_request); roster.createEntry(presence.getFrom(), null, null);
public void sendSubscriptionRequest(BareJid jid) throws NotLoggedInException, NotConnectedException, InterruptedException { final XMPPConnection connection = getAuthenticatedConnectionOrThrow(); // Create a presence subscription packet and send. Presence presencePacket = new Presence(Presence.Type.subscribe); presencePacket.setTo(jid); connection.sendStanza(presencePacket); }
private void accept(String from) throws NotConnectedException { final Presence newp = new Presence(Presence.Type.subscribed); newp.setTo(from); connection.sendPacket(newp); final Presence subscription = new Presence(Presence.Type.subscribe); subscription.setTo(from); connection.sendPacket(subscription); if (api.isOnline()) { api.setOnline(); } }
if(selectedRoster != null) { Presence presence = new Presence(Presence.Type.unsubscribe); presence.setTo(selectedRoster.getUser()); presence.setStatus("Offline"); presence.setShow("unavailable"); ConnectionController.GetInstance(this).getXMPPConnection().sendPacket(presence); try { roster.removeEntry(selectedRoster); } catch (XMPPException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
//subscribe to eachother connection.login("tester", ...); Presence subscribe = new Presence(Presence.Type.subscribe); subscribe.setTo("sanika@sanika.com"); connection.sendPacket(subscribe); connection.disconnect(); ... connection.connect(); connection.login("sanika", ...); subscribe = new Presence(Presence.Type.subscribe); subscribe.setTo("tester@localhost"); connection.sendPacket(subscribe); connection.disconnect();
Presence subscription = new Presence( Presence.Type.subscribe); subscription.setTo(CurrentUser+"@reza-hp"); subscription.setPriority(24); newp.setMode(Presence.Mode.available); connection.sendPacket(subscription);
Presence getJoinPresence(MultiUserChat multiUserChat) { final EntityFullJid jid = JidCreate.fullFrom(multiUserChat.getRoom(), nickname); joinPresence.setTo(jid); return joinPresence; }