Skip to content

Commit

Permalink
working on rawsocket support in apprunner
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Oberstein committed Jul 16, 2016
1 parent 931c8b8 commit d06a4fc
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 12 deletions.
3 changes: 0 additions & 3 deletions autobahn/rawsocket/__init__.py
Expand Up @@ -23,6 +23,3 @@
# THE SOFTWARE.
#
###############################################################################


from __future__ import absolute_import
3 changes: 0 additions & 3 deletions autobahn/rawsocket/util.py
Expand Up @@ -129,6 +129,3 @@ def parse_url(url):
raise Exception("invalid port {}".format(port))

return parsed.scheme == "rss", parsed.hostname, port


print create_url('crossbar.io', 9000, True)
21 changes: 16 additions & 5 deletions autobahn/twisted/wamp.py
Expand Up @@ -34,8 +34,10 @@

from autobahn.wamp import protocol
from autobahn.wamp.types import ComponentConfig
from autobahn.websocket.util import parse_url
from autobahn.websocket.util import parse_url as parse_ws_url
from autobahn.rawsocket.util import parse_url as parse_rs_url
from autobahn.twisted.websocket import WampWebSocketClientFactory
from autobahn.twisted.rawsocket import WampRawSocketClientFactory

# new API
# from autobahn.twisted.connection import Connection
Expand Down Expand Up @@ -160,8 +162,6 @@ def run(self, make, start_reactor=True, auto_reconnect=False):
txaio.config.loop = reactor
txaio.start_logging(level='info')

isSecure, host, port, resource, path, params = parse_url(self.url)

if callable(make):
# factory for use ApplicationSession
def create():
Expand All @@ -182,8 +182,19 @@ def create():
else:
create = make

# create a WAMP-over-WebSocket transport client factory
transport_factory = WampWebSocketClientFactory(create, url=self.url, serializers=self.serializers, proxy=self.proxy, headers=self.headers)
if self.url.startswith(u'rs'):
# try to parse RawSocket URL ..
isSecure, host, port = parse_rs_url(self.url)

# create a WAMP-over-RawSocket transport client factory
transport_factory = WampRawSocketClientFactory(create)

else:
# try to parse WebSocket URL ..
isSecure, host, port, resource, path, params = parse_ws_url(self.url)

# create a WAMP-over-WebSocket transport client factory
transport_factory = WampWebSocketClientFactory(create, url=self.url, serializers=self.serializers, proxy=self.proxy, headers=self.headers)

# supress pointless log noise like
# "Starting factory <autobahn.twisted.websocket.WampWebSocketClientFactory object at 0x2b737b480e10>""
Expand Down
6 changes: 5 additions & 1 deletion examples/twisted/wamp/client_using_apprunner.py
Expand Up @@ -65,5 +65,9 @@ def onDisconnect(self):
# reconnects (if automatically reconnected)
session = MyAppSession(ComponentConfig(u'realm1', {}))

runner = ApplicationRunner(u'ws://localhost:8080/ws', u'realm1')
if False:
runner = ApplicationRunner(u'ws://localhost:8080/ws', u'realm1')
else:
runner = ApplicationRunner(u'rs://localhost:8080', u'realm1')

runner.run(session, auto_reconnect=True)
2 changes: 2 additions & 0 deletions setup.py
Expand Up @@ -195,6 +195,8 @@ def run_tests(self):
'autobahn.wamp.test',
'autobahn.websocket',
'autobahn.websocket.test',
'autobahn.rawsocket',
'autobahn.rawsocket.test',
'autobahn.asyncio',
'autobahn.twisted',
'twisted.plugins'
Expand Down

0 comments on commit d06a4fc

Please sign in to comment.