might work

This commit is contained in:
Bruno Rybársky 2022-06-12 13:47:29 +02:00
parent de87a14813
commit 291cc2d12e
2 changed files with 14 additions and 2 deletions

@ -99,7 +99,7 @@ function resolveCommand(commandname:string, socket:Socket, args:string[], buffer
bufko += savesess(args, sessions, filesystem, curdir, buffer, socket); bufko += savesess(args, sessions, filesystem, curdir, buffer, socket);
break; break;
case "loadsess": case "loadsess":
bufko += loadsess(args, sessions, filesystem[socket.id], curdir[socket.id], buffer[socket.id]); bufko += loadsess(args, sessions, filesystem[socket.id], curdir[socket.id], buffer[socket.id], socket);
break; break;
case "wee": case "wee":
bufko += wee(); bufko += wee();

@ -1,7 +1,18 @@
var fs = require('fs'); var fs = require('fs');
const SerAny = require('serialize-anything'); const SerAny = require('serialize-anything');
import { Socket } from 'socket.io'; import { Socket } from 'socket.io';
function loadsess(args:Array<string>, sessions:any, filesystem:any, curdir:any, buffer:string ):string { function sendbuffer(socket:Socket, bufferx: string, forcefulload:boolean) {
var bufx = bufferx[socket.id];
//add placeholder character(reserved unicode) for blinking cursor in client;
bufx += "\u2588";
if(forcefulload) {
socket.emit('buffer', bufx);
}
else {
socket.emit('bufferx', bufx);
}
}
function loadsess(args:Array<string>, sessions:any, filesystem:any, curdir:any, buffer:string, socket:Socket ):string {
var buf = ""; var buf = "";
if (args.length == 1) { if (args.length == 1) {
sessions = SerAny.deserialize(fs.readFileSync("./sessions.json")); sessions = SerAny.deserialize(fs.readFileSync("./sessions.json"));
@ -10,6 +21,7 @@ function loadsess(args:Array<string>, sessions:any, filesystem:any, curdir:any,
curdir = sessions[args[0]]["curdir"]; curdir = sessions[args[0]]["curdir"];
buffer = sessions[args[0]]["buffer"]; buffer = sessions[args[0]]["buffer"];
buf += "Session loaded.\n"; buf += "Session loaded.\n";
sendbuffer(socket, buffer, true);
} }
} }
else { else {