refactoring for cleaner support of websockets in obj-c