Client does not need to be an EventEmitter

This commit is contained in:
Rik Berkelder 2021-01-23 22:36:50 +01:00
parent 1d32299fd4
commit 5fda0ab204
2 changed files with 7 additions and 8 deletions

View file

@ -1,6 +1,6 @@
{ {
"name": "ts-osc", "name": "ts-osc",
"version": "0.2.0", "version": "0.2.1",
"description": "Fully TypeScript-native OSC Client based on osc-min", "description": "Fully TypeScript-native OSC Client based on osc-min",
"main": "./lib/index.js", "main": "./lib/index.js",
"types": "./lib/index.d.ts", "types": "./lib/index.d.ts",

View file

@ -9,12 +9,11 @@ import { EventEmitter } from 'events';
const osc = new OSCClient("192.168.0.44", 8000) const osc = new OSCClient("192.168.0.44", 8000)
``` ```
*/ */
export class OSCClient extends EventEmitter { export class OSCClient {
private socket: dgram.Socket; private socket: dgram.Socket;
private host: string; private host: string;
private port: number; private port: number;
constructor(host: string, port: number) { constructor(host: string, port: number) {
super();
this.host = host; this.host = host;
this.port = port; this.port = port;
this.socket = dgram.createSocket({ type: 'udp4', reuseAddr: true }); this.socket = dgram.createSocket({ type: 'udp4', reuseAddr: true });
@ -25,11 +24,11 @@ export class OSCClient extends EventEmitter {
} }
/** /**
* Send an OSC message * Send an OSC message
``` ```
osc.send("/osc/url", OSCType.String, "hello") osc.send("/osc/url", OSCType.String, "hello")
``` ```
*/ */
public send<T extends OSCType>(address: string, type: T, value: OSCArgumentType<T>): void { public send<T extends OSCType>(address: string, type: T, value: OSCArgumentType<T>): void {
const arg: OSCArgument<T> = { const arg: OSCArgument<T> = {