net.ts 1.1 KB
Newer Older
K
Kyle Carberry 已提交
1
import * as net from "net";
A
Asher 已提交
2
import { Client } from '../client';
K
Kyle Carberry 已提交
3 4 5 6 7 8 9 10

type NodeNet = typeof net;

/**
 * Implementation of net for the browser.
 */
export class Net implements NodeNet {

A
Asher 已提交
11 12 13 14
	public constructor(
		private readonly client: Client,
	) {}

K
Kyle Carberry 已提交
15
	public get Socket(): typeof net.Socket {
A
Asher 已提交
16
		throw new Error("not implemented");
K
Kyle Carberry 已提交
17 18 19
	}

	public get Server(): typeof net.Server {
A
Asher 已提交
20
		throw new Error("not implemented");
K
Kyle Carberry 已提交
21 22 23 24 25 26
	}

	public connect(): net.Socket {
		throw new Error("not implemented");
	}

A
Asher 已提交
27 28 29
	public createConnection(...args: any[]): net.Socket {
		//@ts-ignore
		return this.client.createConnection(...args) as net.Socket;
K
Kyle Carberry 已提交
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
	}

	public isIP(_input: string): number {
		throw new Error("not implemented");
	}

	public isIPv4(_input: string): boolean {
		throw new Error("not implemented");
	}

	public isIPv6(_input: string): boolean {
		throw new Error("not implemented");
	}

	public createServer(
		_options?: { allowHalfOpen?: boolean, pauseOnConnect?: boolean } | ((socket: net.Socket) => void),
		_connectionListener?: (socket: net.Socket) => void,
A
Asher 已提交
47 48
	): net.Server {
		throw new Error("not implemented");
K
Kyle Carberry 已提交
49 50 51
	}

}