# Path: sockjs/cyclone/transports/base.py
# class BaseTransportMixin(object):
# class MultiplexTransport(BaseTransportMixin):
#     def get_conn_info(self):
#     def session_closed(self):
#     def __init__(self, conn_info):
#     def get_conn_info(self):
# 
# Path: sockjs/cyclone/session.py
# class MultiplexChannelSession(BaseSession):
#     def __init__(self, conn, server, base, name):
#         super(MultiplexChannelSession, self).__init__(conn, server)
# 
#         self.base = base
#         self.name = name
# 
#     def send_message(self, msg, stats=True):
#         if not self.base.is_closed:
#             msg = 'msg,%s,%s' % (self.name, msg)
#             self.base.session.send_message(msg, stats)
# 
#     def messageReceived(self, msg):
#         self.conn.messageReceived(msg)
# 
#     def close(self, code=3000, message='Go away!'):
#         self.base.sendMessage('uns,%s' % self.name)
#         self._close(code, message)
# 
#     # Non-API version of the close, without sending the close message
#     def _close(self, code=3000, message='Go away!'):
#         super(MultiplexChannelSession, self).close(code, message)


from twisted.python import log
from sockjs.cyclone.transports import base
from sockjs.cyclone.session import MultiplexChannelSession
    def connectionMade(self, info):
        self.endpoints = dict()
        self.handler = base.MultiplexTransport(self.session.conn_info)
    
    def messageReceived(self, message):
        try:
            msgtype, topic, payload = self._messageSplit(message)
        except ValueError:
            log.msg('invalid message received <%s>' % message)
            return

        if topic not in self.channels:
            return

        if topic in self.endpoints:
            session = self.endpoints[topic]

            if msgtype == 'uns':
                del self.endpoints[topic]
                session._close()
            elif msgtype == 'msg':
                if payload:
                    session.messageReceived(payload)
        else:
            if msgtype == 'sub':

                session_args = (self.channels[topic], self.session.server,
                                self, topic)
                session = self.session.server.create_session(
                                     session_id=None, register=False,

# Path: sockjs/cyclone/transports/base.py
# class BaseTransportMixin(object):
# class MultiplexTransport(BaseTransportMixin):
#     def get_conn_info(self):
#     def session_closed(self):
#     def __init__(self, conn_info):
#     def get_conn_info(self):
# 
# Path: sockjs/cyclone/session.py
# class MultiplexChannelSession(BaseSession):
#     def __init__(self, conn, server, base, name):
#         super(MultiplexChannelSession, self).__init__(conn, server)
# 
#         self.base = base
#         self.name = name
# 
#     def send_message(self, msg, stats=True):
#         if not self.base.is_closed:
#             msg = 'msg,%s,%s' % (self.name, msg)
#             self.base.session.send_message(msg, stats)
# 
#     def messageReceived(self, msg):
#         self.conn.messageReceived(msg)
# 
#     def close(self, code=3000, message='Go away!'):
#         self.base.sendMessage('uns,%s' % self.name)
#         self._close(code, message)
# 
#     # Non-API version of the close, without sending the close message
#     def _close(self, code=3000, message='Go away!'):
#         super(MultiplexChannelSession, self).close(code, message)


# Path: sockjs/cyclone/conn.py
from twisted.python import log
from sockjs.cyclone.transports import base
from sockjs.cyclone.session import MultiplexChannelSession

    def connectionMade(self, info):
        self.endpoints = dict()
        self.handler = base.MultiplexTransport(self.session.conn_info)
    
    def messageReceived(self, message):
        try:
            msgtype, topic, payload = self._messageSplit(message)
        except ValueError:
            log.msg('invalid message received <%s>' % message)
            return

        if topic not in self.channels:
            return

        if topic in self.endpoints:
            session = self.endpoints[topic]

            if msgtype == 'uns':
                del self.endpoints[topic]
                session._close()
            elif msgtype == 'msg':
                if payload:
                    session.messageReceived(payload)
        else:
            if msgtype == 'sub':

                session_args = (self.channels[topic], self.session.server,
                                self, topic)
                session = self.session.server.create_session(
                                     session_id=None, register=False,

                                     session_factory=(MultiplexChannelSession,