Session based IDE integration with PIO Home

This commit is contained in:
Ivan Kravets
2019-07-19 12:59:50 +03:00
parent aebe891895
commit 6d7854d113
2 changed files with 13 additions and 11 deletions

2
docs

Submodule docs updated: 8bf85043ee...39d34be360

View File

@ -21,22 +21,24 @@ from twisted.internet import defer # pylint: disable=import-error
class IDERPC(object): class IDERPC(object):
def __init__(self): def __init__(self):
self._queue = [] self._queue = {}
def send_command(self, command, params): def send_command(self, command, params, sid=0):
if not self._queue: if not self._queue.get(sid):
raise jsonrpc.exceptions.JSONRPCDispatchException( raise jsonrpc.exceptions.JSONRPCDispatchException(
code=4005, message="PIO Home IDE agent is not started") code=4005, message="PIO Home IDE agent is not started")
while self._queue: while self._queue[sid]:
self._queue.pop().callback({ self._queue[sid].pop().callback({
"id": time.time(), "id": time.time(),
"method": command, "method": command,
"params": params "params": params
}) })
def listen_commands(self): def listen_commands(self, sid=0):
self._queue.append(defer.Deferred()) if sid not in self._queue:
return self._queue[-1] self._queue[sid] = []
self._queue[sid].append(defer.Deferred())
return self._queue[sid][-1]
def open_project(self, project_dir): def open_project(self, project_dir, sid=0):
return self.send_command("open_project", project_dir) return self.send_command("open_project", project_dir, sid)