mirror of
https://github.com/m1k1o/neko.git
synced 2025-08-06 10:20:26 +02:00
use persistent autentication.
This commit is contained in:
parent
bc443cb3a0
commit
f796eb236b
6 changed files with 14 additions and 15 deletions
|
@ -25,14 +25,15 @@ export class NekoWebSocket extends EventEmitter<NekoWebSocketEvents> {
|
|||
return typeof this._ws !== 'undefined' && this._ws.readyState === WebSocket.OPEN
|
||||
}
|
||||
|
||||
public connect(url: string, password: string) {
|
||||
public connect(url: string, id: string, secret: string) {
|
||||
if (this.connected) {
|
||||
throw new Error('attempting to create websocket while connection open')
|
||||
}
|
||||
|
||||
this.emit('connecting')
|
||||
|
||||
this._ws = new WebSocket(`${url}ws?password=${password}`)
|
||||
const ws_url = url.replace(/^http/, 'ws').replace(/\/$|\/ws$/, '')
|
||||
this._ws = new WebSocket(`${ws_url}/ws?id=${encodeURIComponent(id)}&secret=${encodeURIComponent(secret)}`)
|
||||
this._log.debug(`connecting to ${this._ws.url}`)
|
||||
|
||||
this._ws.onopen = this.onConnected.bind(this)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue