Java Code Examples for org.jivesoftware.smackx.muc.MultiUserChat#isJoined()
The following examples show how to use
org.jivesoftware.smackx.muc.MultiUserChat#isJoined() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XSCHelper.java From PracticeCode with Apache License 2.0 | 5 votes |
/** * 发送信息到云同步室 * * @param room 云同步室 * @param msg 将要发送的信息 */ public void sendProjChromMsg(MultiUserChat room, Object msg) { if (!room.isJoined()) return; try { Message message = new Message(room.getRoom(), Message.Type.groupchat); message.setBody(SysUtil.getInstance().getDateAndTimeFormated()); message.setProperty(MSGCLOUD, msg); room.sendMessage(message); } catch (XMPPException e) { e.printStackTrace(); } }
Example 2
Source File: ConferenceUtils.java From Spark with Apache License 2.0 | 5 votes |
/** * Joins a chat room without using the UI. * * @param groupChat the <code>MultiUserChat</code> * @param nickname the nickname of the user. * @param password the password to join the room with. * @return a List of errors, if any. */ public static List<String> joinRoom(MultiUserChat groupChat, Resourcepart nickname, String password) { final List<String> errors = new ArrayList<>(); if ( !groupChat.isJoined() ) { try { if ( ModelUtil.hasLength( password ) ) { groupChat.join( nickname, password ); } else { groupChat.join( nickname ); } changePresenceToAvailableIfInvisible(); } catch ( XMPPException | SmackException | InterruptedException ex ) { StanzaError error = null; if ( ex instanceof XMPPException.XMPPErrorException ) { error = ( (XMPPException.XMPPErrorException) ex ).getStanzaError(); } final String errorText = ConferenceUtils.getReason( error ); errors.add( errorText ); } } return errors; }
Example 3
Source File: UserInvitationPane.java From Spark with Apache License 2.0 | 4 votes |
/** * Removes oneself as an owner of the room. * * @param muc the <code>MultiUserChat</code> of the chat room. */ private void removeOwner(MultiUserChat muc) { if (muc.isJoined()) { // Try and remove myself as an owner if I am one. Collection<Affiliate> owners = null; try { owners = muc.getOwners(); } catch (XMPPException | SmackException | InterruptedException e1) { return; } if (owners == null) { return; } Iterator<Affiliate> iter = owners.iterator(); List<Jid> list = new ArrayList<>(); while (iter.hasNext()) { Affiliate affilitate = iter.next(); Jid jid = affilitate.getJid(); if (!jid.equals(SparkManager.getSessionManager().getBareUserAddress())) { list.add(jid); } } if (list.size() > 0) { try { Form form = muc.getConfigurationForm().createAnswerForm(); List<String> jidStrings = JidUtil.toStringList(list); form.setAnswer("muc#roomconfig_roomowners", jidStrings); // new DataFormDialog(groupChat, form); muc.sendConfigurationForm(form); } catch (XMPPException | SmackException | InterruptedException e) { Log.error(e); } } } }
Example 4
Source File: InvitationPane.java From Spark with Apache License 2.0 | 4 votes |
/** * Removes oneself as an owner of the room. * * @param muc the <code>MultiUserChat</code> of the chat room. */ private void removeOwner(MultiUserChat muc) { if (muc.isJoined()) { // Try and remove myself as an owner if I am one. Collection owners = null; try { owners = muc.getOwners(); } catch (XMPPException | SmackException | InterruptedException e1) { return; } if (owners == null) { return; } Iterator iter = owners.iterator(); List<Jid> list = new ArrayList<>(); while (iter.hasNext()) { Affiliate affilitate = (Affiliate)iter.next(); Jid jid = affilitate.getJid(); if (!jid.equals(SparkManager.getSessionManager().getBareUserAddress())) { list.add(jid); } } if (list.size() > 0) { try { Form form = muc.getConfigurationForm().createAnswerForm(); List<String> jidStrings = new ArrayList<>(list.size()); JidUtil.toStrings(list, jidStrings); form.setAnswer("muc#roomconfig_roomowners", jidStrings); // new DataFormDialog(groupChat, form); muc.sendConfigurationForm(form); } catch (XMPPException | SmackException | InterruptedException e) { Log.error(e); } } } }