added server state and filled in the handle_x functions. client now uses valid session id