Socket
Book a DemoInstallSign in
Socket

engine.io-browser

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

engine.io-browser

Client for the realtime Engine

latest
Source
npmnpm
Version
4.0.0
Version published
Maintainers
1
Created
Source

Engine.IO browser

Build Status NPM version

This is the browser-only client for Engine.IO, the implementation of transport-based cross-browser/cross-device bi-directional communication layer for Socket.IO.

How to use

Standalone

You can find an engine.io.js file in this repository, which is a standalone build you can use as follows:

<script src="/path/to/engine.io.js"></script>
<script>
  // eio = Socket
  const socket = eio("ws://localhost");
  socket.on("open", () => {
    socket.on("message", (data) => {});
    socket.on("close", () => {});
  });
</script>

With browserify

Engine.IO is a commonjs module, which means you can include it by using require on the browser and package using browserify:

  • install the package

    $ npm install engine.io-browser
    
  • write your app code

    const socket = require("engine.io-browser")("ws://localhost");
    socket.on("open", () => {
      socket.on("message", (data) => {});
      socket.on("close", () => {});
    });
    
  • build your app bundle

    $ browserify app.js > bundle.js
    
  • include on your page

    <script src="/path/to/bundle.js"></script>
    

Sending and receiving binary

<script src="/path/to/engine.io.js"></script>
<script>
  const socket = new eio.Socket("ws://localhost/");
  socket.binaryType = "blob";
  socket.on("open", () => {
    socket.send(new Int8Array(5));
    socket.on("message", (blob) => {});
    socket.on("close", () => {});
  });
</script>

FAQs

Package last updated on 21 Jun 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts