<s> '''<STR_LIT>''' <EOL> import logging <EOL> from pulsar . apps import data <EOL> from . websocket import WebSocket , WebSocketProtocol <EOL> __all__ = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> LOGGER = logging . getLogger ( '<STR_LIT>' ) <EOL> class WS : <EOL> '''<STR_LIT>''' <EOL> frame_parser = None <EOL> def on_open ( self , websocket ) : <EOL> '''<STR_LIT>''' <EOL> pass <EOL> def on_message ( self , websocket , message ) : <EOL> '''<STR_LIT>''' <EOL> pass <EOL> def on_bytes ( self , websocket , body ) : <EOL> '''<STR_LIT>''' <EOL> pass <EOL> def on_ping ( self , websocket , message ) : <EOL> '''<STR_LIT>''' <EOL> websocket . pong ( message ) <EOL> def on_pong ( self , websocket , body ) : <EOL> '''<STR_LIT>''' <EOL> pass <EOL> def on_close ( self , websocket ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> class PubSubClient ( data . PubSubClient ) : <EOL> __slots__ = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def __init__ ( self , websocket , channel ) : <EOL> self . websocket = websocket <EOL> self . channel = channel <EOL> def __call__ ( self , channel , message ) : <EOL> handler = self . websocket . handler <EOL> handler . write ( self . websocket , message ) <EOL> class PubSubWS ( WS ) : <EOL> '''<STR_LIT>''' <EOL> client = PubSubClient <EOL> def __init__ ( self , pubsub , channel ) : <EOL> self . pubsub = pubsub <EOL> self . channel = channel <EOL> def on_open ( self , websocket ) : <EOL> '''<STR_LIT>''' <EOL> LOGGER . info ( '<STR_LIT>' , <EOL> self . pubsub , self . channel ) <EOL> self . pubsub . add_client ( self . client ( websocket , self . channel ) ) <EOL> def write ( self , websocket , message ) : <EOL> websocket . write ( message ) </s>
