Implemented logic for connect and accept sessions