本文整理汇总了Java中org.jivesoftware.smack.Roster.setDefaultSubscriptionMode方法的典型用法代码示例。如果您正苦于以下问题:Java Roster.setDefaultSubscriptionMode方法的具体用法?Java Roster.setDefaultSubscriptionMode怎么用?Java Roster.setDefaultSubscriptionMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smack.Roster
的用法示例。
在下文中一共展示了Roster.setDefaultSubscriptionMode方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
public XMPPConnection init() {
Connection.DEBUG_ENABLED = false;
ProviderManager pm = ProviderManager.getInstance();
configure(pm);
ConnectionConfiguration connectionConfig = new ConnectionConfiguration(Const.XMPP_HOST, Const.XMPP_PORT);
// connectionConfig.setSASLAuthenticationEnabled(false);//
// 不使用SASL验证,设置为false
// connectionConfig
// .setSecurityMode(ConnectionConfiguration.SecurityMode.enabled);
// 允许自动连接
connectionConfig.setReconnectionAllowed(true);
// 允许登陆成功后更新在线状态
connectionConfig.setSendPresence(true);
// 收到好友邀请后manual表示需要经过同意,accept_all表示不经同意自动为好友
Roster.setDefaultSubscriptionMode(Roster.SubscriptionMode.accept_all);
XMPPConnection connection = new XMPPConnection(connectionConfig);
return connection;
}
示例2: init
import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
* 初始化连接
* @param loginConfig
* @return
*/
public XMPPConnection init(IMConfig loginConfig) {
Connection.DEBUG_ENABLED = false;
ProviderManager pm = ProviderManager.getInstance();
configure(pm);
connectionConfig = new ConnectionConfiguration(
loginConfig.getXmppHost(), loginConfig.getXmppPort(),
loginConfig.getXmppServiceName());
//connectionConfig.setSASLAuthenticationEnabled(false);// 不使用SASL验证,设置为false
connectionConfig
.setSecurityMode(ConnectionConfiguration.SecurityMode.enabled);
// 允许自动连接
connectionConfig.setReconnectionAllowed(false);
// 允许登陆成功后更新在线状态
connectionConfig.setSendPresence(true);
// 收到好友邀请后manual表示需要经过同意,accept_all表示不经同意自动为好友
Roster.setDefaultSubscriptionMode(Roster.SubscriptionMode.manual);
connection = new XMPPConnection(connectionConfig);
return connection;
}
示例3: LolChat
import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
* Represents a single connection to a League of Legends chatserver.
*
* @param server
* The chatserver of the region you want to connect to
* @param friendRequestPolicy
* Determines how new Friend requests are treated.
* @param riotApiKey
* Your apiKey used to convert summonerId's to name. You can get
* your key here <a
* href="https://developer.riotgames.com/">developer
* .riotgames.com</a>
*
* @see LolChat#setFriendRequestPolicy(FriendRequestPolicy)
* @see LolChat#setFriendRequestListener(FriendRequestListener)
*/
public LolChat(ChatServer server, FriendRequestPolicy friendRequestPolicy,
RiotApiKey riotApiKey) {
this.friendRequestPolicy = friendRequestPolicy;
this.server = server;
if (riotApiKey != null && server.api != null) {
this.riotApi = RiotApi.build(riotApiKey, server);
}
Roster.setDefaultSubscriptionMode(SubscriptionMode.manual);
final ConnectionConfiguration config = new ConnectionConfiguration(
server.host, 5223, "pvp.net");
config.setSecurityMode(ConnectionConfiguration.SecurityMode.enabled);
config.setSocketFactory(SSLSocketFactory.getDefault());
config.setCompressionEnabled(true);
connection = new XMPPTCPConnection(config);
addListeners();
}
示例4: init
import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
public XMPPConnection init(LoginConfig loginConfig) {
Connection.DEBUG_ENABLED = false;
ProviderManager pm = ProviderManager.getInstance();
configure(pm);
connectionConfig = new ConnectionConfiguration(
loginConfig.getXmppHost(), loginConfig.getXmppPort(),
loginConfig.getXmppServiceName());
try {
Class.forName("org.jivesoftware.smackx.ServiceDiscoveryManager", true, XmppConnectionManager.class.getClassLoader());
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
/// ServiceDiscoveryManager discoManager = new ServiceDiscoveryManager(connection);
connectionConfig.setSASLAuthenticationEnabled(false);// ��ʹ��SASL��֤������Ϊfalse
connectionConfig
.setSecurityMode(ConnectionConfiguration.SecurityMode.enabled);
// �����Զ�����
connectionConfig.setReconnectionAllowed(false);
// �����½�ɹ����������״̬
connectionConfig.setSendPresence(true);
// connectionConfig.setSendPresence(false);
// �յ����������manual��ʾ��Ҫ����ͬ��,accept_all��ʾ����ͬ���Զ�Ϊ����
Roster.setDefaultSubscriptionMode(Roster.SubscriptionMode.manual);
connection = new XMPPConnection(connectionConfig);
return connection;
}
示例5: xmppConnect
import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
* XMPP
* @throws XMPPException
*/
public void xmppConnect() throws XMPPException {
if (!(ThreadHelper.xmppConnection == null) &&
ThreadHelper.xmppConnection.isConnected()) return;
// Set configuration parameter
Roster.setDefaultSubscriptionMode(Roster.SubscriptionMode.manual);
ConnectionConfiguration config = new ConnectionConfiguration(HOST, PORT);
config.setSASLAuthenticationEnabled(false);
configure(ProviderManager.getInstance());
ThreadHelper.xmppConnection = new XMPPConnection(config);
ThreadHelper.xmppConnection.connect();
}
示例6: init
import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
* Initializing the XMPPListener. Retrieve connection details provided in
* xmpp transport receiver, connect to those servers & start listening in
* for messages.
*/
public void init(ConfigurationContext configurationCtx, TransportInDescription transportIn)
throws AxisFault {
log.info("Initializing XMPPListener...");
//allow anyone to send message to listening account
Roster.setDefaultSubscriptionMode(SubscriptionMode.accept_all);
configurationContext = configurationCtx;
initializeConnectionFactories(transportIn);
if (connectionFactories.isEmpty()) {
log.warn("No XMPP connection factories defined." +
"Will not listen for any XMPP messages");
return;
}
}
示例7: LolChat
import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
* Represents a single connection to a League of Legends chatserver.
*
* @param server The chatserver of the region you want to connect to
* @param friendRequestPolicy Determines how new Friend requests are treated.
* @param riotApiKey Your apiKey used to convert summonerId's to name. You can get
* your key here <a
* href="https://developer.riotgames.com/">developer
* .riotgames.com</a>
* @see LolChat#setFriendRequestPolicy(FriendRequestPolicy)
* @see LolChat#setFriendRequestListener(FriendRequestListener)
*/
public LolChat(ChatServer server, FriendRequestPolicy friendRequestPolicy,
String riotApiKey) {
this.friendRequestPolicy = friendRequestPolicy;
if (riotApiKey != null && server.api != null) {
this.riotApi = new JRiot(riotApiKey, server.name().toLowerCase());
}
Roster.setDefaultSubscriptionMode(SubscriptionMode.manual);
final ConnectionConfiguration config = new ConnectionConfiguration(
server.host, 5223, "pvp.net");
config.setSecurityMode(ConnectionConfiguration.SecurityMode.enabled);
config.setSocketFactory(SSLSocketFactory.getDefault());
config.setCompressionEnabled(true);
connection = new XMPPTCPConnection(config);
try {
connection.connect();
} catch (Exception e) {
System.err.println("Failed to connect to " + server.host);
return;
}
addListeners();
new Thread(new Runnable() {
@Override
public void run() {
while (!stop) {
try {
Thread.sleep(500);//NOT SURE ABOUT THIS, TODO:REVIST
} catch (final InterruptedException ignored) {
}
}
}
}).start();
}
示例8: getRoster
import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
private void getRoster(){
/*
* get the Roster and add the logaccount as a contact
*/
Roster roster = conn.getRoster();
roster.setDefaultSubscriptionMode(Roster.SubscriptionMode.accept_all);
roster.setSubscriptionMode(Roster.SubscriptionMode.accept_all);
String[] groups= {"admins"};
try {
roster.createEntry(logAccount, logAccount,groups );
} catch (XMPPException e) {
e.printStackTrace();
}
}
示例9: onCreate
import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void onCreate() {
super.onCreate();
registerReceiver(mReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
mSettings = PreferenceManager.getDefaultSharedPreferences(this);
mSettings.registerOnSharedPreferenceChangeListener(mPreferenceListener);
if (mSettings.getBoolean(BeemApplication.USE_AUTO_AWAY_KEY, false)) {
mOnOffReceiverIsRegistered = true;
registerReceiver(mOnOffReceiver, new IntentFilter(Intent.ACTION_SCREEN_OFF));
registerReceiver(mOnOffReceiver, new IntentFilter(Intent.ACTION_SCREEN_ON));
}
String tmpJid = mSettings.getString(BeemApplication.ACCOUNT_USERNAME_KEY, "").trim();
mLogin = StringUtils.parseName(tmpJid);
boolean useSystemAccount = mSettings.getBoolean(BeemApplication.USE_SYSTEM_ACCOUNT_KEY, false);
mPort = DEFAULT_XMPP_PORT;
mService = StringUtils.parseServer(tmpJid);
mHost = mService;
initMemorizingTrustManager();
if (mSettings.getBoolean(BeemApplication.ACCOUNT_SPECIFIC_SERVER_KEY, false)) {
mHost = mSettings.getString(BeemApplication.ACCOUNT_SPECIFIC_SERVER_HOST_KEY, "").trim();
if ("".equals(mHost))
mHost = mService;
String tmpPort = mSettings.getString(BeemApplication.ACCOUNT_SPECIFIC_SERVER_PORT_KEY, "5222");
if (!"".equals(tmpPort))
mPort = Integer.parseInt(tmpPort);
}
if (mSettings.getBoolean(BeemApplication.FULL_JID_LOGIN_KEY, false)
|| "gmail.com".equals(mService) || "googlemail.com".equals(mService)
|| useSystemAccount) {
mLogin = tmpJid;
}
configure(ProviderManager.getInstance());
mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Roster.setDefaultSubscriptionMode(SubscriptionMode.manual);
mBind = new XmppFacade(this);
Log.d(TAG, "Create BeemService");
}