Skip to content
This repository has been archived by the owner on Nov 2, 2020. It is now read-only.

Installation and Configuration

Roman Baitaliuk edited this page Jan 19, 2018 · 10 revisions

Installation

There are two ways to install ClusterWS Client Java library

Maven

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

<dependency>
    <groupId>com.github.ClusterWS</groupId>
    <artifactId>ClusterWS-Client-Java</artifactId>
    <version>1.5.0</version>
</dependency>

Gradle

allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
    }
}
	
dependencies {
    compile 'com.github.ClusterWS:ClusterWS-Client-Java:1.5.0'
}

Configuration

To connect to the server use ClusterWS instance:

/**
   url: string - url to the server with ws/wss and port at the end. (must be provided)
*/
String url = "ws://localhost:80";
ClusterWS socket = new ClusterWS(url);
socket.connect();

Optional configurations

/**
   autoReconnect: boolean - allow to auto-reconnect to the server on lost connection. (default false)
   reconnectionIntervalMin: int - how long min time wait. (default 1000) in ms
   reconnectionIntervalMax: int - how long max time wait. (default 5000) in ms
   reconnectionAttempts: int - how many times to try, 0 means without limit. (default 0)
*/
socket.setReconnection(autoReconnect,reconnectionIntervalMin,reconnectionIntervalMax,reconnectionAttempts);