# socket.io-java-emitter **Repository Path**: baishaochuan/socket.io-java-emitter ## Basic Information - **Project Name**: socket.io-java-emitter - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-01-30 - **Last Updated**: 2024-01-30 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README socket.io-java-emitter ====================== [![Build Status](https://travis-ci.org/sunsus/socket.io-java-emitter.svg)](https://travis-ci.org/sunsus/socket.io-java-emitter) A Java implementation of socket.io-emitter This project uses [msgpack-java](https://github.com/msgpack/msgpack-java) and [jedis](https://github.com/xetorthio/jedis). ## Usage ### Using an existing redis instance ```java JedisPool jedis = new JedisPool(new JedisPoolConfig(), "127.0.0.1", 6379); Emitter emitter = Emitter.getInstance(jedis, new HashMap()); Emitter emitter = Emitter.getInstance(null, opts); emitter.of("/namespace").emit("event", "Hello World!"); ``` ### Emitting without manually creating a redis instance ```java HashMap opts = new HashMap(); opts.put("host", "127.0.0.1"); opts.put("port", "6379"); Emitter emitter = Emitter.getInstance(null, opts); emitter.of("/namespace").emit("event", "Hello World!"); ``` ### Broadcasting and other flags Possible flags * json * volatile * broadcast ```java Emitter emitter = Emitter.getInstance(null, ImmutableMap.of("host", "127.0.0.1", "port", "6379")); // broadcast can be replaced by any of the other flags emitter.of("/namespace").broadcast().emit("event", "Hello World!"); ``` ### Emitting objects ```java Emitter emitter = Emitter.getInstance(null, ImmutableMap.of("host", "127.0.0.1", "port", "6379")); String jsonData = "{\"test\":[\"test\",\"test1\"],\"name\":\"xxxxx\",\"id\":1234,\"float\":1234.00,\"bool\":true,\"object\":{\"name\":\"xxxxx\",\"id\":1234}}"; JSONObject jsonRoot = new JSONObject(jsonData); emitter.of("/namespace").emit("event", jsonRoot); ``` ## Dependencies This module requires a [Redis][redis] to be available on the network. ### License Copyright © 2014 sunsus GmbH Distributed under the [MIT License][mit]. [Redis]: http://redis.io/ [MIT]: http://www.opensource.org/licenses/mit-license.php