UNPKG

@hrtk92/mcwsjs

Version:

![npm](https://img.shields.io/npm/v/@hrtk92/mcwsjs) ![npm](https://img.shields.io/npm/dt/%40hrtk92%2Fmcwsjs) [![GitHub Release](https://github.com/HRTK92/mcws.js/actions/workflows/release.yml/badge.svg)](https://github.com/HRTK92/mcws.js/actions/workflows

35 lines (34 loc) 960 B
import { WebSocket } from 'ws'; type Data = { header: { messagePurpose: string; requestId: string; version: number; }; body: { eventName: string; [key: string]: any; }; }; declare class mswc { private host; private port; private server; private ws; private debug; constructor(host?: string, port?: number, debug?: boolean); private readyCallback; onReady(callback: (host: string, port: number) => void): void; private connectionCallback; onConnection(callback: (client: WebSocket) => void): void; private dissconnectCallback; onDisconnect(callback: () => void): void; private eventCallbacks; on(eventName: string, callback: (data: Data) => void): void; createServer(): void; disconnect(): void; subscribe(eventName: string): void; unsubscribe(eventName: string): void; sendCommand(command: string): void; } export default mswc;