Switch to yarn

This commit is contained in:
Jonathan Staab
2023-07-07 16:34:44 -07:00
parent b74f2e8e3d
commit 46470aabe4
6 changed files with 2672 additions and 8564 deletions
+3 -3
View File
@@ -4,11 +4,11 @@ export class Relay {
constructor(socket) {
this.socket = socket
this.bus = new EventBus()
this.listeners = sockets.map(socket => {
return socket.bus.addListener('message', (url, [verb, ...payload]) => {
this.listeners = [
socket.bus.addListener('message', (url, [verb, ...payload]) => {
this.bus.emit(verb, url, ...payload)
})
})
]
}
get sockets() {
return [this.socket]
+21 -25
View File
@@ -27,34 +27,30 @@ export class Socket {
this.queue = []
this.bus = new EventBus()
this.status = Socket.STATUS.NEW
}
onOpen() {
this.error = undefined
this.status = Socket.STATUS.READY
this.ready.resolve()
this.bus.emit('open')
}
onMessage(event) {
this.queue.push(event.data as string)
this._onOpen = () => {
this.error = undefined
this.status = Socket.STATUS.READY
this.ready.resolve()
this.bus.emit('open')
}
this._onMessage = event => {
this.queue.push(event.data as string)
if (!this.timeout) {
this.handleMessagesAsync()
}
}
this._onError = (error: Error) => {
this.error = error
this.bus.emit('error', error)
}
this._onClose = () => {
this.disconnect()
this.ready.reject()
this.status = Socket.STATUS.CLOSED
this.bus.emit('close')
if (!this.timeout) {
this.handleMessagesAsync()
}
}
onError(error: Error) {
this.error = error
this.bus.emit('error', error)
}
onClose() {
this.disconnect()
this.ready.reject()
this.status = Socket.STATUS.CLOSED
this.bus.emit('close')
}
async connect() {
if ([Socket.STATUS.NEW, Socket.STATUS.CLOSED].includes(this.status)) {
if (this.ws) {