com.github.homesynck:homesynck-java-sdk

A cross platform sdk for homesynck applications

License

License

Categories

Categories

Java Languages
GroupId

GroupId

com.github.homesynck
ArtifactId

ArtifactId

homesynck-java-sdk
Last Version

Last Version

1.0.3
Release Date

Release Date

Type

Type

jar
Description

Description

com.github.homesynck:homesynck-java-sdk
A cross platform sdk for homesynck applications
Project URL

Project URL

https://github.com/Homesynck/homesynck-java-sdk
Source Code Management

Source Code Management

http://github.com/Homesynck/homesynck-java-sdk/tree/master

Download homesynck-java-sdk

How to add to project

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

Dependencies

compile (6)

Group / Artifact Type Version
ch.kuon.phoenix » channel jar 0.1.6
com.neovisionaries : nv-websocket-client jar 2.14
com.github.openjson : openjson jar 1.0.12
org.jetbrains : annotations jar 20.1.0
io.github.java-diff-utils : java-diff-utils jar 4.9
org.jetbrains.kotlin : kotlin-stdlib jar 1.5.0-M2

Project Modules

There are no modules declared in this project.

thumbnail

Homesynck Java SDK

How to install?

With maven

Add the following dependency to your pom.xml to import the api :

<dependency>
    <groupId>com.github.homesynck</groupId>
    <artifactId>homesynck-java-sdk</artifactId>
    <version>1.0.2</version>
</dependency>

With Gradle

Add the following dependency to your build.gradle to import the api :

implementation group: 'com.github.homesynck', name: 'homesynck-java-sdk', version: '1.0.2'

Other

You can also check this website for other configurations and older versions.

Start

The server address is set to default on our servers. If you self-host the server, you can change the server address by using the following code :

com.github.homesynck.connect.Connection.setHost("ws://example.com/socket");   // without https server
com.github.homesynck.connect.Connection.setHost("wss://example.com/socket");  // with https server

Authentication

To register and connect to the repository of your application on the server, first you will need to send your phone number to the server in order to avoid fake account creation. One phone number can only create one account every thirty days. Then, a token will be sent to you on their mobile. You can now register to the server by using the register method and connect to the directory by using the create function (create also connect if the directory exist).

Here is a simple example:

import com.github.homesynck.Response;
import com.github.homesynck.connect.Directory;
import com.github.homesynck.connect.Session;
import com.github.homesynck.data.FileManager;
import com.github.homesynck.data.FileSynck;
import java.io.IOException;

public class MyApplication {
    private static FileManager fileManager;
    private static FileSynck fileSynck;

    public static void main(String[] args) {
        Session session = Session.getSession();

        Response response = session.phoneValidation("+33000000000");
        if (!response.isCorrect()) {
            System.out.println("Error on send phone validation");
            return;
        }

        response = session.register("John doe", "I<3AgeOfEmpires", "123456");
        if (!response.isCorrect()) {
            System.out.println("Error on account registration");
            return;
        }

        Response directoryResponse = Directory.createSecured("MyDirectory",
                "The directory for the readme application", "Thumbnail", "directoryPassword");
        System.out.println(directoryResponse);
        if (!directoryResponse.isCorrect()) {
            System.out.println("Error on directory registration");
            return;
        }
        
        //...
    }
}

To login, the process is very similar but without the phone validation

Synchronizing files

After connecting to the account, you need to join the synck channel of your directory in order to synchronize your files by creating a new FileSynck and use fileSynck.startSyncing();.

To activate the live update, you need to register a Consumer with fileSynck.setOnUpdate(Promise<Void> promise); before joining the channel. You are now ready to edit or create files with fileManager.editFile(String path, String content);, get every files in a HashMap<String, String> with fileManager.getFiles();, specify a path with fileManager.getFile(String Path);, or delete a file with fileManager.deleteFile(String path);. If you want to save these datas and push all of these changes on the server, you can use fileSynck.pushInstructions();.

Here is a short example where we show "update(s) receive" when we receive one or more updates, then edit and delete two files and push these updates to the server.

import com.github.homesynck.data.FileSynck;

public class MyApplication {
    private static FileManager fileManager;
    private static FileSynck fileSynck;

    public static void main(String[] args) {
        //...

        // You need to choose where the API store all of the datas.
        fileManager = new FileManager("./myStorageDirectory/");
        //let the directoryPassword empty if the directory is not secured
        fileSynck = new FileSynck(fileManager, "directoryPassword");
        
        fileSynck.setOnUpdate(msg -> {
            System.out.println("update(s) receive");
        });

        Response response = fileSynck.startSyncing();
        if (!response.isCorrect) {
            System.out.println("Error on join: " + response);
            return;
        }

        try {
            fileManager.editFile("/myDocument/PositiveReview.txt", "this documentation is very amazing!");
        } catch (IOException e) {
            e.printStackTrace();
        }

        fileManager.deleteFile("/myDocument/NegativeReview.txt");

        fileSynck.pushInstructions();
    }
}

License

Licensed under MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT).

com.github.homesynck
Message synchronization made easy!

Versions

Version
1.0.3
1.0.2
1.0.1
1.0.0
0.2.2
0.2.0
0.1.1
0.1