Skip to content

Commit

Permalink
fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
EzraBrooks committed Mar 20, 2024
1 parent 929350c commit 624bfa3
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/core/Ros.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,18 @@ export default class Ros extends EventEmitter {
} else if (this.transportLibrary === 'websocket') {
if (!this.socket || this.socket.readyState === WebSocket.CLOSED) {
// Detect if in browser vs in NodeJS
if (typeof window !== undefined) {
this.socket = new WebSocket(url);
this.socket.binaryType = 'arraybuffer';
if (typeof window !== 'undefined') {
const sock = new WebSocket(url);
sock.binaryType = 'arraybuffer';
this.socket = Object.assign(sock, socketAdapter(this));
} else {
// if in Node.js, import ws to replace browser WebSocket API
import('ws').then((ws) => {
this.socket = new ws.WebSocket(url);
this.socket.binaryType = 'arraybuffer'
const sock = new ws.WebSocket(url);
sock.binaryType = 'arraybuffer'
this.socket = Object.assign(sock, socketAdapter(this));
})
}
var sock = typeof window !== 'undefined' ? new window.WebSocket(url) : new WebSocket(url);
sock.binaryType = 'arraybuffer';
this.socket = Object.assign(sock, socketAdapter(this));
}
} else {
throw 'Unknown transportLibrary: ' + this.transportLibrary.toString();
Expand Down

0 comments on commit 624bfa3

Please sign in to comment.