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


Java MultiUserChat.join方法代码示例

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


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

示例1: init

import org.jivesoftware.smackx.muc.MultiUserChat; //导入方法依赖的package包/类
public void init() throws XMPPException {
  new TrackRooms().addTo(conn);
  new TrackStatus(getMonitorRoomJID().toLowerCase()).addTo(conn);
  new ListenForChat().addTo(conn);
  monitorRoom = new MultiUserChat(conn, getMonitorRoomJID());
  monitorRoom.addMessageListener(this);
  monitorRoom.addParticipantStatusListener(this);
  monitorRoom.join(StringUtils.parseName(conn.getUser()));
  try {
    // This is necessary to create the room if it doesn't already exist
    monitorRoom.sendConfigurationForm(new Form(Form.TYPE_SUBMIT));
  }
  catch (XMPPException ex) {
    // 403 code means the room already exists and user is not an owner
    if (ex.getXMPPError().getCode() != 403) {
      throw ex;
    }
  }
  sendStatus(me);
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:21,代码来源:JabberClient.java

示例2: joinMultiUserChat

import org.jivesoftware.smackx.muc.MultiUserChat; //导入方法依赖的package包/类
/**
 * 加入聊天室
 * @param xmppConnection
 * @param roomName
 * @param password
 * @return
 */
public static  MultiUserChat joinMultiUserChat(XMPPConnection xmppConnection,String roomName,String password,PacketListener packetListener){
    try {
        // 使用XMPPConnection创建一个MultiUserChat窗口
        MultiUserChat muc = new MultiUserChat(xmppConnection, roomName+ "@conference." + xmppConnection.getServiceName());
        // 聊天室服务将会决定要接受的历史记录数量
        DiscussionHistory history = new DiscussionHistory();
        history.setMaxChars(0);
        // 用户加入聊天室
        muc.join(xmppConnection.getUser(), password, history, SmackConfiguration.getPacketReplyTimeout());
        if(packetListener!=null){
        	muc.addMessageListener(packetListener);
        }
        return muc;
    } catch (XMPPException e) {
        e.printStackTrace();
        return null;
    }
}
 
开发者ID:FanHuaRan,项目名称:SmackStudy,代码行数:26,代码来源:XMPPUtil.java

示例3: joinMultiUserChat

import org.jivesoftware.smackx.muc.MultiUserChat; //导入方法依赖的package包/类
/**
 * 加入聊天室
 * @param xmppConnection
 * @param roomName
 * @param password
 * @param packetListener 消息监听器
 * @return
 */
public static  MultiUserChat joinMultiUserChat(XMPPConnection xmppConnection,String roomName,String password,PacketListener packetListener){
    try {
        // 使用XMPPConnection创建一个MultiUserChat窗口
        MultiUserChat muc = new MultiUserChat(xmppConnection, roomName+ "@conference." + xmppConnection.getServiceName());
        // 聊天室服务将会决定要接受的历史记录数量
        DiscussionHistory history = new DiscussionHistory();
        history.setMaxChars(0);
        // history.setSince(new Date());
        // 用户加入聊天室
        muc.join(xmppConnection.getUser(), password, history, SmackConfiguration.getPacketReplyTimeout());
        Log.i("MultiUserChat", "会议室【"+roomName+"】加入成功........");
        if(packetListener!=null){
            muc.addMessageListener(packetListener);
        }
        return muc;
    } catch (XMPPException e) {
        Log.e("MultiUserChat", "会议室【"+roomName+"】加入失败........");
        e.printStackTrace();
        return null;
    }
}
 
开发者ID:FanHuaRan,项目名称:SmackStudy,代码行数:30,代码来源:XMPPUtil.java

示例4: joinPublicChat

import org.jivesoftware.smackx.muc.MultiUserChat; //导入方法依赖的package包/类
public void joinPublicChat(String chatJid, long lastMessageDate) {
    try {
        MultiUserChat mucChat;
        if ((mucChat = publicChats.get(chatJid)) == null) {
            mucChat = MultiUserChatManager.getInstanceFor(privateChatConnection).getMultiUserChat(chatJid);
            mucChat.addMessageListener(this);
            publicChats.put(chatJid, mucChat);
        }

        DiscussionHistory history = new DiscussionHistory();
        if(lastMessageDate != 0)
            history.setSince(new Date(lastMessageDate * 1000));
        else
            history.setMaxChars(0);
        mucChat.join(
                CurrentUser.getInstance().getCurrentUserId().toString(),
                null,
                history,
                privateChatConnection.getPacketReplyTimeout());
    } catch (Exception ex) {
        Logger.logExceptionToFabric(ex);
    }
}
 
开发者ID:ukevgen,项目名称:BizareChat,代码行数:24,代码来源:QuickbloxPrivateXmppConnection.java

示例5: reconnectAll

import org.jivesoftware.smackx.muc.MultiUserChat; //导入方法依赖的package包/类
public void reconnectAll ()
{
    MultiUserChatManager mucMgr = MultiUserChatManager.getInstanceFor(mConnection);
    mucMgr.setAutoJoinOnReconnect(true);

    Enumeration<MultiUserChat> eMuc = mMUCs.elements();
    while (eMuc.hasMoreElements())
    {
        MultiUserChat muc = eMuc.nextElement();

        MultiUserChat reMuc = mucMgr.getMultiUserChat(muc.getRoom());

        try {
            DiscussionHistory history = new DiscussionHistory();
            reMuc.join(Resourcepart.from(mUser.getName()), null, history, SmackConfiguration.getDefaultPacketReplyTimeout());
            mMUCs.put(muc.getRoom().toString(),reMuc);
            ChatGroup group = mGroups.get(muc.getRoom().toString());

            addMucListeners(reMuc, group);

        } catch (Exception e) {
            Log.w(TAG,"unable to join MUC: " + e.getMessage());
        }
    }
}
 
开发者ID:zom,项目名称:Zom-Android,代码行数:26,代码来源:XmppConnection.java

示例6: perform

import org.jivesoftware.smackx.muc.MultiUserChat; //导入方法依赖的package包/类
@Override
public SampleResult perform(JMeterXMPPSampler sampler, SampleResult res) throws Exception {
    String room = sampler.getPropertyAsString(ROOM);
    String nick = sampler.getPropertyAsString(NICKNAME);
    res.setSamplerData("Join Room: " + room + "/" + nick);
    MultiUserChat muc = new MultiUserChat(sampler.getXMPPConnection(), room);
    muc.join(nick);
    return res;
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:10,代码来源:MUC.java

示例7: 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

示例8: start

import org.jivesoftware.smackx.muc.MultiUserChat; //导入方法依赖的package包/类
public void start(ITetradCallback callback) {
    logger.debug("start");
    logger.info(MessageFormat.format("Connecting to service {0} with username {1} and resource {2}",
                                     service_domain,
                                     username,
                                     resource
                                    ));
    this.callback = callback;
    try {
        XMPPConnection xmppConnection = new XMPPConnection(service_domain);
        xmppConnection.connect();

        xmppConnection.login(username, password, resource);

        DiscussionHistory history = new DiscussionHistory();
        history.setMaxStanzas(0);

        for (String room : rooms) {
            final String roomJID = room + "@" + getChatService();
            logger.info(MessageFormat.format("Connecting to room {0}", roomJID));
            MultiUserChat chat = new MultiUserChat(xmppConnection, roomJID);
            chat.join(xmppConnection.getUser(), password, history, SmackConfiguration.getPacketReplyTimeout());
            chat.addMessageListener(packet -> this.handleMessage((Message) packet, roomJID));
            chat.changeNickname("β");
            connectedRooms.put(room, chat);
        }
    } catch (XMPPException e) {
        logger.error(MessageFormat.format("Error connecting to service {0} with username {1} and resource {2}. Message: {3}",
                                          service_domain,
                                          username,
                                          resource,
                                          e.getMessage()
                                         ));
    }
}
 
开发者ID:dmitriid,项目名称:tetrad,代码行数:36,代码来源:TetradXMPP.java

示例9: joinRoom

import org.jivesoftware.smackx.muc.MultiUserChat; //导入方法依赖的package包/类
/**
 * ����������
 * 
 * @param user
 * @param pwd
 *            ����������
 * @param roomName
 * @return
 */
public MultiUserChat joinRoom(String user, String pwd, String roomName) {
	MultiUserChat muc = new MultiUserChat(connection,
			roomName.contains(CONFERENCE) ? roomName : roomName
					+ CONFERENCE + connection.getServiceName());
	DiscussionHistory history = new DiscussionHistory();
	history.setMaxStanzas(100);
	history.setSince(new Date(2014, 07, 31));
	// history.setSince(new Date());
	try {
		muc.join(user, pwd, history,
				SmackConfiguration.getPacketReplyTimeout());
		Message msg = muc.nextMessage();
		if (null != msg)
			SLog.i(tag, msg.toXML());

		Message msg2 = muc.nextMessage(100);
		if (null != msg2)
			SLog.i(tag, msg2.toXML());

	} catch (XMPPException e) {
		SLog.e(tag, " ���� ������ ����");
		SLog.e(tag, Log.getStackTraceString(e));
		return null;
	}
	return muc;
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:36,代码来源:XmppConnectionManager.java

示例10: activateOptions

import org.jivesoftware.smackx.muc.MultiUserChat; //导入方法依赖的package包/类
/**
 * Options are activated and become effective only after calling this method.
 */
@Override
public void activateOptions() {
    try {
        cb = new CyclicBuffer(bufferSize);

        // Create a connection to the XMPP server
        LogLog.debug("Stablishing connection with XMPP server");
        con = new XMPPConnection(InstantMessagingModule.getConnectionConfiguration());
        // Most servers require you to login before performing other tasks
        LogLog.debug("About to login as [" + username + "/" + password + "]");
        con.connect();
        con.login(username, password);

        // Start a conversation with IMAddress
        if (chatroom) {
            LogLog.debug("About to create ChatGroup");
            groupchat = new MultiUserChat(con, (String) recipientsList.get(0));
            LogLog.debug("About to join room");
            groupchat.join(nickname != null ? nickname : username);
        } else {
            final Iterator iter = recipientsList.iterator();
            while (iter.hasNext()) {
                chats.add(con.getChatManager().createChat((String) iter.next(), null));
            }
            // chat = con.createChat(recipients);
        }

    } catch (final XMPPException xe) {
        errorHandler.error("Error while activating options for appender named [" + name + "] Could not connect to instant messaging server with user: "
                + getUsername(), xe, ErrorCode.GENERIC_FAILURE);
    } catch (final Exception e) {
        errorHandler.error("Error while activating options for appender named [" + name + "]", e, ErrorCode.GENERIC_FAILURE);
    }
}
 
开发者ID:huihoo,项目名称:olat,代码行数:38,代码来源:IMAppender.java

示例11: joinChannelWithoutHashing

import org.jivesoftware.smackx.muc.MultiUserChat; //导入方法依赖的package包/类
public MultiUserChat joinChannelWithoutHashing(String name, String password) {
	MultiUserChat chat = new MultiUserChat(this, name);
	chatRooms.put(name, chat);
	try {
		chat.join(getUsername(), password);
		return chat;
	} catch (XMPPException.XMPPErrorException | SmackException e) {
		throw new IllegalStateException(e);
	}
}
 
开发者ID:loldevs,项目名称:riotapi,代码行数:11,代码来源:XmppClient.java

示例12: enterRoom

import org.jivesoftware.smackx.muc.MultiUserChat; //导入方法依赖的package包/类
private void enterRoom(String roomName) {
	/*
	 * Enters a MUC and listens for messages to handle
	 * @param roomName The name of the MuC
	 */
	MultiUserChat muc = new MultiUserChat(conn,roomName+"@conference"+serverName);
	try {
		muc.join(username + "_" + hostname);
		muc.addMessageListener(new PacketListener()
		{

			@Override
			public void processPacket(Packet packet) {
				// TODO Auto-generated method stub
				{
					Message msg = (Message) packet;

					handleMessage(msg);

				}


			}
		});


	} catch (XMPPException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
		System.out.println("Couldn't login at MUC");
	}

}
 
开发者ID:ControlAltDieliet,项目名称:system_updater,代码行数:34,代码来源:Bot.java

示例13: 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

示例14: doStart

import org.jivesoftware.smackx.muc.MultiUserChat; //导入方法依赖的package包/类
@Override
protected void doStart() throws Exception {
    try {
        connection = endpoint.createConnection();
    } catch (SmackException e) {
        if (endpoint.isTestConnectionOnStartup()) {
            throw new RuntimeException("Could not connect to XMPP server.", e);
        } else {
            LOG.warn(e.getMessage());
            if (getExceptionHandler() != null) {
                getExceptionHandler().handleException(e.getMessage(), e);
            }
            scheduleDelayedStart();
            return;
        }
    }

    chatManager = ChatManager.getInstanceFor(connection);
    chatManager.addChatListener(this);

    OrFilter pubsubPacketFilter = new OrFilter();
    if (endpoint.isPubsub()) {
        //xep-0060: pubsub#notification_type can be 'headline' or 'normal'
        pubsubPacketFilter.addFilter(new MessageTypeFilter(Type.headline));
        pubsubPacketFilter.addFilter(new MessageTypeFilter(Type.normal));
        connection.addPacketListener(this, pubsubPacketFilter);
    }

    if (endpoint.getRoom() == null) {
        privateChat = chatManager.getThreadChat(endpoint.getChatId());

        if (privateChat != null) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Adding listener to existing chat opened to " + privateChat.getParticipant());
            }
            privateChat.addMessageListener(this);
        } else {
            privateChat = ChatManager.getInstanceFor(connection).createChat(endpoint.getParticipant(), endpoint.getChatId(), this);
            if (LOG.isDebugEnabled()) {
                LOG.debug("Opening private chat to " + privateChat.getParticipant());
            }
        }
    } else {
        // add the presence packet listener to the connection so we only get packets that concerns us
        // we must add the listener before creating the muc
       
        final AndFilter packetFilter = new AndFilter(new PacketTypeFilter(Presence.class));
        connection.addPacketListener(this, packetFilter);

        muc = new MultiUserChat(connection, endpoint.resolveRoom(connection));
        muc.addMessageListener(this);
        DiscussionHistory history = new DiscussionHistory();
        history.setMaxChars(0); // we do not want any historical messages

        muc.join(endpoint.getNickname(), null, history, SmackConfiguration.getDefaultPacketReplyTimeout());
        if (LOG.isInfoEnabled()) {
            LOG.info("Joined room: {} as: {}", muc.getRoom(), endpoint.getNickname());
        }
    }

    this.startRobustConnectionMonitor();
    super.doStart();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:64,代码来源:XmppConsumer.java

示例15: joinRoom

import org.jivesoftware.smackx.muc.MultiUserChat; //导入方法依赖的package包/类
/**
 * Joins the specified room and removes from queue.
 *
 * @param roomName the name of the room to join.
 */
public void joinRoom(String roomName) {
    // Set the last check now
    lastCheck = System.currentTimeMillis();

    try {
        groupChat = new MultiUserChat(connection, roomName);
        if (name != null) {
            try {
                AndFilter presenceFilter = new AndFilter(new PacketTypeFilter(Presence.class), new FromContainsFilter(groupChat.getRoom()));
                connection.addPacketListener(this, presenceFilter);
                groupChat.join(name);
            }
            // Catch any join exceptions and attempt to join again
            // using an altered name (since exception is most likely
            // due to a conflict of names).
            catch (XMPPException xe) {
                String conflictName = name + " (Visitor)";
                groupChat.join(conflictName);
                nickname = conflictName;
            }
        }
        else {
            nickname = "Visitor";
            groupChat.join(nickname);
        }
        groupChat.addParticipantListener(new PacketListener() {
            public void processPacket(Packet packet) {
                final Presence p = (Presence)packet;
                final String from = p.getFrom();
                String user = StringUtils.parseResource(from);

                if (p.getType() != Presence.Type.available) {
                    lastAgent = user;
                }

                final Timer timer = new Timer();
                timer.schedule(new TimerTask() {
                    public void run() {
                        checkForEmptyRoom();
                    }
                }, 5000);


            }
        });

        messageEventManager = new MessageEventManager(connection);
        messageEventManager.addMessageEventNotificationListener(this);
    }
    catch (Exception e) {
        WebLog.logError("Error joining room:", e);
    }

    this.roomName = roomName;
    listenForMessages(connection, groupChat);
}
 
开发者ID:igniterealtime,项目名称:Fastpath-webchat,代码行数:62,代码来源:ChatSession.java


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