updates to allow new gui to recreate session to continue where it left off

This commit is contained in:
Blake Harnden 2020-03-04 20:09:56 -08:00
parent f2da8dc2c9
commit c4234d33f0
4 changed files with 60 additions and 9 deletions

View file

@ -262,6 +262,16 @@ class CoreGrpcClient:
"""
return self.stub.GetSessions(core_pb2.GetSessionsRequest())
def check_session(self, session_id: int) -> core_pb2.CheckSessionResponse:
"""
Check if a session exists.
:param session_id: id of session to check for
:return: response with result if session was found
"""
request = core_pb2.CheckSessionRequest(session_id=session_id)
return self.stub.CheckSession(request)
def get_session(self, session_id: int) -> core_pb2.GetSessionResponse:
"""
Retrieve a session.

View file

@ -453,6 +453,19 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
session.metadata = dict(request.config)
return core_pb2.SetSessionMetadataResponse(result=True)
def CheckSession(
self, request: core_pb2.GetSessionRequest, context: ServicerContext
) -> core_pb2.CheckSessionResponse:
"""
Checks if a session exists.
:param request: check session request
:param context: context object
:return: check session response
"""
result = request.session_id in self.coreemu.sessions
return core_pb2.CheckSessionResponse(result=result)
def GetSession(
self, request: core_pb2.GetSessionRequest, context: ServicerContext
) -> core_pb2.GetSessionResponse: