context based state machine for server