aboutsummaryrefslogtreecommitdiff
path: root/session.py
diff options
context:
space:
mode:
Diffstat (limited to 'session.py')
-rw-r--r--session.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/session.py b/session.py
index f1824d7..a2880c7 100644
--- a/session.py
+++ b/session.py
@@ -18,6 +18,7 @@ API_SERVER = "http://127.0.0.1:8000"
BASE_URL = API_SERVER + "/app/rwa/api/"
REGISTER_URL = BASE_URL + "register/"
STOP_URL = BASE_URL + "stop/"
+STATUS_URL = BASE_URL + "status/"
def random_digits(length: int):
@@ -43,7 +44,7 @@ class Session:
STATUS_RUNNING = "running"
#: Remote has joined the session
- STATUS_JOINED = "joined"
+ STATUS_JOINED = "active"
def __init__(self, mockup_session: bool):
self.mockup_session = mockup_session
@@ -51,6 +52,7 @@ class Session:
self._start_vnc()
self._start_trigger_service()
self._register_session()
+ self.status_text = self.STATUS_RUNNING
@property
def pid(self) -> int:
@@ -147,7 +149,9 @@ class Session:
def pull(self):
"""Update status: Get status from Django."""
- pass
+ if not self.mockup_session:
+ r = requests.get(STATUS_URL, params={"id": self.session_id}, headers=self._api_headers)
+ self.status_text = r.json()["status"]
def push(self):
"""Update status: Push status to Django."""
@@ -187,7 +191,7 @@ class Session:
if not triggered:
requests.post(
- STOP_URL, json={"id": self.session_id}, headers=self._api_headers
+ STOP_URL, params={"id": self.session_id}, headers=self._api_headers
)
# Delete self
@@ -213,4 +217,4 @@ class Session:
@property
def status(self):
- return {"id": self.pid, "status": self.STATUS_RUNNING}
+ return {"id": self.pid, "status": self.status_text}