forked from colinbdclark/osc.js
-
Notifications
You must be signed in to change notification settings - Fork 1
/
osc.d.ts
138 lines (101 loc) · 3.47 KB
/
osc.d.ts
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
declare module "osc" {
export class EventEmitter<T>{
addListener<E extends keyof T>(event: E, listener: T[E]): this;
on<E extends keyof T>(event: E, listener: T[E]): this;
once<E extends keyof T>(event: E, listener: T[E]): this;
removeListener<E extends keyof T>(event: E, listener: T[E]): this;
removeAllListeners(event?: keyof T): this;
setMaxListeners(n: number): this;
getMaxListeners(): number;
listeners<E extends keyof T>(event: E): T[E][];
emit(event: string | symbol, ...args: any[]): boolean;
listenerCount(type: keyof T): number;
// Added in Node 6...
prependListener<E extends keyof T>(event: E, listener: T[E]): this;
prependOnceListener<E extends keyof T>(event: E, listener: T[E]): this;
eventNames(): Array<keyof T>;
}
export const defaults: {
metadata: boolean;
unpackSingleArgs: boolean;
};
export type Argument = number | string | Uint8Array;
export type MetaArgument =
{ type: 'i' | 'f', value: number }
| { type: 's', value: string }
| { type: 'b', value: Uint8Array };
export abstract class SLIPPort {
}
export interface OscMessage {
address: string;
args: Argument | Array<Argument> | MetaArgument | Array<MetaArgument>;
}
export interface OscBundle {
}
export interface SenderInfo {
address: string;
port: number;
size: number;
family: 'IPv4' | 'IPv6';
}
export interface PortEvents {
ready: () => void;
message: (message: OscMessage, timeTag: number | undefined, info: SenderInfo) => void;
bundle: (bundle: OscBundle, timeTag: number, info: SenderInfo) => void;
osc: (packet: OscBundle | OscMessage, info: SenderInfo) => void;
raw: (data: Uint8Array, info: SenderInfo) => void;
error: (err: Error) => void;
}
export interface UdpOptions {
/**
* The port to listen on
*/
localPort?: number; // 57121
/**
* The local address to bind to
*/
localAddress?: string; // '127.0.0.1'
/**
* The remote port to send messages to
*/
remotePort?: number;
/**
* The remote address to send messages to
*/
remoteAddress?: string;
broadcast?: boolean; // false
/**
* The time to live (number of hops) for a multicast connection
*/
multicastTTL?: number;
/**
* An array of multicast addresses to join when listening for multicast messages
*/
multicastMembership?: string[];
socket?: any;
/**
* should message arguments be wrapped with type?
*/
metadata?: boolean;
unpackSingleArgs?: boolean;
}
export interface OscSender {
send(msg: OscMessage, address?: string, port?: number): void;
}
export abstract class Port extends EventEmitter<PortEvents> implements OscSender {
send(msg: OscMessage, address?: string, port?: number): void;
}
export class SerialPort extends SLIPPort {
open(): void;
close(): void;
listen(): void;
}
export class UDPPort extends Port {
static setupMulticast(that: UDPPort): void;
options: UdpOptions;
constructor(options: UdpOptions);
open(): void;
close(): void;
listen(): void;
}
}