change the api of the init

to add the event of the OnConnect , OnDisconnect , OnSocketError , change the init of the api.