Giter Site home page Giter Site logo

Comments (5)

xuuhaoo avatar xuuhaoo commented on May 5, 2024

你的代码如何写的 能否贴出

from oksocket.

dzghxs avatar dzghxs commented on May 5, 2024

//连接参数设置(IP,端口号),这也是一个连接的唯一标识,不同连接,该参数中的两个值至少有其一不一样
ConnectionInfo info = new ConnectionInfo(bean.getData().get(0).getWwIpAddress(), bean.getData().get(0).getPort());
//调用OkSocket,开启这次连接的通道,拿到通道Manager
manager = OkSocket.open(info);
options = OkSocketOptions.getDefault();
//获得当前连接通道的参配对象
options= manager.getOption();
//基于当前参配对象构建一个参配建造者类
builder = new OkSocketOptions.Builder(options);
builder.setPulseFeedLoseTimes(10);
builder.setPulseFrequency(1000*30);
//建造一个新的参配对象并且付给通道
manager.option(builder.build());
//注册Socket行为监听器,SocketActionAdapter是回调的Simple类,其他回调方法请参阅类文档
manager.registerReceiver(new SocketActionAdapter(){
@OverRide
public void onSocketConnectionSuccess(Context context, ConnectionInfo info, String action) {
Toast.makeText(context, "连接成功", Toast.LENGTH_SHORT).show();
if(manager != null){
PulseManager pulseManager = manager.getPulseManager();
//给心跳管理器设置心跳数据,一个连接只有一个心跳管理器,因此数据只用设置一次,如果断开请再次设置.
pulseManager.setPulseSendable(new PulseBean(MobileMessageUtils.getIMEI(OkSocketService.this),String.valueOf(SPUtils.get(OkSocketService.this, Filed.USERID, ""))));
//开始心跳,开始心跳后,心跳管理器会自动进行心跳触发
pulseManager.pulse();
}
}
}
我先跟服务器进行连接,连接通了之后就发送心跳包,但是服务器接收不到,只有关闭才能收到

from oksocket.

xuuhaoo avatar xuuhaoo commented on May 5, 2024

我的qq 183459684.可以加我qq帮助你排查问题

from oksocket.

xuuhaoo avatar xuuhaoo commented on May 5, 2024

我没有看到你的连接行为,您有没有调用connect方法

from oksocket.

dzghxs avatar dzghxs commented on May 5, 2024

已解决,谢谢

from oksocket.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.