use of com.lingtuan.firefly.xmpp.LoginThread in project SmartMesh_Android by SmartMeshFoundation.
the class XmppService method onStartCommand.
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
if (intent != null) {
if (XmppAction.ACTION_LOGIN.equals(intent.getAction())) {
// The login
if (intent.getExtras() != null) {
Bundle mBundle = intent.getExtras().getBundle(XmppAction.ACTION_LOGIN);
String[] uNamePwd = mBundle.getStringArray(XmppAction.ACTION_LOGIN);
String username = uNamePwd[0];
String password = uNamePwd[1];
if (!XmppUtils.isLogining) {
new LoginThread(mHandler, username, password).start();
}
}
} else if (XmppAction.ACTION_LOGIN_MESSAGE_LISTENER.equals(intent.getAction())) {
try {
mXmppUtils = XmppUtils.getInstance();
if (mPacketListener != null) {
mXmppUtils.getConnection().removePacketListener(mPacketListener);
}
mXmppUtils.sendOnLine();
mPacketListener = new NextPacketListener();
mXmppUtils.getConnection().addPacketListener(mPacketListener, new PacketFilter() {
@Override
public boolean accept(Packet packet) {
return true;
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
}
return super.onStartCommand(intent, flags, startId);
}
Aggregations