Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 34 35 36 37 38 39 40 41 42 43 44 | 3x 3x 282x 282x 282x 282x 1x 282x 282x 282x 282x 3x 572x 3x 138x 3x 138x 138x 138x 138x 138x 3x | import * as net from "net";
import { EventEmitter } from "events";
import { Server } from "./server";
export interface ISocket {
write(buffer: Buffer): void;
end(): void;
remove(): void;
}
export class MemcachedSocket extends EventEmitter implements ISocket {
private _socket: net.Socket;
public server: Server;
constructor(socket: net.Socket, server: Server) {
super();
this._socket = socket;
this.server = server;
this._socket.on("error", (err: Error) => {
this.emit("error", err);
});
this._socket.on("timeout", () => this.emit("timeout"));
this._socket.on("close", () => this.emit("close"));
this._socket.on("connect", () => this.emit("connect"));
this._socket.on("data", (chunk: Buffer) => this.emit("data", chunk));
}
public async write(buffer: Uint8Array | string) {
this._socket.write(buffer);
}
public end() {
this._socket.end();
}
public remove() {
this._socket.removeAllListeners("error");
this._socket.removeAllListeners("timeout");
this._socket.removeAllListeners("connect");
this._socket.removeAllListeners("close");
this._socket.removeAllListeners("data");
}
}
|