• This repository has been archived on 06/Mar/2018
  • Stars
    star
    948
  • Rank 48,064 (Top 1.0 %)
  • Language
    Java
  • License
    MIT License
  • Created almost 13 years ago
  • Updated over 2 years ago

Reviews

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

Repository Details

Socket.IO Client Implementation in Java

Flattr this git repo

Socket.IO-Client for Java

socket.io-java-client is an easy to use implementation of socket.io for Java.

It uses Weberknecht as transport backend, but it's easy to write your own transport. See description below. An XHR-Transport is included, too. But it's not functional in its current state.

The API is inspired by java-socket.io.client.

Features:

  • transparent reconnecting - The API cares about re-establishing the connection to the server when the transport is interrupted.
  • easy to use API - implement an interface, instantiate a class - you're done.
  • output buffer - send data while the transport is still connecting. No problem, socket.io-java-client handles that.
  • meaningful exceptions - If something goes wrong, SocketIO tries to throw meaningful exceptions with hints for fixing.

Status: Connecting with Websocket is production ready. XHR is in beta.

How to use

Using socket.io-java-client is quite simple. But lets see:

Checkout and compile the project:

git clone git://github.com/Gottox/socket.io-java-client.git
cd socket.io-java-client
ant jar
mv jar/socketio.jar /path/to/your/libs/project

If you're using ant, change your build.xml to include socketio.jar. If you're eclipse, add the jar to your project buildpath.

Afterwards, you'll be able to use this library:

		SocketIO socket = new SocketIO("http://127.0.0.1:3001/");
		socket.connect(new IOCallback() {
			@Override
			public void onMessage(JSONObject json, IOAcknowledge ack) {
				try {
					System.out.println("Server said:" + json.toString(2));
				} catch (JSONException e) {
					e.printStackTrace();
				}
			}

			@Override
			public void onMessage(String data, IOAcknowledge ack) {
				System.out.println("Server said: " + data);
			}

			@Override
			public void onError(SocketIOException socketIOException) {
				System.out.println("an Error occured");
				socketIOException.printStackTrace();
			}

			@Override
			public void onDisconnect() {
				System.out.println("Connection terminated.");
			}

			@Override
			public void onConnect() {
				System.out.println("Connection established");
			}

			@Override
			public void on(String event, IOAcknowledge ack, Object... args) {
				System.out.println("Server triggered event '" + event + "'");
			}
		});
		
		// This line is cached until the connection is establisched.
		socket.send("Hello Server!");

For further informations, read the Javadoc.

Checkout

  • with git

     git clone git://github.com/Gottox/socket.io-java-client.git
    
  • with mercurial

     hg clone https://bitbucket.org/Gottox/socket.io-java-client 
    

Both repositories are synchronized and up to date.

Building

to build a jar-file:

cd $PATH_TO_SOCKETIO_JAVA
ant jar
ls jar/socketio.jar

You'll find the socket.io-jar in jar/socketio.jar

Bugs

Please report any bugs feature requests to the Github issue tracker

Frameworks

This Library was designed with portability in mind.

  • Android is fully supported.
  • JRE is fully supported.
  • GWT does not work at the moment, but a port would be possible.
  • Java ME does not work at the moment, but a port would be possible.
  • ... is there anything else out there?

Testing

There comes a JUnit test suite with socket.io-java-client. Currently it's tested with Eclipse.

You need node installed in PATH.

  • open the project with eclipse
  • open tests/io.socket/AllTests.java
  • run it as JUnit4 test.

TODO

  • Socket.io needs more unit-tests.
  • XhrTransport needs to pass all tests.
  • If websockets are failing (due to proxy servers e.g.), use XHR automaticly instead.

License - the boring stuff...

This library is distributed under MIT Licence.

Sounds so interesting...

You'll find further documentation at the Socket.io-java-client Github Wiki

More Repositories

1

terminal.js

Javascript terminal emulator library that aims to be xterm compliant and is supposed to work in browsers and node.js.
JavaScript
590
star
2

node-webterm

simple demo application for child_pty and terminal.js.
JavaScript
244
star
3

smu

simple markup - markdown like syntax
C
192
star
4

sltar

Minimal implementation of tar.
C
105
star
5

node-pdfutils

tool for analyzing and converting PDF
C++
104
star
6

child_pty

a modern node.js module for interacting with pseudo terminals.
JavaScript
89
star
7

bgs

simple background setter based on imlib2
C
60
star
8

node-urlify

simplifies converting utf8 strings to ASCII strings which can be used as readable URL-segments.
JavaScript
56
star
9

mongoose-cache

Caches Database querys the easy way. This module is currently not developed. Nevertheless, I will apply patches.
JavaScript
36
star
10

sqsh-tools

πŸ—œοΈ fast r/o squashfs implementation written in C.
C
35
star
11

jQR

Generates a QR-Code in Plain Javascript using canvas
JavaScript
27
star
12

chelf

change or display the stack size of an ELF binary
C
22
star
13

irc-message-action

Github Action to Interact with IRC Channels and Users
JavaScript
20
star
14

jQRange

Range Plugin for jQuery
JavaScript
16
star
15

nson

nson is a data framework for C with a very fast JSON and property list parser.
C
13
star
16

reveal.js-ace

a reveal.js plugin that allows to embed ACE editors in a reveal.js presentation.
JavaScript
12
star
17

qemuconf

simple qemu launcher with config file support
C
7
star
18

quickjs-dts

quickjs typescript definitions
Makefile
6
star
19

node-termios

C++
6
star
20

java2js

Java to Javascript Transpiler - research project
JavaScript
5
star
21

quotefm-node

The Quote.fm API for node
JavaScript
5
star
22

hexadisplay

LED display with ESP32
Rust
5
star
23

socket.io-java-client-new

Java implementation of the upcoming socket.io-1.0 protocol. For now, it supports only engine.io.
Java
4
star
24

OAuthUtils-Android

Eases the authentication with an OAuth Provider
Java
3
star
25

zsh-eval-cached

Caches completitions
Shell
3
star
26

pam_ns

simple PAM module that uses unshare(2) to isolate a user.
C
3
star
27

pb

C
3
star
28

dewey

dewey is a simple version parser and comperator that aims to be compatible to NetBSD and xbps' comperator implementation.
Rust
2
star
29

btun

bidirectional tunnel through a webbrowser
C
2
star
30

vnc2gif

JavaScript
2
star
31

libfetch

C
2
star
32

greasemonkey-mastodon-translate

Simple script to translate toots on mastodon for instances that do not support translation.
JavaScript
2
star
33

keycloak-metrics-spi-k8s

init container for jboss/keycloak to enable prometheus monitoring at startup.
Dockerfile
2
star
34

en.wipikedia.org

HTML
2
star
35

url-shortener-action

JavaScript
2
star
36

CodeRacoon

an eclipse plugin to find and examine source code of class files without saving them locally.
Java
2
star
37

e

a text editor written in C
C
2
star
38

void-docker

Dockerfile
1
star
39

ewmhgestures

use OSX-like gestures on Linux
C
1
star
40

libsqsh-lzo

LZO extension to libsqsh.
C
1
star
41

reverse-tcp

Rust
1
star
42

swtterminator

port of Terminator (http://software.jessies.org/terminator/) to Eclipse
Java
1
star
43

PollEnflug

Simplistic and performant HTTP long poll server
JavaScript
1
star
44

void-make-vm

Shell
1
star
45

adventofcode

JavaScript
1
star
46

Gottox

1
star
47

pdfium

patchset to make pdfium run on node
C
1
star
48

joyexec

Execute commands by a Joystick
C
1
star
49

saxmir

CSS selectors for SAX
Java
1
star
50

libRacoon

a library which finds and examines source code of class files without saving them locally.
Java
1
star
51

runit

a UNIX init scheme with service supervision
C
1
star
52

c-microbench

C
1
star
53

get-ip

Small microservice that reports the clients IP address
Rust
1
star
54

nile

C
1
star
55

KeyboardLed

Small Service for Milestone2. Enables keyboard backlight for cyanogen mod. Not needed anymore
Java
1
star
56

zeditor

Stateless Richtext Editor
JavaScript
1
star
57

mk

calls the right build system for the current project
Rust
1
star