That function should be defined after websocket_payload, in a top down fashion. I didn't understand what it was about having not encountered it while reading the file yet.