-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdemo.ts
42 lines (27 loc) · 859 Bytes
/
demo.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// a
import SwapChat from "./src/swapchat";
const apiURL = "http://localhost:1633";
const debugURL = "http://localhost:1635";
const swapChatA = new SwapChat(apiURL, debugURL, console.log);
let sessionA;
swapChatA.initiate().then((a) => {
sessionA = a;
return sessionA.getToken();
});
sessionA.getToken();
sessionA.waitForRespondentHandshakeChunk().then(console.log);
let message_A_0 = "hello world one";
await sessionA.send(message_A_0);
// b
import SwapChat from "./src/swapchat";
const apiURL = "http://localhost:1633";
const debugURL = "http://localhost:1635";
const swapChatB = new SwapChat(apiURL, debugURL, console.log);
let sessionB;
swapChatB.respond(token).then((b) => {
sessionB = b;
});
await sessionB.waitForInitiatorHandshakeChunk();
const index_B_0 = 0;
const message_B_0 = "hello world too";
await sessionA.send(message_B_0);