add callback to close method and emit connect [ closes #114 ]