Commit f20f84b6 authored by i317280's avatar i317280

fix: record the replay log

parent 8a8c81b6
......@@ -120,7 +120,7 @@ class SSHws(Namespace, BaseWebSocketHandler):
def on_leave(self, room):
if self.rooms[room]["admin"] == request.sid:
self.emit("data", "\nAdmin leave", room=room)
self.rooms.remove(room)
del self.rooms[room]
leave_room(room=room)
def on_disconnect(self):
......
......@@ -98,7 +98,7 @@ class ServerReplayRecorder(ReplayRecorder):
:return:
"""
# Todo: <liuzheng712@gmail.com>
self.file.write(data)
self.file.write(str(data))
def session_start(self, session_id):
self.file = open(os.path.join(
......
......@@ -8,19 +8,17 @@ import datetime
import selectors
import time
BUF_SIZE = 1024
logger = logging.getLogger(__file__)
class Session:
def __init__(self, client, server, command_recorder=None, replay_recorder=None):
self.id = str(uuid.uuid4())
self.client = client # Master of the session, it's a client sock
self.server = server # Server channel
self._watchers = [] # Only watch session
self._sharers = [] # Join to the session, read and write
self._sharers = [] # Join to the session, read and write
self.replaying = True
self.date_created = datetime.datetime.now()
self.date_finished = None
......@@ -123,6 +121,7 @@ class Session:
events = self.sel.select()
for sock in [key.fileobj for key, _ in events]:
data = sock.recv(BUF_SIZE)
self.put_replay(data)
if sock == self.server:
if len(data) == 0:
msg = "Server close the connection"
......@@ -184,8 +183,3 @@ class Session:
def __del__(self):
logger.info("Session {} object has been GC")
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