A simple ping client and server implementation using HRPC (Holepunch RPC).
- Install dependencies:
npm install- Generate the schema and HRPC interface:
npm run setupThis will create the spec/ directory with the generated schema and RPC code.
In one terminal:
npm run serverThe server will listen on port 3000.
In another terminal:
npm run clientOr send a custom message:
npm run client "Your custom ping message"- Schema Definition: The
setup-schema.jsdefines the ping request/response schemas using Hyperschema - Server: Listens for ping requests and responds with a pong message including timestamps
- Client: Connects to the server, sends a ping, and displays the response with round-trip time
message(string): The ping messagetimestamp(uint): Client timestamp
message(string): The pong messagetimestamp(uint): Original client timestampserverTime(uint): Server timestamp