TubeSock

A WebSocket client implemented in Java

Лицензия

Лицензия

MIT
Группа

Группа

com.firebase
Идентификатор

Идентификатор

tubesock
Последняя версия

Последняя версия

0.0.12
Дата

Дата

Тип

Тип

jar
Описание

Описание

TubeSock
A WebSocket client implemented in Java
Ссылка на сайт

Ссылка на сайт

https://github.com/firebase/TubeSock
Организация-разработчик

Организация-разработчик

Firebase
Система контроля версий

Система контроля версий

https://github.com/firebase/TubeSock

Скачать tubesock

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.firebase/tubesock/ -->
<dependency>
    <groupId>com.firebase</groupId>
    <artifactId>tubesock</artifactId>
    <version>0.0.12</version>
</dependency>
// https://jarcasting.com/artifacts/com.firebase/tubesock/
implementation 'com.firebase:tubesock:0.0.12'
// https://jarcasting.com/artifacts/com.firebase/tubesock/
implementation ("com.firebase:tubesock:0.0.12")
'com.firebase:tubesock:jar:0.0.12'
<dependency org="com.firebase" name="tubesock" rev="0.0.12">
  <artifact name="tubesock" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.firebase', module='tubesock', version='0.0.12')
)
libraryDependencies += "com.firebase" % "tubesock" % "0.0.12"
[com.firebase/tubesock "0.0.12"]

Зависимости

compile (1)

Идентификатор библиотеки Тип Версия
org.apache.httpcomponents : httpclient jar 4.0.1

Модули Проекта

Данный проект не имеет модулей.

TubeSock - A Java WebSocket Client Library

TubeSock is a Java implementation of the client side of the WebSocket Protocol for use in Java applications.

Status

Status: Archived

This library is no longer actively maintained. We do not recommend using this library in production.

If you maintain a fork of this library that you believe is healthier than the official version, we may consider recommending your fork. Please open a Pull Request if you believe that is the case.

Building / Installing

Maven

Add the following to your pom.xml file:

<dependency>
  <groupId>com.firebase</groupId>
  <artifactId>tubesock</artifactId>
  <version>0.0.1</version>
</dependency>

Building standalone

If you want to build a standalone jar to include in an application, clone the application and then run:

mvn clean package -Dstandalone

This will generate a jar that includes shaded versions of the dependencies to avoid clashing with any other dependencies your application might have.

Dependencies

If compiling from source, you must include Apache Httpcomponents Client 4.2.5 as well.

Usage

This code snippet demonstrates using TubeSock in your code:

    URI url = new URI("ws://127.0.0.1:8080/test");
    WebSocket websocket = new WebSocket(url);

    // Register Event Handlers
    websocket.setEventHandler(new WebSocketEventHandler() {
            public void onOpen() {
                System.out.println("--open");
            }

            public void onMessage(WebSocketMessage message) {
                System.out.println("--received message: " + message.getText());
            }

            public void onClose() {
                System.out.println("--close");
            }

            public void onError(WebSocketException e) {
                System.err.println(e.getMessage());
            }

            public void onLogMessage(String msg) {
                System.err.println(msg);
            }
        });

    // Establish a WebSocket Connection
    websocket.connect();

    // Send UTF-8 Text
    websocket.send("hello world");

    // Close WebSocket Connection
    websocket.close();

Architecture

TubeSock uses two threads, one for reading and one for writing. The underlying socket is a blocking socket, or, if using wss, a blocking SSLSocket. Using an SSLSocket is preferred over a non-blocking socket with SSLEngine due to bugs in some Android implementations of SSLEngine. TubeSock can make SSL-enabled connections from both a standard JVM as well as Android, tested on version 2.3 and forward.

When events occur, the specified handler will be called with details of the event. The onMessage method will always be called from the reader thread. The onError and onClose methods can be called from either the writer or the reader. As both threads perform blocking I/O, it is recommended that you handle events on your own thread.

Acknowledgements

TubeSock is based on work originally done by Roderick Baier on the weberknecht library. Renamed and relicensed with permission.

License

MIT.

com.firebase

Firebase

Версии библиотеки

Версия
0.0.12
0.0.11
0.0.10
0.0.9
0.0.8
0.0.7
0.0.6
0.0.5
0.0.4
0.0.3
0.0.2
0.0.1