Make server use StateControl and threading