Skip to content

Commit

Permalink
Merge pull request #12 from HengiFettlich/master
Browse files Browse the repository at this point in the history
Game time updates, move imports, launch games in new thread
  • Loading branch information
LeonardFiedrowicz authored Dec 11, 2019
2 parents 47e64ee + 73a1e05 commit 1dbcd42
Show file tree
Hide file tree
Showing 2 changed files with 141 additions and 106 deletions.
7 changes: 5 additions & 2 deletions galaxy/api/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from galaxy.api.types import Achievement, Authentication, FriendInfo, Game, GameTime, LocalGame, NextStep
from galaxy.task_manager import TaskManager


class JSONEncoder(json.JSONEncoder):
def default(self, o): # pylint: disable=method-hidden
if dataclasses.is_dataclass(o):
Expand All @@ -33,6 +34,7 @@ def __init__(self, platform, version, reader, writer, handshake_token):
logging.info("Creating plugin for platform %s, version %s", platform.value, version)
self._platform = platform
self._version = version
self.TICK_TIME = 1

self._features: Set[Feature] = set()
self._active = True
Expand Down Expand Up @@ -169,6 +171,7 @@ def _register_notification(self, name, handler, internal=False, immediate=False,
def _wrap_external_method(self, handler, name: str):
async def wrapper(*args, **kwargs):
return await self._external_task_manager.create_task(handler(*args, **kwargs), name, False)

return wrapper

async def run(self):
Expand Down Expand Up @@ -202,7 +205,7 @@ async def _pass_control(self):
self.tick()
except Exception:
logging.exception("Unexpected exception raised in plugin tick")
await asyncio.sleep(1)
await asyncio.sleep(self.TICK_TIME)

async def _shutdown(self):
logging.info("Shutting down")
Expand Down Expand Up @@ -487,7 +490,7 @@ async def authenticate(self, stored_credentials=None):
raise NotImplementedError()

async def pass_login_credentials(self, step: str, credentials: Dict[str, str], cookies: List[Dict[str, str]]) \
-> Union[NextStep, Authentication]:
-> Union[NextStep, Authentication]:
"""This method is called if we return galaxy.api.types.NextStep from authenticate or from pass_login_credentials.
This method's parameters provide the data extracted from the web page navigation that previous NextStep finished on.
This method should either return galaxy.api.types.Authentication if the authentication is finished
Expand Down
Loading

0 comments on commit 1dbcd42

Please sign in to comment.