2016-06-04 06:07:50 +00:00
|
|
|
from __future__ import print_function, absolute_import, unicode_literals
|
2017-02-23 01:02:01 +00:00
|
|
|
import sys
|
|
|
|
from .timing import DebugTiming
|
2017-02-22 20:51:53 +00:00
|
|
|
from .journal import ImmediateJournal
|
2016-05-21 01:49:20 +00:00
|
|
|
|
2017-01-06 16:25:32 +00:00
|
|
|
def wormhole(appid, relay_url, reactor, tor_manager=None, timing=None,
|
|
|
|
stderr=sys.stderr):
|
2016-05-23 01:40:44 +00:00
|
|
|
timing = timing or DebugTiming()
|
2017-01-06 16:25:32 +00:00
|
|
|
w = _Wormhole(appid, relay_url, reactor, tor_manager, timing, stderr)
|
2016-05-21 01:49:20 +00:00
|
|
|
w._start()
|
|
|
|
return w
|
|
|
|
|
2016-05-28 01:47:14 +00:00
|
|
|
#def wormhole_from_serialized(data, reactor, timing=None):
|
|
|
|
# timing = timing or DebugTiming()
|
|
|
|
# w = _Wormhole.from_serialized(data, reactor, timing)
|
|
|
|
# return w
|
2017-02-14 07:12:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
# considerations for activity management:
|
|
|
|
# * websocket to server wants to be a t.a.i.ClientService
|
|
|
|
# * if Wormhole is a MultiService:
|
|
|
|
# * makes it easier to chain the ClientService to it
|
|
|
|
# * implies that nothing will happen before w.startService()
|
|
|
|
# * implies everything stops upon d=w.stopService()
|
|
|
|
# * if not:
|
|
|
|
# *
|
|
|
|
|
2017-02-23 00:56:39 +00:00
|
|
|
class _JournaledWormhole(object):
|
2017-02-14 07:12:57 +00:00
|
|
|
def __init__(self, reactor, journal_manager, event_dispatcher,
|
|
|
|
event_dispatcher_args=()):
|
|
|
|
pass
|
|
|
|
|
|
|
|
class _Wormhole(_JournaledWormhole):
|
|
|
|
# send events to self, deliver them via Deferreds
|
|
|
|
def __init__(self, reactor):
|
2017-02-22 20:51:53 +00:00
|
|
|
_JournaledWormhole.__init__(self, reactor, ImmediateJournal(), self)
|
2017-02-14 07:12:57 +00:00
|
|
|
|
2017-02-23 01:02:01 +00:00
|
|
|
def wormhole2(reactor):
|
2017-02-14 07:12:57 +00:00
|
|
|
w = _Wormhole(reactor)
|
|
|
|
w.startService()
|
|
|
|
return w
|
|
|
|
|
|
|
|
def journaled_from_data(state, reactor, journal,
|
|
|
|
event_handler, event_handler_args=()):
|
|
|
|
pass
|
|
|
|
|
2017-02-22 20:51:53 +00:00
|
|
|
def journaled(reactor, journal, event_handler, event_handler_args=()):
|
2017-02-14 07:12:57 +00:00
|
|
|
pass
|