And also abstracted the encoding and sending away to websocket.c

Signed-off-by: Toon Schoenmakers <nighteyes1993@gmail.com>