add onConnect when socket is conencted.