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>
|
||||||
<div v-if="loaded && !neko.connected">
|
<div v-if="loaded && !neko.connected">
|
||||||
<input type="text" placeholder="URL" v-model="url" />
|
<input type="text" placeholder="URL" v-model="url" />
|
||||||
<input type="text" placeholder="Password" v-model="pass" />
|
<input type="text" placeholder="Member ID" v-model="member_id" />
|
||||||
<input type="text" placeholder="Display Name" v-model="name" />
|
<input type="text" placeholder="Member Secret" v-model="member_secret" />
|
||||||
<button @click="connect()">Connect</button>
|
<button @click="connect()">Connect</button>
|
||||||
</div>
|
</div>
|
||||||
<button v-if="loaded && neko.connected" @click="disconnect()">Disonnect</button>
|
<button v-if="loaded && neko.connected" @click="disconnect()">Disonnect</button>
|
||||||
@ -236,12 +236,12 @@
|
|||||||
return this.neko.state.member.is_controlling
|
return this.neko.state.member.is_controlling
|
||||||
}
|
}
|
||||||
|
|
||||||
url: string = 'ws://192.168.1.20:3000/'
|
url: string = 'ws://192.168.1.20:3000/ws'
|
||||||
pass: string = 'admin'
|
member_id: string = 'admin'
|
||||||
name: string = 'test'
|
member_secret: string = 'admin'
|
||||||
|
|
||||||
connect() {
|
connect() {
|
||||||
this.neko.connect(this.url, this.pass, this.name)
|
this.neko.connect(this.url, this.member_id, this.member_secret)
|
||||||
}
|
}
|
||||||
|
|
||||||
disconnect() {
|
disconnect() {
|
||||||
|
@ -132,13 +132,12 @@
|
|||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
// Public methods
|
// Public methods
|
||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
public connect(url: string, password: string, name: string) {
|
public connect(url: string, id: string, secret: string) {
|
||||||
if (this.connected) {
|
if (this.connected) {
|
||||||
throw new Error('client already connected')
|
throw new Error('client already connected')
|
||||||
}
|
}
|
||||||
|
|
||||||
Vue.set(this.state.member, 'name', name)
|
this.websocket.connect(url, id, secret)
|
||||||
this.websocket.connect(url, password)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public disconnect() {
|
public disconnect() {
|
||||||
@ -241,7 +240,7 @@
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
let sdp = await this.webrtc.connect(payload.sdp, payload.lite, payload.ice)
|
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) {}
|
} catch (e) {}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -77,6 +77,7 @@ export class NekoMessages extends EventEmitter<NekoEvents> {
|
|||||||
//user.addMember(member)
|
//user.addMember(member)
|
||||||
|
|
||||||
if (member.id === this.state.member.id) {
|
if (member.id === this.state.member.id) {
|
||||||
|
Vue.set(this.state.member, 'name', member.name)
|
||||||
Vue.set(this.state.member, 'is_admin', member.admin)
|
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
|
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) {
|
if (this.connected) {
|
||||||
throw new Error('attempting to create websocket while connection open')
|
throw new Error('attempting to create websocket while connection open')
|
||||||
}
|
}
|
||||||
|
|
||||||
this.emit('connecting')
|
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._log.debug(`connecting to ${this._ws.url}`)
|
||||||
|
|
||||||
this._ws.onopen = this.onConnected.bind(this)
|
this._ws.onopen = this.onConnected.bind(this)
|
||||||
|
@ -76,7 +76,6 @@ export interface SignalAnswerMessage extends WebSocketMessage, SignalAnswerPaylo
|
|||||||
}
|
}
|
||||||
export interface SignalAnswerPayload {
|
export interface SignalAnswerPayload {
|
||||||
sdp: string
|
sdp: string
|
||||||
displayname: string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
export interface Member {
|
export interface Member {
|
||||||
id: string
|
id: string
|
||||||
displayname: string
|
name: string
|
||||||
admin: boolean
|
admin: boolean
|
||||||
muted: boolean
|
|
||||||
connected?: boolean
|
connected?: boolean
|
||||||
ignored?: boolean
|
ignored?: boolean
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user