V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
workman2021
V2EX  ›  问与答

websocket 根据提供的 API 文档实现相应的功能思路大概有那几步呢?

  •  
  •   workman2021 · 2021-10-18 13:39:27 +08:00 · 604 次点击
    这是一个创建于 913 天前的主题,其中的信息可能已经有所发展或是发生改变。
    ### 客户端
    ```golang
    // Equipment request
    // Device heartbeat, the device sends a heartbeat packet to the server every 30 seconds.

    {
    "method": "heartBeat",
    "params": {
    "DeviceId": "ABCDEFG"
    },
    "req_id": 123
    }

    ```

    ### 服务器
    ```golang
    //Server response:

    {
    "method": " heartBeat", // Interface name
    "params" : {
    "Timestamp" : 123 //If the time needs to be synchronized, please fill it in, if you don’t need it, don’t fill it in, UTC time seconds UINT32
    },
    "result": 0, // return value, UINT32, 0 means success
    "req_id":123 //Transparent ID, UINT32
    }
    ```

    现在的需求就是服务器发请求到客户端 客户端返回对应的信息 到服务器

    看了一些 golang 相关的 ws 的内容和库 然而还是不知道具体实现步骤
    新手请教大家实现思路 谢谢
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   4429 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 01:05 · PVG 09:05 · LAX 18:05 · JFK 21:05
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.