diff --git a/sockette.d.ts b/sockette.d.ts index a61ebe2..6ff2779 100644 --- a/sockette.d.ts +++ b/sockette.d.ts @@ -12,6 +12,7 @@ declare module "sockette" { protocols?: string | string[]; timeout?: number; maxAttempts?: number; + binaryType?: BinaryType; onopen?: (this: Sockette, ev: Event) => any; onmessage?: (this: Sockette, ev: MessageEvent) => any; onreconnect?: (this: Sockette, ev: Event | CloseEvent) => any; diff --git a/src/index.js b/src/index.js index 594bd8a..406783c 100644 --- a/src/index.js +++ b/src/index.js @@ -9,6 +9,8 @@ export default function (url, opts) { $.open = function () { ws = new WebSocket(url, opts.protocols || []); + ws.binaryType = opts.binaryType || 'blob'; + ws.onmessage = opts.onmessage || noop; ws.onopen = function (e) {