Example #1
0
def on_chat_saved(sender, instance, **kw):
    """Broad cast this event to all channel listeners"""
    if kw.get('created'):
        from comet.api import broadcast_message
        from omchat.api import ChatRc, dump_rc
        broadcast_message('omchat', {
            'action': 'chat-created',
            'data': dump_rc(ChatRc, instance)
        })
Example #2
0
def index(request):
    # prepare for channel id
    cid = create_channel('omchat')

    # prepare for list of chats
    chat_list = Chat.objects.order_by('-pub_time')[:20]

    return render_to_response('omchat/index.html', {
            'cid': cid,
            'init_data': dump_rc(ChatRc, chat_list),
            'closure_compiled': True,
            'user_ip': request.META['REMOTE_ADDR']
        }, context_instance=RequestContext(request)
    )