feat(plugins): add c2.WebSocket (#6076)

This commit is contained in:
nerix
2025-04-07 19:38:10 +02:00
committed by GitHub
parent d3bab9132f
commit ab66be21b3
31 changed files with 1859 additions and 29 deletions
+23 -1
View File
@@ -1,6 +1,6 @@
/** @noSelfInFile */
declare module c2 {
declare namespace c2 {
enum LogLevel {
Debug,
Info,
@@ -129,4 +129,26 @@ declare module c2 {
function register_callback<T>(type: T, func: CbFunc<T>): void;
function later(callback: () => void, msec: number): void;
interface WebSocket {
close(): void;
send_text(data: string): void;
send_binary(data: string): void;
on_close: null | (() => void);
on_text: null | ((data: string) => void);
on_binary: null | ((data: string) => void);
}
interface WebSocketConstructor {
new: (
this: void,
url: string,
options?: {
headers?: Record<string, string>;
on_close?: () => void;
on_text?: (data: string) => void;
on_binary?: (data: string) => void;
}
) => WebSocket;
}
var WebSocket: WebSocketConstructor;
}