You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TestFrontend.ts 930B

1234567891011121314151617181920212223
  1. import { RPCSocket } from '../src/Frontend'
  2. const client = new RPCSocket(20000, 'localhost')
  3. client.connect().then(async _ => {
  4. await client.info().then(console.log)
  5. await client["HelloWorldRPCGroup"].echo("x")
  6. .then(hopefullyX => console.log("echo('x') returned x: ", hopefullyX === "x", hopefullyX))
  7. await client["HelloWorldRPCGroup"].add(1,2,3)
  8. .then(hopefully6 => console.log("add(1,2,3) returned 6: ", hopefully6 === 6, hopefully6))
  9. let counter = 0
  10. const handler = (s) => {
  11. counter++
  12. if(counter === 3)
  13. console.log("callback was called 3 times", counter === 3)
  14. }
  15. await client["HelloWorldRPCGroup"].subscribe(handler)
  16. client["HelloWorldRPCGroup"].triggerCallback("test1", "test1", "test1", )
  17. client["HelloWorldRPCGroup"].triggerCallback("test2", "test2", "test2", )
  18. client["HelloWorldRPCGroup"].triggerCallback("test3", "test3", "test3", )
  19. })