refactor: pull out processServerMessage