mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
use persistent autentication.
This commit is contained in:
parent
bc443cb3a0
commit
f796eb236b
12
src/app.vue
12
src/app.vue
@ -180,8 +180,8 @@
|
||||
<div>
|
||||
<div v-if="loaded && !neko.connected">
|
||||
<input type="text" placeholder="URL" v-model="url" />
|
||||
<input type="text" placeholder="Password" v-model="pass" />
|
||||
<input type="text" placeholder="Display Name" v-model="name" />
|
||||
<input type="text" placeholder="Member ID" v-model="member_id" />
|
||||
<input type="text" placeholder="Member Secret" v-model="member_secret" />
|
||||
<button @click="connect()">Connect</button>
|
||||
</div>
|
||||
<button v-if="loaded && neko.connected" @click="disconnect()">Disonnect</button>
|
||||
@ -236,12 +236,12 @@
|
||||
return this.neko.state.member.is_controlling
|
||||
}
|
||||
|
||||
url: string = 'ws://192.168.1.20:3000/'
|
||||
pass: string = 'admin'
|
||||
name: string = 'test'
|
||||
url: string = 'ws://192.168.1.20:3000/ws'
|
||||
member_id: string = 'admin'
|
||||
member_secret: string = 'admin'
|
||||
|
||||
connect() {
|
||||
this.neko.connect(this.url, this.pass, this.name)
|
||||
this.neko.connect(this.url, this.member_id, this.member_secret)
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
|
@ -132,13 +132,12 @@
|
||||
/////////////////////////////
|
||||
// Public methods
|
||||
/////////////////////////////
|
||||
public connect(url: string, password: string, name: string) {
|
||||
public connect(url: string, id: string, secret: string) {
|
||||
if (this.connected) {
|
||||
throw new Error('client already connected')
|
||||
}
|
||||
|
||||
Vue.set(this.state.member, 'name', name)
|
||||
this.websocket.connect(url, password)
|
||||
this.websocket.connect(url, id, secret)
|
||||
}
|
||||
|
||||
public disconnect() {
|
||||
@ -241,7 +240,7 @@
|
||||
|
||||
try {
|
||||
let sdp = await this.webrtc.connect(payload.sdp, payload.lite, payload.ice)
|
||||
this.websocket.send('signal/answer', { sdp, displayname: this.state.member.name })
|
||||
this.websocket.send('signal/answer', { sdp })
|
||||
} catch (e) {}
|
||||
break
|
||||
}
|
||||
|
@ -77,6 +77,7 @@ export class NekoMessages extends EventEmitter<NekoEvents> {
|
||||
//user.addMember(member)
|
||||
|
||||
if (member.id === this.state.member.id) {
|
||||
Vue.set(this.state.member, 'name', member.name)
|
||||
Vue.set(this.state.member, 'is_admin', member.admin)
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -76,7 +76,6 @@ export interface SignalAnswerMessage extends WebSocketMessage, SignalAnswerPaylo
|
||||
}
|
||||
export interface SignalAnswerPayload {
|
||||
sdp: string
|
||||
displayname: string
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1,8 +1,7 @@
|
||||
export interface Member {
|
||||
id: string
|
||||
displayname: string
|
||||
name: string
|
||||
admin: boolean
|
||||
muted: boolean
|
||||
connected?: boolean
|
||||
ignored?: boolean
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user