<s> from ranstring import randomByteString <EOL> from twisted . internet import reactor <EOL> from autobahn . twisted . websocket import WebSocketClientFactory , WebSocketClientProtocol , connectWS <EOL> BATCH_SIZE = <NUM_LIT:1> * <NUM_LIT:2> ** <NUM_LIT:20> <EOL> class StreamingHashClientProtocol ( WebSocketClientProtocol ) : <EOL> """<STR_LIT>""" <EOL> def sendOneBatch ( self ) : <EOL> data = randomByteString ( BATCH_SIZE ) <EOL> self . sendMessageFrameData ( data ) <EOL> def onOpen ( self ) : <EOL> self . count = <NUM_LIT:0> <EOL> self . beginMessage ( isBinary = True ) <EOL> self . beginMessageFrame ( <NUM_LIT> ) <EOL> self . sendOneBatch ( ) <EOL> def onMessage ( self , payload , isBinary ) : <EOL> print ( "<STR_LIT>" . format ( self . count , payload . decode ( '<STR_LIT:utf8>' ) ) ) <EOL> self . count += <NUM_LIT:1> <EOL> self . sendOneBatch ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> factory = WebSocketClientFactory ( u"<STR_LIT>" ) <EOL> factory . protocol = StreamingHashClientProtocol <EOL> connectWS ( factory ) <EOL> reactor . run ( ) </s>
