# Path: sockjs/cyclone/proto.py
# CONNECT = 'o'
# DISCONNECT = 'c'
# MESSAGE = 'm'
# HEARTBEAT = 'h'
# def disconnect(code, reason):
# 
# Path: sockjs/cyclone/transports/streamingbase.py
# class StreamingTransportBase(pollingbase.PollingTransportBase):
#     def initialize(self, server):
#     def should_finish(self, data_len):
#     def session_closed(self):


from cyclone.web import asynchronous
from sockjs.cyclone import proto
from sockjs.cyclone.transports import streamingbase
        self.handle_session_cookie()
        self.disable_cache()
        self.set_header('Content-Type', 'text/html; charset=UTF-8')

        # Grab callback parameter
        callback = self.get_argument('c', None)
        if not callback:
            self.write('"callback" parameter required')
            self.set_status(500)
            self.finish()
            return

        self.write(HTMLFILE_HEAD % callback)
        self.flush()

        # Now try to attach to session
        if not self._attach_session(session_id):
            self.finish()
            return

        # Flush any pending messages
        if self.session:
            self.session.flush()

    def connectionLost(self, reason):
        self.session.delayed_close()
        self._detach()

    def send_pack(self, message):
        # TODO: Just do escaping

# Path: sockjs/cyclone/proto.py
# CONNECT = 'o'
# DISCONNECT = 'c'
# MESSAGE = 'm'
# HEARTBEAT = 'h'
# def disconnect(code, reason):
# 
# Path: sockjs/cyclone/transports/streamingbase.py
# class StreamingTransportBase(pollingbase.PollingTransportBase):
#     def initialize(self, server):
#     def should_finish(self, data_len):
#     def session_closed(self):


# Path: sockjs/cyclone/transports/htmlfile.py
from cyclone.web import asynchronous
from sockjs.cyclone import proto
from sockjs.cyclone.transports import streamingbase

        self.handle_session_cookie()
        self.disable_cache()
        self.set_header('Content-Type', 'text/html; charset=UTF-8')

        # Grab callback parameter
        callback = self.get_argument('c', None)
        if not callback:
            self.write('"callback" parameter required')
            self.set_status(500)
            self.finish()
            return

        self.write(HTMLFILE_HEAD % callback)
        self.flush()

        # Now try to attach to session
        if not self._attach_session(session_id):
            self.finish()
            return

        # Flush any pending messages
        if self.session:
            self.session.flush()

    def connectionLost(self, reason):
        self.session.delayed_close()
        self._detach()

    def send_pack(self, message):
        # TODO: Just do escaping

        msg = '<script>\np(%s);\n</script>\r\n' % proto.json_encode(message)