feat: update

parent ae020d43
......@@ -24,10 +24,12 @@ class SSHws(Namespace):
# self.chan.settimeout(0.1)
self.socketio.start_background_task(self.sent_data, self, self.clients[request.sid]["chan"][connection],
self.clients[request.sid]["room"],
connection)
connection, request.sid)
def sent_data(self, s, chan, room, connection):
def sent_data(self, s, chan, room, connection, sid):
while True:
if connection not in s.clients[sid]["chan"].keys():
return
try:
data = chan.recv(2048).decode('utf-8', 'replace')
s.emit(event='data', data={"data": data, "room": connection}, room=room)
......@@ -61,8 +63,8 @@ class SSHws(Namespace):
def on_host(self, message):
connection = str(uuid.uuid4())
self.ssh_with_password(connection)
self.emit('room', {'room': connection, 'secret': message['secret']})
self.ssh_with_password(connection)
def on_resize(self, message):
self.clients[request.sid]["cols"] = message.get('cols', 80)
......@@ -84,11 +86,19 @@ class SSHws(Namespace):
def on_disconnect(self):
print("disconnect")
for connection in self.clients[request.sid]["chan"]:
self.on_logout(connection)
pass
def on_leave(self):
leave_room(self.room)
def on_logout(self, connection):
print("logout", connection)
if connection:
self.clients[request.sid]["chan"][connection].close()
del self.clients[request.sid]["chan"][connection]
@app.route('/luna/<path:path>')
def send_js(path):
......
......@@ -8,6 +8,7 @@
*/
import {Component, OnInit} from '@angular/core';
import {TermWS} from '../../globals';
// export class Term {
// machine: string;
......@@ -30,6 +31,7 @@ export class View {
closed: boolean;
host: any;
user: any;
room: string;
Rdp: Rdp;
Term: any;
}
......@@ -63,8 +65,12 @@ export class ControlComponent implements OnInit {
}
static TerminalDisconnect(id) {
NavList.List[id].connected = false;
NavList.List[id].Term.write('\r\n\x1b[31mBye Bye!\x1b[m\r\n');
console.log(id);
if (NavList.List[id].connected) {
NavList.List[id].connected = false;
NavList.List[id].Term.write('\r\n\x1b[31mBye Bye!\x1b[m\r\n');
TermWS.emit('logout', NavList.List[id].room);
}
}
static RdpDisconnect(id) {
......
......@@ -15,7 +15,7 @@ export class ElementTermComponent implements OnInit, AfterViewInit {
@Input() host: any;
@Input() userid: any;
@Input() index: number;
@Input() room: string;
// @Input() room: string;
@ViewChild('term') el: ElementRef;
secret: string;
term: any;
......@@ -31,6 +31,7 @@ export class ElementTermComponent implements OnInit, AfterViewInit {
useStyle: true,
screenKeys: true,
});
// NavList.List[this.index].room = this.room;
}
ngAfterViewInit() {
......@@ -74,11 +75,11 @@ export class ElementTermComponent implements OnInit, AfterViewInit {
TermWS.emit('host', {'uuid': this.host.id, 'userid': this.userid, 'secret': this.secret});
this.term.on('data', function (data) {
TermWS.emit('data', {'data': data, 'room': that.room});
TermWS.emit('data', {'data': data, 'room': NavList.List[that.index].room});
});
TermWS.on('data', function (data) {
if (data['room'] === that.room) {
if (data['room'] === NavList.List[that.index].room) {
that.term.write(data['data']);
}
});
......@@ -88,7 +89,7 @@ export class ElementTermComponent implements OnInit, AfterViewInit {
});
TermWS.on('room', function (data) {
if (data['secret'] === that.secret) {
that.room = data['room'];
NavList.List[that.index].room = data['room'];
}
});
}
......@@ -97,5 +98,6 @@ export class ElementTermComponent implements OnInit, AfterViewInit {
TerminalDisconnect() {
NavList.List[this.index].connected = false;
this.term.write('\r\n\x1b[31mBye Bye!\x1b[m\r\n');
TermWS.emit('logout', NavList.List[this.index].room);
}
}
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