diff options
author | Kitson Kelly <me@kitsonkelly.com> | 2019-03-10 04:30:38 +1100 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-03-09 12:30:38 -0500 |
commit | 034e2cc02829c9244b32232074c7a48af827a2fb (patch) | |
tree | bade01606a1ee076c1f753ce99c97ddb1e4edf30 /js/net.ts | |
parent | 8c7a12d1b258f0ef5ab27f49c424331d43e8d97f (diff) |
Migrate from tslint to eslint for linting (#1905)
Diffstat (limited to 'js/net.ts')
-rw-r--r-- | js/net.ts | 108 |
1 files changed, 54 insertions, 54 deletions
@@ -27,46 +27,22 @@ export interface Listener { addr(): Addr; } -class ListenerImpl implements Listener { - constructor(readonly rid: number) {} - - async accept(): Promise<Conn> { - const builder = flatbuffers.createBuilder(); - msg.Accept.startAccept(builder); - msg.Accept.addRid(builder, this.rid); - const inner = msg.Accept.endAccept(builder); - const baseRes = await dispatch.sendAsync(builder, msg.Any.Accept, inner); - assert(baseRes != null); - assert(msg.Any.NewConn === baseRes!.innerType()); - const res = new msg.NewConn(); - assert(baseRes!.inner(res) != null); - return new ConnImpl(res.rid(), res.remoteAddr()!, res.localAddr()!); - } - - close(): void { - close(this.rid); - } - - addr(): Addr { - return notImplemented(); - } +enum ShutdownMode { + // See http://man7.org/linux/man-pages/man2/shutdown.2.html + // Corresponding to SHUT_RD, SHUT_WR, SHUT_RDWR + Read = 0, + Write, + ReadWrite // unused } -export interface Conn extends Reader, Writer, Closer { - /** The local address of the connection. */ - localAddr: string; - /** The remote address of the connection. */ - remoteAddr: string; - /** The resource ID of the connection. */ - rid: number; - /** Shuts down (`shutdown(2)`) the reading side of the TCP connection. Most - * callers should just use `close()`. - */ - closeRead(): void; - /** Shuts down (`shutdown(2)`) the writing side of the TCP connection. Most - * callers should just use `close()`. - */ - closeWrite(): void; +function shutdown(rid: number, how: ShutdownMode): void { + const builder = flatbuffers.createBuilder(); + msg.Shutdown.startShutdown(builder); + msg.Shutdown.addRid(builder, rid); + msg.Shutdown.addHow(builder, how); + const inner = msg.Shutdown.endShutdown(builder); + const baseRes = dispatch.sendSync(builder, msg.Any.Shutdown, inner); + assert(baseRes == null); } class ConnImpl implements Conn { @@ -103,22 +79,46 @@ class ConnImpl implements Conn { } } -enum ShutdownMode { - // See http://man7.org/linux/man-pages/man2/shutdown.2.html - // Corresponding to SHUT_RD, SHUT_WR, SHUT_RDWR - Read = 0, - Write, - ReadWrite // unused +class ListenerImpl implements Listener { + constructor(readonly rid: number) {} + + async accept(): Promise<Conn> { + const builder = flatbuffers.createBuilder(); + msg.Accept.startAccept(builder); + msg.Accept.addRid(builder, this.rid); + const inner = msg.Accept.endAccept(builder); + const baseRes = await dispatch.sendAsync(builder, msg.Any.Accept, inner); + assert(baseRes != null); + assert(msg.Any.NewConn === baseRes!.innerType()); + const res = new msg.NewConn(); + assert(baseRes!.inner(res) != null); + return new ConnImpl(res.rid(), res.remoteAddr()!, res.localAddr()!); + } + + close(): void { + close(this.rid); + } + + addr(): Addr { + return notImplemented(); + } } -function shutdown(rid: number, how: ShutdownMode) { - const builder = flatbuffers.createBuilder(); - msg.Shutdown.startShutdown(builder); - msg.Shutdown.addRid(builder, rid); - msg.Shutdown.addHow(builder, how); - const inner = msg.Shutdown.endShutdown(builder); - const baseRes = dispatch.sendSync(builder, msg.Any.Shutdown, inner); - assert(baseRes == null); +export interface Conn extends Reader, Writer, Closer { + /** The local address of the connection. */ + localAddr: string; + /** The remote address of the connection. */ + remoteAddr: string; + /** The resource ID of the connection. */ + rid: number; + /** Shuts down (`shutdown(2)`) the reading side of the TCP connection. Most + * callers should just use `close()`. + */ + closeRead(): void; + /** Shuts down (`shutdown(2)`) the writing side of the TCP connection. Most + * callers should just use `close()`. + */ + closeWrite(): void; } /** Listen announces on the local network address. @@ -197,8 +197,8 @@ export async function dial(network: Network, address: string): Promise<Conn> { /** **RESERVED** */ export async function connect( - network: Network, - address: string + _network: Network, + _address: string ): Promise<Conn> { return notImplemented(); } |