Main View

This is the main view module which manages main tornado connections. This module provides request handlers for managing simple HTTP requests as well as Websocket requests.

Although the websocket requests are actually sockJs requests which follows the sockjs protcol, thus it provide interface to sockjs connection handlers behind the scene.


class mosquittoChat.apps.main.views.IndexHandler(application, request, **kwargs)

This handler is a basic regular HTTP handler to serve the chatroom page.


This method is called when a client does a simple GET request, all other HTTP requests like POST, PUT, DELETE, etc are ignored.

Returns:Returns the rendered main requested page, in this case its the chat page, index.html
__module__ = 'mosquittoChat.apps.main.views'


class mosquittoChat.apps.main.views.ChatWebsocketHandler(session)

Websocket Handler implementing the sockjs Connection Class which will handle the websocket/sockjs connections.


This method is called when a websocket/sockjs connection is opened for the first time.

  • self – The object
  • info – The information

It returns the websocket object


This method is called when a message is received via the websocket/sockjs connection created initially.

  • self – The object
  • message (json string) – The message received via the connection.

This method is called when a websocket/sockjs connection is closed.

Parameters:self – The object
Returns:Doesn’t return anything, except a confirmation of closed connection back to web app.
__module__ = 'mosquittoChat.apps.main.views'