A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/binaryType below:

WebSocket: binaryType property - Web APIs

WebSocket: binaryType property

Baseline Widely available

Note: This feature is available in Web Workers.

The WebSocket.binaryType property controls the type of binary data being received over the WebSocket connection.

Value

A string:

"blob"

Use Blob objects for binary data. This is the default value.

"arraybuffer"

Use ArrayBuffer objects for binary data.

Examples
// Create WebSocket connection.
const socket = new WebSocket("ws://localhost:8080");

// Change binary type from "blob" to "arraybuffer"
socket.binaryType = "arraybuffer";

// Listen for messages
socket.addEventListener("message", (event) => {
  if (event.data instanceof ArrayBuffer) {
    // binary frame
    const view = new DataView(event.data);
    console.log(view.getInt32(0));
  } else {
    // text frame
    console.log(event.data);
  }
});
Specifications Browser compatibility

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4