このチュートリアルに従ってコンシューマを作成しようとしています
class MyConsumer(WebsocketConsumer):
def __init__(self,path):
WebsocketConsumer.__init__(self,path)
self.client_id_seed = 0
self.clients_connected = 0
# The following are passed on to RosbridgeProtocol
self.fragment_timeout = 600 # seconds
self.delay_between_messages = 0 # seconds
self.max_message_size = None
self.protocol = None
def connection_groups(self):
"""
Called to return the list of groups to automatically add/remove
this connection to/from.
"""
return ["test"]
# Connected to websocket.connect
def connect(self,message):
parameters = {
"fragment_timeout": self.fragment_timeout,
"delay_between_messages": self.delay_between_messages,
"max_message_size": self.max_message_size
}
try:
self.protocol.outgoing = self.receive
self.client_id_seed += 1
self.clients_connected += 1
except Exception as exc:
print ("Unable to accept incoming connection. Reason: %s" % str(exc))
print "Client connected. %d clients total." % self.clients_connected
self.message.reply_channel.send({"accept": True})
# Connected to websocket.receive
def receive(self,text=None, bytes=None):
# binary = type(message)==bson.BSON
self.send(text=text, bytes=bytes)
# Connected to websocket.disconnect
def disconnect(self,message):
self.clients_connected -= 1
タイトルにエラーが表示されますが、コンストラクターで明確に定義しました。エラーはdisconnect
メソッドから呼び出されます