/**
* $RCSfile$
* $Revision: 11613 $
* $Date: 2010-02-09 12:55:56 +0100 (mar. 09 févr. 2010) $
*
* Copyright 2003-2007 Jive Software.
*
* All rights reserved. Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.smackx.muc;
import java.lang.ref.WeakReference;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;
import java.util.concurrent.ConcurrentHashMap;
import org.jivesoftware.smack.Chat;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.ConnectionListener;
import org.jivesoftware.smack.MessageListener;
import org.jivesoftware.smack.PacketCollector;
import org.jivesoftware.smack.PacketInterceptor;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.SmackConfiguration;
import org.jivesoftware.smack.Connection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.filter.AndFilter;
import org.jivesoftware.smack.filter.FromMatchesFilter;
import org.jivesoftware.smack.filter.MessageTypeFilter;
import org.jivesoftware.smack.filter.PacketExtensionFilter;
import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.filter.PacketIDFilter;
import org.jivesoftware.smack.filter.PacketTypeFilter;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.packet.Registration;
import org.jivesoftware.smackx.Form;
import org.jivesoftware.smackx.NodeInformationProvider;
import org.jivesoftware.smackx.ServiceDiscoveryManager;
import org.jivesoftware.smackx.packet.DiscoverInfo;
import org.jivesoftware.smackx.packet.DiscoverItems;
import org.jivesoftware.smackx.packet.MUCAdmin;
import org.jivesoftware.smackx.packet.MUCInitialPresence;
import org.jivesoftware.smackx.packet.MUCOwner;
import org.jivesoftware.smackx.packet.MUCUser;
/**
* A MultiUserChat is a conversation that takes place among many users in a virtual
* room. A room could have many occupants with different affiliation and roles.
* Possible affiliatons are "owner", "admin", "member", and "outcast". Possible roles
* are "moderator", "participant", and "visitor". Each role and affiliation guarantees
* different privileges (e.g. Send messages to all occupants, Kick participants and visitors,
* Grant voice, Edit member list, etc.).
*
* @author Gaston Dombiak, Larry Kirschner
*/
public class MultiUserChat {
private final static String discoNamespace = "http://jabber.org/protocol/muc";
private final static String discoNode = "http://jabber.org/protocol/muc#rooms";
private static Map<Connection, List<String>> joinedRooms =
new WeakHashMap<Connection, List<String>>();
private Connection connection;
private String room;
private String subject;
private String nickname = null;
private boolean joined = false;
private Map<String, Presence> occupantsMap = new ConcurrentHashMap<String, Presence>();
private final List<InvitationRejectionListener> invitationRejectionListeners =
new ArrayList<InvitationRejectionListener>();
private final List<SubjectUpdatedListener> subjectUpdatedListeners =
new ArrayList<SubjectUpdatedListener>();
private final List<UserStatusListener> userStatusListeners =
new ArrayList<UserStatusListener>();
private final List<ParticipantStatusListener> participantStatusListeners =
new ArrayList<ParticipantStatusListener>();
private PacketFilter presenceFilter;
private List<PacketInterceptor> presenceInterceptors = new ArrayList<PacketInterceptor>();
private PacketFilter messageFilter;
private RoomListenerMultiplexor roomListenerMultiplexor;
private ConnectionDetachedPacketCollector messageCollector;
private List<PacketListener> connectionListeners = new ArrayList<PacketListener>();
static {
Connection.addConnectionCreationListener(new ConnectionCreationListener() {
public void connectionCreated(final Connection connection) {
// Set on every established connection that this client supports the Multi-User
// Chat protocol. This information will be used when another client tries to
// discover whether this client supports MUC or not.
ServiceDiscoveryManager.getInstanceFor(connection).addFeature(discoNamespace);
// Set the NodeInformationProvider that will provide information about the
// joined rooms whenever a disco request is received
ServiceDiscoveryManager.getInstanceFor(connection).setNodeInformationProvider(
discoNode,
new NodeInformationProvider() {
public List<DiscoverItems.Item> getNodeItems() {
List<DiscoverItems.Item> answer = new ArrayList<DiscoverItems.Item>();
Iterator<String> rooms=MultiUserChat.getJoinedRooms(connection);
while (rooms.hasNext()) {
answer.add(new DiscoverItems.Item(rooms.next()));
}
return answer;
}
public List<String> getNodeFeatures() {
return null;
}
public List<DiscoverInfo.Identity> getNodeIdentities() {
return null;
}
});
}
});
}
/**
* Creates a new multi user chat with the specified connection and room name. Note: no
* information is sent to or received from the server until you attempt to
* {@link #join(String) join} the chat room. On some server implementations,
* the room will not be created until the first person joins it.<p>
*
* Most XMPP servers use a sub-domain for the chat service (eg chat.example.com
* for the XMPP server example.com). You must ensure that the room address you're
* trying to connect to includes the proper chat sub-domain.
*
* @param connection the XMPP connection.
* @param room the name of the room in the form "roomName@service", where
* "service" is the hostname at which the multi-user chat
* service is running. Make sure to provide a valid JID.
*/
public MultiUserChat(Connection connection, String room) {
this.connection = connection;
this.room = room.toLowerCase();
init();
}
/**
* Returns true if the specified user supports the Multi-User Chat protocol.
*
* @param connection the connection to use to perform the service discovery.
* @param user the user to check. A fully qualified xmpp ID, e.g. jdoe@example.com.
* @return a boolean indicating whether the specified user supports the MUC protocol.
*/
public static boolean isServiceEnabled(Connection connection, String user) {
try {
DiscoverInfo result =
ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(user);
return result.containsFeature(discoNamespa
没有合适的资源?快使用搜索试试~ 我知道了~
Android平台的即时通信系统的API
共595个文件
java:572个
html:14个
properties:5个
4星 · 超过85%的资源 需积分: 9 14 下载量 163 浏览量
2012-06-04
11:33:38
上传
评论
收藏 989KB ZIP 举报
温馨提示
Android平台的即时通信系统的API asmack android smack
资源推荐
资源详情
资源评论
收起资源包目录
Android平台的即时通信系统的API (595个子文件)
overview.html 224B
package.html 217B
package.html 176B
package.html 79B
package.html 73B
package.html 71B
package.html 67B
package.html 60B
package.html 43B
package.html 41B
package.html 38B
package.html 34B
package.html 29B
package.html 29B
com.kenai.jbosh.HTTPSender 33B
MultiUserChat.java 119KB
Base64.java 67KB
BOSHClient.java 49KB
AgentSession.java 48KB
AbstractHashedMap.java 43KB
XMPPConnection.java 39KB
Roster.java 38KB
Workgroup.java 35KB
PacketParserUtils.java 33KB
Connection.java 33KB
AbstractReferenceMap.java 33KB
AdHocCommandManager.java 30KB
DigestMD5SaslClient.java 30KB
VCard.java 27KB
Subject.java 26KB
ConnectionConfiguration.java 26KB
SASLAuthentication.java 24KB
ServiceDiscoveryManager.java 24KB
Cache.java 23KB
Form.java 23KB
Socks5TransferNegotiator.java 21KB
ProviderManager.java 20KB
Name.java 20KB
Cache.java 20KB
MUCUser.java 20KB
ConfigureForm.java 20KB
DNSSEC.java 20KB
LoginContext.java 19KB
PacketReader.java 19KB
XMPPError.java 18KB
StringUtils.java 18KB
Tokenizer.java 18KB
PrivacyListManager.java 17KB
WKSRecord.java 17KB
FileTransferNegotiator.java 17KB
Record.java 17KB
Node.java 17KB
Packet.java 17KB
MultipleRecipientManager.java 16KB
Lookup.java 16KB
AgentRoster.java 15KB
AdHocCommand.java 15KB
TSIG.java 15KB
IBBTransferNegotiator.java 15KB
Message.java 15KB
ZoneTransferIn.java 14KB
PrivacyItem.java 14KB
PrivateDataManager.java 14KB
OutgoingFileTransfer.java 14KB
Bytestream.java 14KB
Message.java 14KB
BOSHClientConfig.java 13KB
AccountManager.java 13KB
StreamInitiation.java 13KB
OfflineMessageManager.java 13KB
Socks5TransferNegotiatorManager.java 12KB
MessageEvent.java 12KB
PrivateCredentialPermission.java 12KB
MessageEventManager.java 12KB
DirectiveList.java 12KB
Zone.java 12KB
DigestChallenge.java 12KB
SASLMechanism.java 12KB
FormField.java 12KB
XHTMLText.java 11KB
MUCOwner.java 11KB
Presence.java 11KB
ResolverConfig.java 11KB
Privacy.java 11KB
ComposableBody.java 11KB
LeafNode.java 11KB
ServerTrustManager.java 11KB
ModelUtil.java 11KB
Socks5ProxySocketFactory.java 11KB
ExtendedResolver.java 10KB
Master.java 10KB
PacketWriter.java 10KB
Bookmarks.java 10KB
PubSubManager.java 10KB
UserSearch.java 10KB
DataForm.java 10KB
SmackConfiguration.java 10KB
Address.java 9KB
VCardProvider.java 9KB
FileTransfer.java 9KB
共 595 条
- 1
- 2
- 3
- 4
- 5
- 6
资源评论
- mmorss2013-08-07不是文档吧,是代码
- luojiaoshou_1232012-06-26非常不错,还有这么好的文档。。。。
- KingGuardian2012-12-04文档很好,很详细
念愿
- 粉丝: 49
- 资源: 26
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功