Initial websocket API (derived from Marcin Kelar's impl