Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

manager.disconnect无效 #45

Closed
wanyt opened this issue Feb 28, 2018 · 3 comments
Closed

manager.disconnect无效 #45

wanyt opened this issue Feb 28, 2018 · 3 comments

Comments

@wanyt
Copy link

wanyt commented Feb 28, 2018

在onDestory里面调用disconnect,重新打开应用的时候,再次链接会多次触发onSocketConnectionSuccess,这个怎么解决

@xuuhaoo
Copy link
Owner

xuuhaoo commented Feb 28, 2018

您加我qq吧183459684,有可能你的Activity对象没有销毁,导致注册了多个监听器对象,你的监听器对象估计是个匿名内部类

@santosunny
Copy link

在onDestroy生命周期里调用unregister方法,
@OverRide
protected void onDestroy() {
super.onDestroy();
if (manager != null && manager.isConnect()) {
manager.disConnect();
manager.unRegisterReceiver(adapter);
manager = null;
}
}
或者监听器只随manager的创建绑定一次
manager = OkSocket.open(info);
manager.registerReceiver(adapter);

@xuuhaoo
Copy link
Owner

xuuhaoo commented Mar 1, 2018

完美解决,谢谢 @santosunny

@xuuhaoo xuuhaoo closed this as completed Mar 1, 2018
xuuhaoo pushed a commit that referenced this issue May 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants