merge writeToLocal function.
rewrite onLocalTcpSocketReadyRead function as a clone of python version.
fix handleStageHello.

almost a clone of python version.