Implement WSHello
parent
b870fe214c
commit
4f67439042
35
js/ln.vue.js
35
js/ln.vue.js
|
@ -192,7 +192,21 @@
|
|||
this.closing = false;
|
||||
|
||||
this.websocket = new WebSocket(this.options.url);
|
||||
this.websocket.onopen = (e) =>{ console.log("WebSocket connected"); this._state = "ONLINE"; };
|
||||
this.websocket.onopen = (e) =>{
|
||||
console.log("WebSocket connected");
|
||||
this._state = "ONLINE";
|
||||
|
||||
let WSHello = {
|
||||
ApplicationSessionID: this.LNVue.sessionID(),
|
||||
};
|
||||
console.log("WSHello request",WSHello);
|
||||
|
||||
this.request("WSHello",WSHello)
|
||||
.then((wsh)=>{
|
||||
console.log("WSHello response",wsh);
|
||||
this.LNVue.sessionID(wsh.message.ApplicationSessionID);
|
||||
});
|
||||
};
|
||||
this.websocket.onclose = (e)=>{ this._onclose(e); this._state = "OFFLINE"; };
|
||||
this.websocket.onerror = (e)=>{ this._onerror(e); this._state = "ERROR"; };
|
||||
this.websocket.onmessage = (e)=>{ this._onmessage(e); };
|
||||
|
@ -345,7 +359,26 @@
|
|||
});
|
||||
}
|
||||
|
||||
storage(){
|
||||
return window.localStorage;
|
||||
}
|
||||
|
||||
sessionID(){
|
||||
if (arguments.length == 1){
|
||||
this.storage().setItem("LNVueSessionID",arguments[0]);
|
||||
console.log("LNVue.SID <= " + arguments[0]);
|
||||
return this;
|
||||
} else
|
||||
{
|
||||
let sid = this.storage().getItem("LNVueSessionID");
|
||||
console.log("LNVue.SID == " + sid);
|
||||
if (!sid)
|
||||
{
|
||||
sid = "00000000-0000-0000-0000-000000000000";
|
||||
}
|
||||
return sid;
|
||||
}
|
||||
}
|
||||
|
||||
Version(){ return "0.2alpha"; };
|
||||
getCurrentPromises() {
|
||||
|
|
Loading…
Reference in New Issue