diff --git a/src/index.js b/src/index.js index 3a5c5dd..c6ed940 100644 --- a/src/index.js +++ b/src/index.js @@ -50,22 +50,21 @@ export function createWebsocketMiddleware (options = {}) { connections[endpoint] = connection - connection.onmessage(function (data) { + connection.socket.onmessage = function (data) { store.dispatch(createMessageAction(endpoint, data)) - }) + } - connection.onopen(function () { + connection.socket.onopen = function () { store.dispatch(createConnectionAction(endpoint)) - }) + } - connection.onclose(function () { + connection.socket.onclose = function () { store.dispatch(createDisonnectionAction(endpoint)) - }) + } - connection.onerror(function (error) { + connection.socket.onerror = function (error) { store.dispatch(createErrorAction(endpoint, error)) - }) - + } return connection }