• Stars
    star
    168
  • Rank 225,507 (Top 5 %)
  • Language
    Java
  • License
    Other
  • Created over 6 years ago
  • Updated 12 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Engine.IO Server Library for Java

Engine.IO Java

Build Status codecov

This is the Engine.IO Server Library for Java ported from the JavaScript server.

NOTE This library will follow the major version of the JS library starting with version 4.

See also: Socket.IO-server Java, Engine.IO-client Java

Documentation

Complete documentation can be found here.

Installation

If you're looking for the socket.io library instead, please see here.

The latest artifact is available on Maven Central.

Maven

Add the following dependency to your pom.xml.

<dependencies>
  <dependency>
    <groupId>io.socket</groupId>
    <artifactId>engine.io-server</artifactId>
    <version>6.2.1</version>
  </dependency>
</dependencies>

Gradle

Add it as a gradle dependency in build.gradle.

implementation ('io.socket:engine.io-server:6.2.1')

Engine.IO Protocol 1.x suppport

The current version of engine.io-java does not support protocol 1.x.

Usage

If you're looking for the socket.io library instead, please see here.

Usage is slightly different based on the server being used.

Create a servlet to handle the HTTP requests as follows:

public class EngineIoServlet extends HttpServlet {

    private final EngineIoServer mEngineIoServer = new EngineIoServer();

    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException {
        mEngineIoServer.handleRequest(request, response);
    }
}

Listen for new connections as follows:

EngineIoServer server;  // server instance
server.on("connection", new Emitter.Listener() {
    @Override
    public void call(Object... args) {
        EngineIoSocket socket = (EngineIoSocket) args[0];
        // Do something with socket like store it somewhere
    }
});

Listen for raw packets received as follows:

EngineIoSocket socket;  // socket received in "connection" event

socket.on("packet", new Emitter.Listener() {
    @Override
    public void call(Object... args) {
        Packet packet = (Packet) args[0];
        // Do something with packet.
    }
});

Listen for messages from the remote client as follows:

EngineIoSocket socket;  // socket received in "connection" event

socket.on("message", new Emitter.Listener() {
    @Override
    public void call(Object... args) {
        Object message = args[0];
        // message can be either String or byte[]
        // Do something with message.
    }
});

Send a packet to client as follows:

EngineIoSocket socket;  // socket received in "connection" event

socket.send(new Packet<>(Packet.MESSAGE, "foo"));

WebSockets

Please see the complete documentation on handling WebSockets here.

Features

This library supports all of the features the JS server does, including events, options and upgrading transport.

License

Apache 2.0

More Repositories

1

socket.io

Realtime application framework (Node.JS server)
TypeScript
60,848
star
2

socket.io-client

Realtime application framework (client)
10,608
star
3

socket.io-client-java

Full-featured Socket.IO Client Library for Java, which is compatible with Socket.IO v1.0 and later.
Java
5,302
star
4

socket.io-client-swift

Swift
5,199
star
5

engine.io

The engine used in the Socket.IO JavaScript server, which manages the low-level transports such as HTTP long-polling and WebSocket.
4,596
star
6

socket.io-redis-adapter

Adapter to enable broadcasting of events to multiple separate socket.io server nodes.
TypeScript
2,736
star
7

socket.io-client-cpp

C++11 implementation of Socket.IO client
C++
2,243
star
8

socket.io-p2p

JavaScript
1,027
star
9

engine.io-client

The engine used in the Socket.IO JavaScript client, which manages the low-level transports such as HTTP long-polling, WebSocket and WebTransport.
742
star
10

socket.io-redis-emitter

The Socket.IO Redis emitter, allowing to communicate with a group of Socket.IO servers from another Node.js process.
TypeScript
717
star
11

socket.io-protocol

Socket.IO Protocol specification
JavaScript
504
star
12

engine.io-client-java

Engine.IO Client Library for Java
Java
359
star
13

socket.io-admin-ui

Admin UI for Socket.IO
Vue
344
star
14

socket.io-website

Socket.IO website and blog
JavaScript
318
star
15

engine.io-protocol

Engine.IO protocol
JavaScript
235
star
16

socket.io-adapter

The Socket.IO in-memory adapter
197
star
17

socket.io-parser

136
star
18

socket.io-deno

Socket.IO server for Deno
TypeScript
102
star
19

engine.io-parser

Parser for the engine.io protocol, used by client and server
74
star
20

socket.io-msgpack-parser

Socket.IO parser based on msgpack
JavaScript
64
star
21

socket.io-chat-platform

A basic chat platform based on Socket.IO
JavaScript
62
star
22

socket.io-sticky

A simple and performant way to use Socket.IO within a cluster.
JavaScript
42
star
23

socket.io-redis-streams-adapter

The Socket.IO adapter based on Redis Streams, allowing to broadcast events between several Socket.IO servers.
TypeScript
28
star
24

socket.io-postgres-adapter

The Socket.IO Postgres adapter, allowing to broadcast events between several Socket.IO servers
TypeScript
24
star
25

socket.io-mongo-adapter

The Socket.IO MongoDB adapter, allowing to broadcast events between several Socket.IO servers
TypeScript
24
star
26

socket.io-cluster-adapter

The Socket.IO official cluster adapter, allowing to broadcast events between several Socket.IO servers.
TypeScript
15
star
27

socket.io-json-parser

socket.io parser based on JSON.stringify / JSON.parse
JavaScript
13
star
28

socket.io-benchmarks

Benchmarks for Socket.IO
JavaScript
9
star
29

socket.io-minimal-example

Socket.IO minimal example
HTML
8
star
30

socket.io-compression-demo

JavaScript
7
star
31

get-started-drawing

7
star
32

lz77-compression-demo

JavaScript
7
star
33

socket.io-mongo-emitter

The Socket.IO MongoDB emitter, allowing to communicate with a group of Socket.IO servers from another Node.js process
TypeScript
6
star
34

socket.io-postgres-emitter

The Socket.IO Postgres emitter, allowing to communicate with a group of Socket.IO servers from another Node.js process.
TypeScript
5
star
35

socket.io-echo-server

Socket.IO echo server
JavaScript
4
star
36

socket.io-azure-service-bus-adapter

The Socket.IO adapter for Azure Service Bus, allowing to broadcast events between several Socket.IO servers.
TypeScript
4
star
37

socket.io-aws-sqs-adapter

The Socket.IO adapter for AWS Simple Queue Service (SQS), allowing to broadcast events between several Socket.IO servers.
TypeScript
4
star
38

socket.io-sample-playbook

This repository contains an Ansible playbook to set up a basic Socket.IO application.
JavaScript
4
star
39

tap-to-android

3
star
40

socket.io-swift-fiddle

Swift
2
star
41

socket.io-gcp-pubsub-adapter

The Socket.IO adapter for Google Cloud pub/sub, allowing to broadcast events between several Socket.IO servers
TypeScript
2
star
42

socket.io-browsers

A reusable list of browsers to test when using defunctzombie/zuul
JavaScript
1
star