Fixed some types decoding bugs and extended protocol support

Now client completely successfully connects but it drops connection
because server doesn't send keep alive packets at the moment. I'm
working on it.