当前位置: 首页>>代码示例>>Java>>正文


Java MultiUserChat.isJoined方法代码示例

本文整理汇总了Java中org.jivesoftware.smackx.muc.MultiUserChat.isJoined方法的典型用法代码示例。如果您正苦于以下问题:Java MultiUserChat.isJoined方法的具体用法?Java MultiUserChat.isJoined怎么用?Java MultiUserChat.isJoined使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jivesoftware.smackx.muc.MultiUserChat的用法示例。


在下文中一共展示了MultiUserChat.isJoined方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: join

import org.jivesoftware.smackx.muc.MultiUserChat; //导入方法依赖的package包/类
public MultiUserChat join(JabberClient client, JabberPlayer me) throws XMPPException {
  MultiUserChat chat = new MultiUserChat(client.getConnection(), getJID());
  chat.join(StringUtils.parseName(me.getJid()));

  if (!chat.isJoined()) {
    return null;
  }

  try {
    // This is necessary to create the room if it doesn't already exist
    // Configure the options we needs explicitly, don't depend on the server supplied defaults
    final Form configForm = chat.getConfigurationForm().createAnswerForm();
    configForm.setAnswer(JABBER_MEMBERSONLY, isStartLocked());
    configForm.setAnswer(JABBER_ALLOW_INVITES, false);
    configForm.setAnswer(JABBER_CHANGE_SUBJECT, false);
    configForm.setAnswer(JABBER_MODERATED, false);
    configForm.setAnswer(JABBER_PASSWORD_PROTECTED, false);
    configForm.setAnswer(JABBER_PERSISTENT, false);
    configForm.setAnswer(JABBER_PUBLIC_ROOM, true);

    chat.sendConfigurationForm(configForm);
    ownedByMe = true;
    owners.clear();
    addOwner(jid);
  }
  catch (XMPPException e) {
    // 403 code means the room already exists and user is not an owner
    if (e.getXMPPError() != null && e.getXMPPError().getCode() != 403) {
      throw e;
    }
  }

  chat.addMessageListener(client);
  return chat;
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:36,代码来源:JabberRoom.java

示例2: sendProjChromMsg

import org.jivesoftware.smackx.muc.MultiUserChat; //导入方法依赖的package包/类
/**
 * 发送信息到云同步室
 *
 * @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();
    }
}
 
开发者ID:lfkdsk,项目名称:PracticeCode,代码行数:19,代码来源:XSCHelper.java

示例3: removeOwner

import org.jivesoftware.smackx.muc.MultiUserChat; //导入方法依赖的package包/类
/**
 * 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 e1) {
            return;
        }

        if (owners == null) {
            return;
        }

        Iterator<Affiliate> iter = owners.iterator();

        List<String> list = new ArrayList<String>();
        while (iter.hasNext()) {
            Affiliate affilitate = iter.next();
            String jid = affilitate.getJid();
            if (!jid.equals(SparkManager.getSessionManager().getBareAddress())) {
                list.add(jid);
            }
        }
        if (list.size() > 0) {
            try {
                Form form = muc.getConfigurationForm().createAnswerForm();
                form.setAnswer("muc#roomconfig_roomowners", list);

                // new DataFormDialog(groupChat, form);
                muc.sendConfigurationForm(form);
            }
            catch (XMPPException e) {
                Log.error(e);
            }
        }
    }
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:45,代码来源:UserInvitationPane.java

示例4: removeOwner

import org.jivesoftware.smackx.muc.MultiUserChat; //导入方法依赖的package包/类
/**
 * 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 e1) {
            return;
        }

        if (owners == null) {
            return;
        }

        Iterator iter = owners.iterator();

        List list = new ArrayList();
        while (iter.hasNext()) {
            Affiliate affilitate = (Affiliate)iter.next();
            String jid = affilitate.getJid();
            if (!jid.equals(SparkManager.getSessionManager().getBareAddress())) {
                list.add(jid);
            }
        }
        if (list.size() > 0) {
            try {
                Form form = muc.getConfigurationForm().createAnswerForm();
                form.setAnswer("muc#roomconfig_roomowners", list);

                // new DataFormDialog(groupChat, form);
                muc.sendConfigurationForm(form);
            }
            catch (XMPPException e) {
                Log.error(e);
            }
        }
    }
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:45,代码来源:InvitationPane.java

示例5: post

import org.jivesoftware.smackx.muc.MultiUserChat; //导入方法依赖的package包/类
public void post(FirehoseMessage firehoseMessage) {
    logger.info("Publish message " + firehoseMessage.toLogString());

    if (!chat_service.equals(firehoseMessage.service)) {
        logger.info(
                MessageFormat.format(
                        "Ignore because message service {0} does not match service {1}",
                        firehoseMessage.service,
                        chat_service
                                    )
                   );
        return;
    }

    if (!connectedRooms.containsKey(firehoseMessage.channel)) {
        logger.info(
                MessageFormat.format(
                        "Ignore because message channel {0} does not match connected channels",
                        firehoseMessage.channel
                                    )
                   );
        return;
    }
    MultiUserChat chat = connectedRooms.get(firehoseMessage.channel);
    if (!chat.isJoined()) {
        logger.warn(
                MessageFormat.format(
                        "Chat {0}@{1} is not joined",
                        firehoseMessage.service,
                        firehoseMessage.channel
                                    )
                   );
        try {
            chat.join(chat.getNickname());
        } catch (XMPPException e) {
            logger.error(
                    MessageFormat.format("Error connecting to chatroom {0} at service {1} with username {2}. Message: {3}",
                                         chat.getRoom(),
                                         service_domain,
                                         username,
                                         e.getMessage()
                                        ));
            return;
        }
    }

    if (resource_per_user) {
        postAsUser(chat, firehoseMessage);
    } else {
        postDefaultMessage(chat, firehoseMessage);
    }
}
 
开发者ID:dmitriid,项目名称:tetrad,代码行数:53,代码来源:TetradXMPP.java

示例6: joinRoom

import org.jivesoftware.smackx.muc.MultiUserChat; //导入方法依赖的package包/类
/**
 * 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, String nickname, String password) {
    final List<String> errors = new ArrayList<String>();
    if (!groupChat.isJoined()) {
        int groupChatCounter = 0;
        while (true) {
            groupChatCounter++;
            String joinName = nickname;
            if (groupChatCounter > 1) {
                joinName = joinName + groupChatCounter;
            }
            if (groupChatCounter < 10) {
                try {
                    if (ModelUtil.hasLength(password)) {
                        groupChat.join(joinName, password);
                    }
                    else {
                        groupChat.join(joinName);
                    }
                    break;
                }
                catch (XMPPException ex) {
                    int code = 0;
                    if (ex.getXMPPError() != null) {
                        code = ex.getXMPPError().getCode();
                    }

                    if (code == 0) {
                        errors.add("No response from server.");
                    }
                    else if (code == 401) {
                        errors.add("A Password is required to enter this room.");
                    }
                    else if (code == 403) {
                        errors.add("You have been banned from this room.");
                    }
                    else if (code == 404) {
                        errors.add("The room you are trying to enter does not exist.");
                    }
                    else if (code == 407) {
                        errors.add("You are not a member of this room.\nThis room requires you to be a member to join.");
                    }
                    else if (code != 409) {
                        break;
                    }
                }
            }
            else {
                break;
            }
        }
    }

    return errors;
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:63,代码来源:ConferenceUtils.java

示例7: enterRoom

import org.jivesoftware.smackx.muc.MultiUserChat; //导入方法依赖的package包/类
public static void enterRoom(final MultiUserChat groupChat, String tabTitle, final String nickname, final String password) {
    final GroupChatRoom room = UIComponentRegistry.createGroupChatRoom(groupChat);
    room.setTabTitle(tabTitle);

    final List<String> errors = new ArrayList<String>();

    if (!groupChat.isJoined()) {
        int groupChatCounter = 0;
        while (true) {
            groupChatCounter++;
            String joinName = nickname;
            if (groupChatCounter > 1) {
                joinName = joinName + groupChatCounter;
            }
            if (groupChatCounter < 10) {
                try {
                    if (ModelUtil.hasLength(password)) {
                        groupChat.join(joinName, password);
                    }
                    else {
                        groupChat.join(joinName);
                    }
                    break;
                }
                catch (XMPPException ex) {
                    int code = 0;
                    if (ex.getXMPPError() != null) {
                        code = ex.getXMPPError().getCode();
                    }

                    if (code == 0) {
                        errors.add("No response from server.");
                    }
                    else if (code == 401) {
                        errors.add("A Password is required to enter this room.");
                    }
                    else if (code == 403) {
                        errors.add("You have been banned from this room.");
                    }
                    else if (code == 404) {
                        errors.add("The room you are trying to enter does not exist.");
                    }
                    else if (code == 407) {
                        errors.add("You are not a member of this room.\nThis room requires you to be a member to join.");
                    }
                    else if (code != 409) {
                        break;
                    }
                }
            }
            else {
                break;
            }
        }
    }

    if (errors.size() > 0) {
        String error = errors.get(0);
        JOptionPane.showMessageDialog(SparkManager.getMainWindow(), error, "Could Not Join Room", JOptionPane.ERROR_MESSAGE);
    }
    else if (groupChat.isJoined()) {
        ChatManager chatManager = SparkManager.getChatManager();
        chatManager.getChatContainer().addChatRoom(room);
        chatManager.getChatContainer().activateChatRoom(room);
    }
    else {
        JOptionPane.showMessageDialog(SparkManager.getMainWindow(), "Unable to join room.", "Error", JOptionPane.ERROR_MESSAGE);
    }

}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:71,代码来源:ConferenceUtils.java


注:本文中的org.jivesoftware.smackx.muc.MultiUserChat.isJoined方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。