Merge pull request #628 from larsx2/master

Replaced deprecated HttpException for types.ConnectionDeny on onConnect (code examples)
This commit is contained in:
Tobias Oberstein 2016-04-09 13:55:32 +02:00
commit c86fe266bf
1 changed files with 5 additions and 6 deletions

View File

@ -24,18 +24,15 @@
#
###############################################################################
import sys
import txaio
from twisted.internet import reactor
from twisted.python import log
from twisted.web.server import Site
from twisted.web.static import File
from autobahn.twisted.websocket import WebSocketServerFactory, \
WebSocketServerProtocol, \
listenWS
from autobahn.websocket.http import HttpException
from autobahn.websocket.types import ConnectionDeny
class BaseService:
@ -46,6 +43,7 @@ class BaseService:
def __init__(self, proto):
self.proto = proto
self.is_closed = False
def onOpen(self):
pass
@ -90,6 +88,7 @@ class ServiceServerProtocol(WebSocketServerProtocol):
def __init__(self):
self.service = None
self.is_closed = txaio.create_future()
def onConnect(self, request):
# request has all the information from the initial
@ -115,7 +114,7 @@ class ServiceServerProtocol(WebSocketServerProtocol):
else:
err = "No service under %s" % request.path
print(err)
raise HttpException(404, err)
raise ConnectionDeny(404, unicode(err))
def onOpen(self):
if self.service: