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


Java MultiUserChat类代码示例

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


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

示例1: leaveChatGroupAsync

import org.jivesoftware.smackx.muc.MultiUserChat; //导入依赖的package包/类
@Override
public void leaveChatGroupAsync(ChatGroup group) {
    String chatRoomJid = group.getAddress().getBareAddress();

    if (mMUCs.containsKey(chatRoomJid))
    {
        MultiUserChat muc = mMUCs.get(chatRoomJid);
        try {
            muc.leave();
        }
        catch (Exception nce)
        {
            Log.e(ImApp.LOG_TAG,"not connected error trying to leave group",nce);

        }

        mMUCs.remove(chatRoomJid);

    }

}
 
开发者ID:zom,项目名称:Zom-Android,代码行数:22,代码来源:XmppConnection.java

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

示例3: process

import org.jivesoftware.smackx.muc.MultiUserChat; //导入依赖的package包/类
public void process(Packet packet) {
  if (roomResponseFilter.accept(packet)) {
    final DiscoverItems result = (DiscoverItems) packet;
    final JabberPlayer player = playerMgr.getPlayer(packet.getFrom());
    // Collect the entityID for each returned item
    for (Iterator<DiscoverItems.Item> items = result.getItems(); items.hasNext();) {
      final String roomJID = items.next().getEntityID();
      final JabberRoom room = roomMgr.getRoomByJID(JabberClient.this, roomJID);
      try {
       room.setInfo(MultiUserChat.getRoomInfo(JabberClient.this
            .getConnection(), roomJID));
      }
      catch (XMPPException e) {
        // Ignore Error
      }
      if (!roomJID.equals(monitorRoom.getRoom())) {
        player.join(roomMgr.getRoomByJID(JabberClient.this, roomJID));
      }
    }
    fireRoomsUpdated();
  }
  else if (newPlayerFilter.accept(packet)) {
    sendRoomQuery(getAbsolutePlayerJID(packet.getFrom()));
  }
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:26,代码来源:JabberClient.java

示例4: getRoomByJID

import org.jivesoftware.smackx.muc.MultiUserChat; //导入依赖的package包/类
public synchronized JabberRoom getRoomByJID(JabberClient client, String jid, String defaultName) {
  if (jid == null) {
    return null;
  }
  JabberRoom newRoom = jidToRoom.get(jid);
  if (newRoom == null) {
    String roomName = defaultName == null ? "" : defaultName; //$NON-NLS-1$
    RoomInfo info = null;
    try {
      info = MultiUserChat.getRoomInfo(client.getConnection(), jid);
    }
    // FIXME: review error message
    catch (XMPPException e) {
      e.printStackTrace();
    }
    newRoom = new JabberRoom(roomName, jid, info, client);
    jidToRoom.put(jid, newRoom);
  }
  return newRoom;
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:21,代码来源:JabberRoom.java

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

示例6: getHostRooms

import org.jivesoftware.smackx.muc.MultiUserChat; //导入依赖的package包/类
/**
 * 获取用户的所有聊天室
 * @param xmppConnection
 * @return
 */
public static List<HostedRoom>  getHostRooms(XMPPConnection xmppConnection){
    List<HostedRoom> roominfos = new ArrayList<HostedRoom>();
    try {
        new ServiceDiscoveryManager(xmppConnection);
        Collection<HostedRoom> hostrooms = MultiUserChat.getHostedRooms(xmppConnection,xmppConnection.getServiceName());
        for (HostedRoom entry : hostrooms) {
            roominfos.add(entry);
            Log.i("room", "名字:" + entry.getName() + " - ID:" + entry.getJid());
        }
        Log.i("room", "服务会议数量:" + roominfos.size());
    } catch (XMPPException e) {
        Log.e("getHostRooms",e.getMessage());
        e.printStackTrace();
    }
    return roominfos;
}
 
开发者ID:FanHuaRan,项目名称:SmackStudy,代码行数:22,代码来源:XMPPUtil.java

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

示例8: sendMessage

import org.jivesoftware.smackx.muc.MultiUserChat; //导入依赖的package包/类
public void sendMessage(String body, String chatJid, long timestamp) throws SmackException {
    Random random = new Random(timestamp + body.length() + chatJid.length());
    Log.d(TAG, "Sending message to : " + chatJid);
    MultiUserChat chat = MultiUserChatManager.getInstanceFor(groupChatConnection)
            .getMultiUserChat(chatJid);
    chat.addMessageListener(this);

    Message message = new Message();
    QuickbloxChatExtension extension = new QuickbloxChatExtension();
    extension.setProperty("date_sent", timestamp + "");
    message.setStanzaId(StanzaIdUtil.newStanzaId());
    message.setBody(body);
    message.addExtension(extension);
    message.setType(Message.Type.chat);

    chat.sendMessage(message);
}
 
开发者ID:ukevgen,项目名称:BizareChat,代码行数:18,代码来源:QuickbloxGroupXmppConnection.java

示例9: sendPublicMessage

import org.jivesoftware.smackx.muc.MultiUserChat; //导入依赖的package包/类
public void sendPublicMessage(String body, String chatJid, long timestamp, String stanzaId) {
    Log.d(TAG, "Sending message to : " + chatJid);

    MultiUserChat mucChat = publicChats.get(chatJid);

    QuickbloxChatExtension extension = new QuickbloxChatExtension();
    extension.setProperty("date_sent", timestamp + "");
    extension.setProperty("save_to_history", "1");

    Message message = new Message(chatJid);
    message.setStanzaId(stanzaId);
    message.setBody(body);
    message.setType(Message.Type.groupchat);
    message.addExtension(extension);

    try {
        if (mucChat != null) {
            mucChat.sendMessage(message);
        }
    } catch (SmackException.NotConnectedException ex) {
        offlineMessages.add(message);
    }
}
 
开发者ID:ukevgen,项目名称:BizareChat,代码行数:24,代码来源:QuickbloxPrivateXmppConnection.java

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

示例11: sendRoomInvite

import org.jivesoftware.smackx.muc.MultiUserChat; //导入依赖的package包/类
/**
 * Send invites to clients for joining multi user chat room
 * 
 * @param muc
 * @param userList
 * @param inviteMessage
 */
public void sendRoomInvite(MultiUserChat muc, ArrayList<String> userList, String inviteMessage) {

	if (muc != null && muc.getRoom() != null && !muc.getRoom().isEmpty()) {

		if (userList != null && !userList.isEmpty()) {
			for (String user : userList) {
				try {
					muc.invite(user, inviteMessage);
				} catch (NotConnectedException e) {
					e.printStackTrace();
				}
			}
			logger.info(userList.size() + " clients were invited to room(" + muc.getRoom() + ")");
		}
	} else {
		logger.info("There is no available room for invitation");
	}
}
 
开发者ID:Pardus-LiderAhenk,项目名称:lider,代码行数:26,代码来源:XMPPClientImpl.java

示例12: resolveRoom

import org.jivesoftware.smackx.muc.MultiUserChat; //导入依赖的package包/类
public String resolveRoom(XMPPConnection connection) throws XMPPException, SmackException {
    ObjectHelper.notEmpty(room, "room");

    if (room.indexOf('@', 0) != -1) {
        return room;
    }

    Iterator<String> iterator = MultiUserChat.getServiceNames(connection).iterator();
    if (!iterator.hasNext()) {
        throw new XMPPErrorException("Cannot find Multi User Chat service",
                                     new XMPPError(new XMPPError.Condition("Cannot find Multi User Chat service on connection: " + getConnectionMessage(connection))));
    }

    String chatServer = iterator.next();
    LOG.debug("Detected chat server: {}", chatServer);

    return room + "@" + chatServer;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:XmppEndpoint.java

示例13: join

import org.jivesoftware.smackx.muc.MultiUserChat; //导入依赖的package包/类
public void join(final Context context,String user,String rpwd,String rname)
{
	final MultiUserChat muc = XmppConnectionManager.getInstance().joinRoom(user, rpwd, rname);
	runOnUiThread(new Runnable(){
		@Override
		public void run() { 
			if(null != muc){
				XmppConnectionManager.getInstance().setMuc(muc);
				Toast.makeText(context, "����ɹ�", Toast.LENGTH_SHORT).show();
				((Activity) context).finish();
				Intent intent = new Intent(context, RoomChatActivity.class);
				context.startActivity(intent);
			}
			else{
				Toast.makeText(context, "����ʧ��", Toast.LENGTH_SHORT).show();
			}
		}});
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:19,代码来源:BaseActivity.java

示例14: onCreate

import org.jivesoftware.smackx.muc.MultiUserChat; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
	// TODO Auto-generated method stub
	super.onCreate(savedInstanceState);
	setContentView(R.layout.muc_room);
	con = XmppConnectionManager.getInstance().getConnection();
	muc = XmppConnectionManager.getInstance().getMuc();
	muc.addInvitationRejectionListener(this);
	MultiUserChat.addInvitationListener(con, this);
	muc.addParticipantStatusListener(this);
	muc.addMessageListener(this);
	app = EimApplication.getInstance();
	membersList = (ListView) findViewById(R.id.members);
	chatsList = (ListView) findViewById(R.id.chats);
	content = (EditText) findViewById(R.id.content);
	membersList.setOnItemClickListener(this);
	initData();
	
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:20,代码来源:MUCRoom.java

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


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