diff --git a/autobahn/rawsocket/__init__.py b/autobahn/rawsocket/__init__.py index cf524813..8a4c67bf 100644 --- a/autobahn/rawsocket/__init__.py +++ b/autobahn/rawsocket/__init__.py @@ -23,6 +23,3 @@ # THE SOFTWARE. # ############################################################################### - - -from __future__ import absolute_import diff --git a/autobahn/rawsocket/util.py b/autobahn/rawsocket/util.py index 0c098f88..66ecf8bd 100644 --- a/autobahn/rawsocket/util.py +++ b/autobahn/rawsocket/util.py @@ -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) diff --git a/autobahn/twisted/wamp.py b/autobahn/twisted/wamp.py index 08a3650f..7d7d74c3 100644 --- a/autobahn/twisted/wamp.py +++ b/autobahn/twisted/wamp.py @@ -34,8 +34,10 @@ from twisted.internet.defer import inlineCallbacks 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 @@ -160,8 +162,6 @@ class ApplicationRunner(object): 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(): @@ -182,8 +182,19 @@ class ApplicationRunner(object): 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 "" diff --git a/examples/twisted/wamp/client_using_apprunner.py b/examples/twisted/wamp/client_using_apprunner.py index 1acc658b..0ef62ba9 100644 --- a/examples/twisted/wamp/client_using_apprunner.py +++ b/examples/twisted/wamp/client_using_apprunner.py @@ -65,5 +65,9 @@ if __name__ == '__main__': # 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) diff --git a/setup.py b/setup.py index e6e8bb81..715089cb 100644 --- a/setup.py +++ b/setup.py @@ -195,6 +195,8 @@ setup( 'autobahn.wamp.test', 'autobahn.websocket', 'autobahn.websocket.test', + 'autobahn.rawsocket', + 'autobahn.rawsocket.test', 'autobahn.asyncio', 'autobahn.twisted', 'twisted.plugins'