org.jivesoftware.smack.ConnectionCreationListener Java Examples

The following examples show how to use org.jivesoftware.smack.ConnectionCreationListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XMPPManager.java    From Yahala-Messenger with MIT License 5 votes vote down vote up
public ConnectionCreationListener createConnectionListener() {
    connectionCreationListener = new ConnectionCreationListener() {
        @Override
        public void connectionCreated(XMPPConnection xmppConnection) {
            FileLog.e("Test", "Connection created: Successful!");
        }
    };

    return connectionCreationListener;
}
 
Example #2
Source File: JingleManager.java    From Smack with Apache License 2.0 5 votes vote down vote up
/**
 * Setup the jingle system to let the remote clients know we support Jingle.
 * (This used to be a static part of construction.  The problem is a remote client might
 * attempt a Jingle connection to us after we've created an XMPPConnection, but before we've
 * setup an instance of a JingleManager.  We will appear to not support Jingle.  With the new
 * method you just call it once and all new connections will report Jingle support.)
 */
public static void setJingleServiceEnabled() {
    ProviderManager.addIQProvider("jingle", "urn:xmpp:tmp:jingle", new JingleProvider());

    // Enable the Jingle support on every established connection
    // The ServiceDiscoveryManager class should have been already
    // initialized
    XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() {
        @Override
        public void connectionCreated(XMPPConnection connection) {
            JingleManager.setServiceEnabled(connection, true);
        }
    });
}
 
Example #3
Source File: MessengerService.java    From KlyphMessenger with MIT License 5 votes vote down vote up
@Override
public void onCreate()
{
	Log.d(TAG, "onCreate");

	if (instance != null)
		Log.d(TAG, "instance is already defined !");

	instance = this;

	notificationsEnabled = MessengerPreferences.areNotificationsEnabled();
	ringtone = MessengerPreferences.getNotificationRingtone();
	ringtoneUri = MessengerPreferences.getNotificationRingtoneUri();
	vibrateEnabled = MessengerPreferences.isNotificationVibrationEnabled();

	chats = new ArrayList<Chat>();
	roster = new ArrayList<PRosterEntry>();
	savedMessages = new ArrayList<org.jivesoftware.smack.packet.Message>();
	pendingActions = new LinkedHashMap<String, Object>();

	configure(ProviderManager.getInstance());

	Connection.addConnectionCreationListener(new ConnectionCreationListener() {
		public void connectionCreated(Connection connection)
		{
			reconnectionManager = new ReconnectionManager(connection, ConnectionState.getInstance(MessengerService.this).isOnline());
			connection.addConnectionListener(reconnectionManager);
		}
	});

	registerReceiver(new BroadcastReceiver() {
		public void onReceive(Context context, Intent intent)
		{
			Log.i(TAG, "Connection status change to " + ConnectionState.getInstance(MessengerService.this).isOnline());
			onConnectivityChange();
		}
	}, new IntentFilter("android.net.conn.CONNECTIVITY_CHANGE"));

	connect();
}
 
Example #4
Source File: XmppService.java    From yiim_v2 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onCreate() {
	// TODO Auto-generated method stub
	super.onCreate();
	mHandlerProxy = new YiHandlerProxy(this, this);
	mXmppConnection = null;
	mXmppBinder = new XmppBinder(this);

	NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
	mNotificationManager = new com.ikantech.yiim.common.NotificationManager(
			this, mXmppBinder, notificationManager);
	mKeyguardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);

	mAVCallManager = new AVCallManager(this);

	mSoundPool = new SoundPool(3, AudioManager.STREAM_MUSIC, 0);
	mSoundIds = new HashMap<String, Integer>();
	mSoundIds.put(MSG_SOUND, mSoundPool.load(this, R.raw.office, 1));

	mVibrator = (Vibrator) getSystemService(Service.VIBRATOR_SERVICE);

	mLocker = new Object();
	mMultiUserChats = new HashMap<String, MultiUserChat>();
	mChats = new HashMap<String, Chat>();
	mNeedReInitMultiChatRooms = new ArrayList<String>();

	mMsgReceivedBroadcast = new MsgReceivedBroadcast();
	IntentFilter intentFilter = new IntentFilter();
	intentFilter.addAction(Const.NOTIFY_MSG_RECEIVED_OR_SENT);
	registerReceiver(mMsgReceivedBroadcast, intentFilter);

	mNetworkBroadcastReceiver = new NativeNetworkBroadcastReceiver();
	IntentFilter netIntentFilter = new IntentFilter();
	netIntentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
	registerReceiver(mNetworkBroadcastReceiver, netIntentFilter);

	Connection
			.addConnectionCreationListener(new ConnectionCreationListener() {
				@Override
				public void connectionCreated(Connection connection) {
					// TODO Auto-generated method stub
					initService(connection);
				}
			});

	getHandler().removeMessages(MSG_NETWORK_CONNECTED);
	getHandler().sendEmptyMessageDelayed(MSG_NETWORK_CONNECTED, 1300);
}