working on rawsocket support in apprunner

This commit is contained in:
Tobias Oberstein 2016-07-16 18:33:57 +02:00
parent 931c8b8530
commit d06a4fcfbf
5 changed files with 23 additions and 12 deletions

View File

@ -23,6 +23,3 @@
# THE SOFTWARE.
#
###############################################################################
from __future__ import absolute_import

View File

@ -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)

View File

@ -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 <autobahn.twisted.websocket.WampWebSocketClientFactory object at 0x2b737b480e10>""

View File

@ -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)

View File

@ -195,6 +195,8 @@ setup(
'autobahn.wamp.test',
'autobahn.websocket',
'autobahn.websocket.test',
'autobahn.rawsocket',
'autobahn.rawsocket.test',
'autobahn.asyncio',
'autobahn.twisted',
'twisted.plugins'