diff --git a/core/client.js b/core/client.js index 8fb32a01..a97fbd5d 100644 --- a/core/client.js +++ b/core/client.js @@ -1,7 +1,6 @@ "use strict"; var gSocket; -var gSessionId; var gCredentials; var gErrorCount = 0; var gCommandHistory = []; @@ -111,7 +110,6 @@ function receive(data) { if (line && line.action == "ping") { gSocket.send(JSON.stringify({action: "pong"})); } else if (line && line.action == "session") { - gSessionId = line.sessionId; gCredentials = line.credentials; updateLogin(); } else if (line && line[0] && line[0].action == "ready") { diff --git a/core/core.js b/core/core.js index 7942538b..1b8ad032 100644 --- a/core/core.js +++ b/core/core.js @@ -9,6 +9,7 @@ var network = require("network"); var gProcessIndex = 0; var gProcesses = {}; +var gSessionIndex = 0; var gGlobalSettings = { index: "/~cory/index", @@ -35,11 +36,7 @@ function getCookies(headers) { } function makeSessionId() { - var id = ""; - for (var i = 0; i < 64; i++) { - id += (Math.floor(Math.random() * 16)).toString(16); - } - return id; + return (gSessionIndex++).toString(); } function printError(out, error) { diff --git a/core/terminal.js b/core/terminal.js index 3b6dcc82..547db2ec 100644 --- a/core/terminal.js +++ b/core/terminal.js @@ -160,10 +160,10 @@ function socket(request, response, client) { packageOwner = match[1]; packageName = match[2]; } - var sessionId = makeSessionId(); - response.send(JSON.stringify({lines: [{action: "session", sessionId: sessionId, credentials: credentials}]}), 0x1); + response.send(JSON.stringify({lines: [{action: "session", credentials: credentials}]}), 0x1); options.terminalApi = message.terminalApi || []; + var sessionId = makeSessionId(); process = await getSessionProcess(packageOwner, packageName, sessionId, options); process.terminal.readOutput(function(message) { response.send(JSON.stringify(message), 0x1);