Skip to content
This repository has been archived by the owner on Jun 9, 2018. It is now read-only.

mikroskeem/votifier2-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

votifier2-java

Votifier2 vote packet generator.

Usage

See unit test or code below:

Socket socket = new Socket("127.0.0.1", 8192);
InputStream is = socket.getInputStream();
OutputStream os = socket.getOutputStream();

/* Read Votifier packet and grab challenge token */
String in = new BufferedReader(new InputStreamReader(is)).readLine();
String[] votifierIn = in.split(" ");

String challengeToken = votifierIn[2];

Votifier2.Vote vote = Votifier2.newVoteObject("mikroskeem", "votifier2-java");
byte[] message = Votifier2.encodeMessage(vote, challengeToken, "server-key");

/* Send vote object */
os.write(message);
os.flush();

/* Read status */
in = new BufferedReader(new InputStreamReader(is)).readLine();
JSONObject result = new JSONObject(in);
Assert.assertEquals("Votifier status was not 'ok'! Data: " + result, "ok", result.get("status"));

/* Close connection */
os.close();
socket.close();

Maven repository

Repository

<repository>
    <id>mikroskeem-repo</id>
    <name>mikroskeem Maven Repository</name>
    <url>https://repo.wut.ee/repository/mikroskeem-repo/</url>
    <releases>
        <enabled>true</enabled>
    </releases>
    <snapshots>
        <enabled>true</enabled>
    </snapshots>
</repository>

Dependency

<dependency>
  <groupId>eu.mikroskeem.nuvotifier</groupId>
  <artifactId>java</artifactId>
  <version>0.0.1-SNAPSHOT</version>
</dependency>

Releases

No releases published

Packages

No packages published

Languages