MrJoes/tornadio2 — Issue #17: @event decorator limitation?
Author: greg-hellings
Created: 2012-01-09 22:04:33+00:00
State: open

I have a set of classes like this:

class DistributeHandler(SocketConnection):
@event
def join(self, *args, **kargs):
# Join a channel based on kargs
print "Joining %s" % (kargs['group'], )

on_message(self, msg):
pass

class MainRouter(SocketConnection):
__endpoints__ : { '/realtime': DistributeHandler, '/other': OtherHandler}
on_open(self, *args):
print "Connected"

On the client side, I have this:
var socket = io.connect("ws://mysite.com/realtime");
socket.emit('join', {group: 5}, function() { console.log('joined'); });

However, the server informs me that 'join' is an invalid event. Is this because the @event decorator is on the endpoint SocketConnection class and not on the MainRouter object? Is @event supposed to be that limited or this a bug? I'd love to be able to put the @event decorator on the endpoint classes, as that would make my system far more flexible. I just wanted to make sure I understood what is going on.