added a timeout field as well as 4 event handlers, onLoopBegin, End, OnConnect and onNoConnection.
updated test to reflect new features.