Pure lua

Rewrite in pure lua without libwebsocket dependency.