engine.io-browser

4.0.0 • Public • Published

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:

  1. install the package

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

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

    $ browserify app.js > bundle.js
  4. 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> 

Readme

Keywords

none

Package Sidebar

Install

npm i engine.io-browser

Weekly Downloads

1

Version

4.0.0

License

MIT

Unpacked Size

103 kB

Total Files

18

Last publish

Collaborators

  • renzholy