-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchatroom.js
38 lines (28 loc) · 1.02 KB
/
chatroom.js
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
import { useWebSocketImplementation } from 'nostr-tools/pool';
import WebSocket from "ws"
useWebSocketImplementation(WebSocket);
import { SimplePool } from 'nostr-tools/pool'
import { resolve } from 'import-meta-resolve';
async function getModulePath() {
const modulePath = await resolve('nostr-tools/pool', import.meta.url);
console.log(modulePath);
}
getModulePath();
const pool = new SimplePool()
let relays = [
'wss://relay1.nostrchat.io',
'wss://relay2.nostrchat.io',
'wss://relay.damus.io',
'wss://relay.snort.social',
'wss://nos.lol',
];
//let hub = "ws://relay.xxxx.com/"; //relay_hub
let hub = "";
relays = relays.map(relay => hub + relay );
//let events = await pool.querySync(relays, { kinds: [0, 1] })
let msg = [{"kinds":[41,5],"#e":["f412192fdc846952c75058e911d37a7392aa7fd2e727330f4344badc92fb8a22"]},{"kinds":[42],"#e":["f412192fdc846952c75058e911d37a7392aa7fd2e727330f4344badc92fb8a22"],"limit":30}]
pool.subscribeMany(relays,msg,{
onevent(data){
console.log(data.content)
}
})