]> jfr.im git - irc/quakenet/qwebirc.git/commitdiff
fixup autobahn compatibility with use 0.8.14
authorChris Porter <redacted>
Mon, 18 Aug 2014 16:54:30 +0000 (17:54 +0100)
committerChris Porter <redacted>
Mon, 18 Aug 2014 16:54:30 +0000 (17:54 +0100)
bin/dependencies_b.py
qwebirc/engines/ajaxengine.py

index 4a3ab007dd4641300f69a632545d5425966aa062..b3b82b0b11b8521f884b8497837089614f3ccaaa 100644 (file)
@@ -126,10 +126,15 @@ def check_json():
 \r
 def check_autobahn():\r
   try:\r
-    import autobahn.websocket\r
+    import autobahn, autobahn.websocket\r
+    x = autobahn.version.split(".")\r
+    if len(x) != 3:\r
+      raise ImportError("Unknown version: %s", autobahn.vesrion)\r
+    if (int(x[1]) < 8) or (int(x[1]) == 8 and int(x[2]) < 14):\r
+      raise ImportError()\r
     return 0\r
   except ImportError:\r
-    warn("autobahn not installed; websocket support will be disabled.",\r
+    warn("autobahn 0.8.14 (minimum) not installed; websocket support will be disabled.",\r
          "consider installing autobahn from:",\r
          "http://autobahn.ws/python/getstarted/")\r
     return 1\r
index 26aa7ad5b0d535985d42919932638c9350d998c1..2d3769e3dbdd6ccd80400084c72cdaccf17903f9 100644 (file)
@@ -13,8 +13,15 @@ import urlparse
 TRANSPORTS = ["longpoll"]
 
 try:
-  import autobahn.websocket
-  import autobahn.resource
+  import autobahn
+  x = autobahn.version.split(".")
+  if len(x) != 3:
+    raise ImportError("Unknown version: %s", autobahn.vesrion)
+  if (int(x[1]) < 8) or (int(x[1]) == 8 and int(x[2]) < 14):
+    raise ImportError()
+
+  import autobahn.twisted.websocket
+  import autobahn.twisted.resource
   has_websocket = True
   TRANSPORTS.append("websocket")
 except ImportError:
@@ -355,7 +362,7 @@ if has_websocket:
     def close(self):
       self.channel.close()
 
-  class WebSocketEngineProtocol(autobahn.websocket.WebSocketServerProtocol):
+  class WebSocketEngineProtocol(autobahn.twisted.websocket.WebSocketServerProtocol):
     AWAITING_AUTH, AUTHED = 0, 1
 
     def __init__(self, *args, **kwargs):
@@ -446,23 +453,14 @@ if has_websocket:
     def send(self, message_type, message):
       self.sendMessage(message_type + message)
 
-  class WebSocketResource(autobahn.resource.WebSocketResource):
+  class WebSocketResource(autobahn.twisted.resource.WebSocketResource):
     def render(self, request):
       request.channel.setTimeout(None)
-      return autobahn.resource.WebSocketResource.render(self, request)
+      return autobahn.twisted.resource.WebSocketResource.render(self, request)
 
   def WebSocketEngine(path=None):
-    parsed = urlparse.urlparse(config.BASE_URL)
-    port = parsed.port
-    if port is None:
-      if parsed.scheme == "http":
-        port = 80
-      elif parsed.scheme == "https":
-        port = 443
-      else:
-        raise Exception("Unable to determine port from BASE_URL: " + config.BASE_URL)
-
-    factory = autobahn.websocket.WebSocketServerFactory("ws://localhost:%d" % port)
+    factory = autobahn.twisted.websocket.WebSocketServerFactory("ws://localhost")
+    factory.externalPort = None
     factory.protocol = WebSocketEngineProtocol
     factory.setProtocolOptions(maxMessagePayloadSize=512, maxFramePayloadSize=512, tcpNoDelay=False)
     resource = WebSocketResource(factory)