add support for binary JPEG (server)
This commit is contained in:
@@ -33,6 +33,7 @@ export default class WSClient extends EventEmitter implements NetworkClient {
|
||||
getIP(): string {
|
||||
return this.ip;
|
||||
}
|
||||
|
||||
send(msg: string): Promise<void> {
|
||||
return new Promise((res, rej) => {
|
||||
if (!this.isOpen()) res();
|
||||
@@ -47,6 +48,20 @@ export default class WSClient extends EventEmitter implements NetworkClient {
|
||||
});
|
||||
}
|
||||
|
||||
sendBinary(msg: Uint8Array): Promise<void> {
|
||||
return new Promise((res, rej) => {
|
||||
if (!this.isOpen()) res();
|
||||
|
||||
this.socket.send(msg, (err) => {
|
||||
if (err) {
|
||||
rej(err);
|
||||
return;
|
||||
}
|
||||
res();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
close(): void {
|
||||
if (this.isOpen()) {
|
||||
// While this seems counterintutive, do note that the WebSocket protocol
|
||||
|
||||
Reference in New Issue
Block a user