def push(self, id):
        "Sends a message to the specified connection (id)"
        conn = session['connections'].get(id, None)
        if conn:
            msgs = simplejson.loads(request.body)
            for msg in msgs:
                try:
                    cmd = msg.pop(0).upper()
                    assert ' ' not in cmd, "Bad message"
                    if cmd in ('USER', ):
                        sufix = " :"+msg.pop()
                    else:
                        sufix = ''
                    assert not [i for i in msg if ' ' in i], "Bad message"

                    print 'PUSH:', (cmd, msg, sufix)

                    if msg:
                        payload = "%s %s%s\r\n" % (cmd, ' '.join(msg), sufix)
                    else:
                        payload = "%s%s\r\n" % (cmd, sufix)
                    yield request.environ['cogen.call'](conn.sock.sendall)(
                            payload.encode('utf-8'))
                    if isinstance(request.environ['cogen.wsgi'].result, Exception):
                        yield simplejson.dumps(('', 'ERROR', str(e)))
                    else:
                        yield simplejson.dumps(('', 'PUSH_OK', ''))
                except Exception, e:
                    yield simplejson.dumps(('', 'ERROR', str(e)))
        else:
            yield simplejson.dumps(('', 'ERROR', 'Invalid connection id.'))