Added the handling of pingreq.
Added correct handling of the keepalive interval.