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 883B

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