Skip to content
This repository was archived by the owner on Jul 16, 2025. It is now read-only.
This repository was archived by the owner on Jul 16, 2025. It is now read-only.

Rapid-fire sends regardless of interval. #11

Description

@zimmed

I used the socket.io example to implement timesync using basic websockets (not a fan of socket.io's overhead and lack of binary buffers). Here is the gist of the implementation:

Server

socket.on('timesync', data  => socket.send('timesync', {
    id: data && data.id || null,
    result: Date.now()
}));

Client

const ts = require('timesync').create({server: socket});
ts.send = (socket, data) => socket.send('timesync', data); // Sends {jsonrpc: "2.0", id: null, result: <timestamp>}
socket.on('timesync', data => ts.receive(null, data)); // Receives {id: null, result: <timestamp>}

The issue is that hundreds of timesync requests are being sent per second, even though each is receiving a correct response. I have tried create({server: socket, interval: 5000}) as in the socket.io example, but am getting the same result. I'm not sure if I'm missing something, or if there's a bug. Any help would be appreciated.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions