Commit 5aac324e authored by ibuler's avatar ibuler

[Update] 添加重连

parent bef93b03
......@@ -74,6 +74,7 @@ export class ElementSshTermComponent implements OnInit, AfterViewInit, OnDestroy
'token': this.token, 'secret': this.secret,
'size': [this.term.cols, this.term.rows]
};
console.log('On token event trigger');
this.ws.emit('token', data);
}
......@@ -91,13 +92,14 @@ export class ElementSshTermComponent implements OnInit, AfterViewInit, OnDestroy
// 服务器主动断开
this.ws.on('disconnect', () => {
console.log('On disconnect event trigger');
this.close();
});
this.ws.on('logout', (msg) => {
const data = msg.unmarshal();
if (data.room === this.roomID) {
console.log('On logout: ', data.room, this.roomID);
console.log('On logout event trigger: ', data.room, this.roomID);
this.view.connected = false;
}
});
......
......@@ -27,7 +27,7 @@ export async function getWsSock(url: string, namespace: string): Promise<Socket>
const events = {};
events[namespace] = {
_OnNamespaceConnected: function (ns, msg) {
emitter.emit('connect', ns);
emitter.emit('connect', ns);
},
_OnNamespaceDisconnect: function (ns, msg) {
......@@ -46,7 +46,7 @@ export async function getWsSock(url: string, namespace: string): Promise<Socket>
emitter.emit(msg.Event, msg);
}
};
const options = {reconnnect: 5};
const options = {reconnect: 5000};
const conn = <neffos.Conn>await neffos.dial(url, events, options);
const nsConn = <neffos.NSConn>await conn.connect(namespace);
const sock = new Socket(nsConn, emitter);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment