-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwsend.ts
33 lines (28 loc) · 844 Bytes
/
wsend.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
import { readLines } from "jsr:@std/io/read-lines";
const BUILD_TIME = "2024_08_19-13_26";
const WEBSOCKET_CONNECTION_TYPE = "chart";
// /socket.io/websocket?from=chart&date=2024_08_19-13_26&type=chart
const target = "wss://data.tradingview.com/socket.io/websocket"; //"?from=chart&date="+ BUILD_TIME + "&type=" + WEBSOCKET_CONNECTION_TYPE
console.log(target);
const ws = new WebSocket(target, {
origin: "data.tradingview.com",
});
let fileReader = await Deno.open("./wsendmeg.txt");
// for await (let line of readLines(fileReader)) {
// console.log(line);
// ws.send(line);
// }
ws.onopen = async () => {
console.log(ws.readyState);
// const line = r.line;
// ws.send(line);
};
ws.onmessage = async (e) => {
console.log(e.data);
// ws.close();
};
ws.onclose = () => {
};
ws.onerror = (e) => {
console.log("onerror", e);
};