本文整理匯總了Java中org.jivesoftware.smack.XMPPConnection.getServiceName方法的典型用法代碼示例。如果您正苦於以下問題:Java XMPPConnection.getServiceName方法的具體用法?Java XMPPConnection.getServiceName怎麽用?Java XMPPConnection.getServiceName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.jivesoftware.smack.XMPPConnection
的用法示例。
在下文中一共展示了XMPPConnection.getServiceName方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: joinMultiUserChat
import org.jivesoftware.smack.XMPPConnection; //導入方法依賴的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;
}
}
示例2: joinMultiUserChat
import org.jivesoftware.smack.XMPPConnection; //導入方法依賴的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;
}
}
示例3: addUserHaveGroup
import org.jivesoftware.smack.XMPPConnection; //導入方法依賴的package包/類
/**
* 添加好友 有分組
* @param xmppConnection
* @param userName 用戶名
* @param name 備注名
* @param groupName 分組名
* @return
*/
public static boolean addUserHaveGroup(XMPPConnection xmppConnection,String userName, String name, String groupName) {
try {
Presence subscription = new Presence(Presence.Type.subscribed);
subscription.setTo(userName);
userName += "@" + xmppConnection.getServiceName();
xmppConnection.sendPacket(subscription);
xmppConnection.getRoster().createEntry(userName, name, new String[] { groupName });
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
示例4: addUserHaveGroup
import org.jivesoftware.smack.XMPPConnection; //導入方法依賴的package包/類
/**
* 添加好友 有分組
* @param xmppConnection
* @param userName 用戶名
* @param name 備注名
* @param groupName 分組名
* @return
*/
public static boolean addUserHaveGroup(XMPPConnection xmppConnection, String userName, String name, String groupName) {
try {
Presence subscription = new Presence(Presence.Type.subscribed);
subscription.setTo(userName);
userName += "@" + xmppConnection.getServiceName();
xmppConnection.sendPacket(subscription);
xmppConnection.getRoster().createEntry(userName, name, new String[]{groupName});
return true;
} catch (Exception e) {
Log.e("addUser", e.getMessage());
e.printStackTrace();
return false;
}
}