feat: Add 'connecting' event

As described in the [comment here](https://github.com/yjs/y-websocket/issues/7#issuecomment-623114183), a "connecting" event is useful for monkey-patching the authentication process in lieu of a more official API.

Seems like this is a no-brainer addition.
This commit is contained in:
Tom Moor 2020-10-15 15:12:04 -07:00 committed by GitHub
parent 5a36d77d48
commit 72c9978ceb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -84,6 +84,11 @@ const setupWS = provider => {
provider.wsconnecting = true provider.wsconnecting = true
provider.wsconnected = false provider.wsconnected = false
provider.synced = false provider.synced = false
provider.emit('status', [{
status: 'connecting'
}])
websocket.onmessage = event => { websocket.onmessage = event => {
provider.wsLastMessageReceived = time.getUnixTime() provider.wsLastMessageReceived = time.getUnixTime()
const encoder = readMessage(provider, new Uint8Array(event.data), true) const encoder = readMessage(provider, new Uint8Array(event.data), true)