workman2021
V2EX  ›  问与答

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

  •  
  •   workman2021 · Oct 18, 2021 · 1567 views
    This topic created in 1670 days ago, the information mentioned may be changed or developed.
    ### 客户端
    ```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 的内容和库 然而还是不知道具体实现步骤
    新手请教大家实现思路 谢谢
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   926 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 19:36 · PVG 03:36 · LAX 12:36 · JFK 15:36
    ♥ Do have faith in what you're doing.