transformice.js
Version:
Node.js client for Transformice with full Typescript support.
42 lines (41 loc) • 1.23 kB
TypeScript
/// <reference types="node" />
import net from "net";
import { EventEmitter } from "events";
import { ByteArray, ValueOf } from ".";
import { cipherMethods, identifiers } from "../enums";
/**
* Represents a client that connects to Transformice.
*
* @hidden
*/
export default class Connection extends EventEmitter {
socket: net.Socket;
open: boolean;
fingerprint: number;
buffer: Buffer;
length: number;
private identificationKeys;
private messageKeys;
/**
* Constructor.
* @example
* ```js
* const conn = new Connection(client, 'connectionName');
* ```
*/
constructor(identificationKeys: number[], messageKeys: number[]);
/**
* Connects the socket.
*/
connect(host: string, port: number): void;
/**
* Sends a packet to the connection.
* @param {ByteArray} packet - The packet.
* @param {enums.cipherMethod} [method=enums.cipherMethod.none] - The algorithm method to cipher the packet with it.
*/
send(identifier: ValueOf<typeof identifiers>, packet: ByteArray, method?: ValueOf<typeof cipherMethods>): void;
/**
* Close the connection.
*/
close(): void;
}