@s2script/net 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +19 -0
- package/package.json +15 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** @s2script/net — engine-generic raw TCP + UDP sockets (binary), off the game thread. */
|
|
2
|
+
export interface TcpSocket {
|
|
3
|
+
send(data: Uint8Array | string): void;
|
|
4
|
+
onData(handler: (bytes: Uint8Array) => void): void;
|
|
5
|
+
onClose(handler: () => void): void;
|
|
6
|
+
onError(handler: (err: string) => void): void;
|
|
7
|
+
close(): void;
|
|
8
|
+
}
|
|
9
|
+
export interface UdpSocket {
|
|
10
|
+
sendTo(host: string, port: number, data: Uint8Array | string): void;
|
|
11
|
+
onMessage(handler: (from: { host: string; port: number }, bytes: Uint8Array) => void): void;
|
|
12
|
+
close(): void;
|
|
13
|
+
}
|
|
14
|
+
export declare const Net: {
|
|
15
|
+
/** Connect a TCP client. Rejects on connect failure. */
|
|
16
|
+
connectTcp(host: string, port: number): Promise<TcpSocket>;
|
|
17
|
+
/** Bind a UDP socket on an ephemeral local port. */
|
|
18
|
+
udp(): Promise<UdpSocket>;
|
|
19
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@s2script/net",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"types": "index.d.ts",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"index.d.ts"
|
|
10
|
+
],
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/GabeHirakawa/s2script.git"
|
|
14
|
+
}
|
|
15
|
+
}
|