This folder contains examples of usage of Food Fight in different scenarios
This is a simple demo showing usage of Direct transport in simple Ping-Pong scenario
- Build the library from the main directory:
yarn install && yarn build
- Run one terminal in
demos/direct-ping-pong
subdirectory - Start
node ping-pong.js
in the terminal - You should see flow of messages
- Every 4th message should get timed out (to show timeout scenario)
- We start by calling
ping
with counter that equals0
. - We call
pong
from withinping
with provided counter - We call
ping
from withinpong
with increased counter 4 We rinse and repeat until counter reaches10
5 As we delay eachpong
by 50ms and out max timeout equals 500ms, last pings and pongs are timed out- Notice that we are still waiting for the outermost ping resolution - this is the one that reaches timeout!
- All the pings and pongs are resolved with final counters (no more recurrency, returning final counter)
- Notice that we get 20 (well, actually - 19) final messages (2 for each
ping-pong
pair), as we have 10ping-pong
cycles
- Notice that we get 20 (well, actually - 19) final messages (2 for each