def net_recv(ws, conn):
    ''' Read pending data from network into websocket. '''
    in_data = conn.recv(RECEIVE_BYTES)
    if not in_data:
        # A receive of zero bytes indicates the TCP socket has been closed. We
        # need to pass None to wsproto to update its internal state.
        print('Received 0 bytes (connection closed)')
        ws.receive_data(None)
    else:
        print('Received {} bytes'.format(len(in_data)))
        ws.receive_data(in_data)
def net_recv ( ws , conn ) : in_data = conn . recv ( RECEIVE_BYTES ) if not in_data : print ( 'Received 0 bytes (connection closed)' ) ws . receive_data ( None ) else : print ( 'Received {} bytes' . format ( len ( in_data ) ) ) ws . receive_data ( in_data )
Read pending data from network into websocket.