# Path: sockjs/exceptions.py
# class SessionIsAcquired(SockjsException):
#     """Session is acquired."""
# 
# class SessionIsClosed(SockjsException):
#     """Session is closed."""
# 
# Path: sockjs/protocol.py
# def close_frame(code, reason):
#     return FRAME_CLOSE + json.dumps([code, reason], **kwargs)
# 
# ENCODING = "utf-8"
# 
# Path: sockjs/protocol.py
# STATE_CLOSING = 2
# 
# STATE_CLOSED = 3
# 
# FRAME_CLOSE = "c"
# 
# FRAME_MESSAGE = "a"


import aiohttp
import asyncio
from ..exceptions import SessionIsAcquired, SessionIsClosed
from ..protocol import close_frame, ENCODING
from ..protocol import STATE_CLOSING, STATE_CLOSED, FRAME_CLOSE, FRAME_MESSAGE
            await self.session._remote_closed()
            await self.send(close_frame(3000, "Go away!"))

        else:
            # acquire session
            try:
                await self.manager.acquire(self.session)
            except SessionIsAcquired:
                await self.send(close_frame(2010, "Another connection still open"))
            else:
                try:
                    while True:
                        if self.timeout:
                            try:
                                frame, text = await asyncio.wait_for(
                                    self.session._wait(), timeout=self.timeout
                                )
                            except asyncio.futures.TimeoutError:
                                frame, text = FRAME_MESSAGE, "a[]"
                        else:
                            frame, text = await self.session._wait()

                        if frame == FRAME_CLOSE:
                            await self.session._remote_closed()
                            await self.send(text)
                            return
                        else:
                            stop = await self.send(text)
                            if stop:
                                break

# Path: sockjs/exceptions.py
# class SessionIsAcquired(SockjsException):
#     """Session is acquired."""
# 
# class SessionIsClosed(SockjsException):
#     """Session is closed."""
# 
# Path: sockjs/protocol.py
# def close_frame(code, reason):
#     return FRAME_CLOSE + json.dumps([code, reason], **kwargs)
# 
# ENCODING = "utf-8"
# 
# Path: sockjs/protocol.py
# STATE_CLOSING = 2
# 
# STATE_CLOSED = 3
# 
# FRAME_CLOSE = "c"
# 
# FRAME_MESSAGE = "a"


# Path: sockjs/transports/base.py
import aiohttp
import asyncio
from ..exceptions import SessionIsAcquired, SessionIsClosed
from ..protocol import close_frame, ENCODING
from ..protocol import STATE_CLOSING, STATE_CLOSED, FRAME_CLOSE, FRAME_MESSAGE

            await self.session._remote_closed()
            await self.send(close_frame(3000, "Go away!"))

        else:
            # acquire session
            try:
                await self.manager.acquire(self.session)
            except SessionIsAcquired:
                await self.send(close_frame(2010, "Another connection still open"))
            else:
                try:
                    while True:
                        if self.timeout:
                            try:
                                frame, text = await asyncio.wait_for(
                                    self.session._wait(), timeout=self.timeout
                                )
                            except asyncio.futures.TimeoutError:
                                frame, text = FRAME_MESSAGE, "a[]"
                        else:
                            frame, text = await self.session._wait()

                        if frame == FRAME_CLOSE:
                            await self.session._remote_closed()
                            await self.send(text)
                            return
                        else:
                            stop = await self.send(text)
                            if stop:
                                break

                except asyncio.CancelledError: