Skip to content

makevoid/try_hrpc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HRPC Ping Example

A simple ping client and server implementation using HRPC (Holepunch RPC).

Setup

  1. Install dependencies:
npm install
  1. Generate the schema and HRPC interface:
npm run setup

This will create the spec/ directory with the generated schema and RPC code.

Usage

Start the server

In one terminal:

npm run server

The server will listen on port 3000.

Run the client

In another terminal:

npm run client

Or send a custom message:

npm run client "Your custom ping message"

How it works

  • Schema Definition: The setup-schema.js defines 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

Schema

Ping Request

  • message (string): The ping message
  • timestamp (uint): Client timestamp

Ping Response

  • message (string): The pong message
  • timestamp (uint): Original client timestamp
  • serverTime (uint): Server timestamp

About

A simple ping client and server implementation using HRPC (Holepunch RPC).

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published