Skip to content

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

Notifications You must be signed in to change notification settings

scalajs-io/engine-io

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

engine.io API for Scala.js

engine.io - Engine.IO is the implementation of transport-based cross-browser/cross-device bi-directional communication layer for Socket.IO.

Build Requirements

Build/publish the SDK locally

 $ sbt clean publish-local

Running the tests

Before running the tests the first time, you must ensure the npm packages are installed:

$ npm install

Then you can run the tests:

$ sbt test

Examples

Listening on a port
import io.scalajs.npm.engineio._
import io.scalajs.nodejs.buffer.Buffer
import scala.scalajs.js

val server = EngineIO.listen(80)
server.on("connection", { socket: Socket =>
    socket.send("utf 8 string")
    socket.send(Buffer.from(js.Array(0, 1, 2, 3, 4, 5))); // binary data
})
Intercepting requests for a http.Server
import io.scalajs.npm.engineio._
import io.scalajs.nodejs.buffer.Buffer
import io.scalajs.nodejs.http.Http 

val http = Http.createServer()
http.listen(3000)

val server = EngineIO.attach(http)
server.on("connection", { socket: Socket =>
    socket.on("message", (data: Buffer) => {})
    socket.on("close", () => {})
})

Artifacts and Resolvers

To add the engine.io binding to your project, add the following to your build.sbt:

libraryDependencies += "io.scalajs.npm" %%% "engine-io" % "0.4.1"

Optionally, you may add the Sonatype Repository resolver:

resolvers += Resolver.sonatypeRepo("releases") 

About

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

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages