/// /** * @module core */ import { Account, GameState, Server } from './models'; import { Socket } from 'net'; import { PacketIO, WorldPosData, CreateSuccessPacket } from '../net'; import { PlayerData } from '../common'; import { MapInfo } from './models/map'; import { EventEmitter } from 'events'; /** * A lightweight client for a clientless application * which will reply to any necessary packets in order to stay connected. */ export declare class Client extends EventEmitter { /** * The object id of this client when connected, * and `undefined` if the client is not connected. */ objectId: number; /** * The current position of this client when connected, * and `undefined` if the client is not connected */ position: WorldPosData; /** * The stat data of this client when it is connected, and `undefined` * if the client is not connected. */ stats: PlayerData; /** * The map which the client is currently connected to, * or `undefined` if the client is not connected. */ map: MapInfo; /** * Information about this client's account. */ account: Account; /** * @readonly * Whether or not the socket is currently connected. */ readonly connected: boolean; /** * The packet interface for this client. */ readonly io: PacketIO; /** * @readonly * The time in milliseconds since this client was created. */ readonly time: number; /** * The last server that this client was connected to. */ readonly lastServer: Server; private _connected; private _time; private _lastServer; private eventHandlers; /** * Creates a new client for the specified account. * @param account The account to create this client for. */ constructor(account: Account); /** * Attaches the client to the `Socket`. * @param socket The socket to attach to. */ attach(socket: Socket): void; /** * Detaches this client from its socket. */ detach(): void; /** * Connects to the specified game server. If no server is specified then * the hello handshake will be initiated. If a server is specified the * socket will be connected to the server before beginning the handshake. * @param gameState The state to use when connecting. * @param server The server to connect to. */ connect(gameState: GameState, server?: Server): Promise; /** * Disconnects the client from the current server. */ disconnect(): Promise; private onConnect; private onClose; private emitError; private log; }