Skip to content

Commit

Permalink
client version 1.3.7
Browse files Browse the repository at this point in the history
 - added call-response pattern for channel responders
 - fixed JavaDoc
 - new connection built-up and handling
  • Loading branch information
matsfunk committed Mar 30, 2018
1 parent a44dafa commit 8d13a16
Showing 100 changed files with 1,294 additions and 449 deletions.
Binary file modified dist/oocsi.zip
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import nl.tue.id.oocsi.*;
import nl.tue.id.oocsi.client.services.*;

// ******************************************************
// This example requires a running OOCSI server!
//
// How to do that? Check: Examples > Tools > LocalServer
//
// More information how to run an OOCSI server
// can be found here: https://iddi.github.io/oocsi/)
// ******************************************************

// variables for fill color and size of rectangle
int fillColor = 255;
int size = 3;

OOCSI oocsi1;

// second OOCSI instance for making calls to the registered handlers
OOCSI oocsi2;

void setup() {
size(200, 200);
noStroke();
rectMode(CENTER);

// connect to OOCSI server running on the same machine (localhost)
// with "receiverName" to be my channel others can send data to
// (for more information how to run an OOCSI server refer to: https://iddi.github.io/oocsi/)
oocsi1 = new OOCSI(this, "channel_responder", "localhost");

// register this first OOCSI client for responses
// to call "numberNumer"
oocsi1.registerChannel("colorChannel", "newNumber");
// and "newColor"
oocsi1.registerChannel("colorChannel", "newColor");

// register can take also the name of the function as an optional second parameter:
// oocsi1.register("newColor", "generateColor");

// ---------------------------------------------------------------------------------

// connect with a second OOCSI client for calling the first one
oocsi2 = new OOCSI(this, "caller", "localhost");
}

// responder for calls to "newNumber", will receive the call message and then put the response data into
// the response OOCSIData object, which is same as for OOCSI events and messages
void newNumber(OOCSIEvent event, OOCSIData response) {
response.data("number", frameCount % 20);
}

// responder for calls to "newColor", will receive the call message and then put the response data into
// the response OOCSIData object, which is same as for OOCSI events and messages
void newColor(OOCSIEvent event, OOCSIData response) {
int col = event.getInt("color", 0);
response.data("color", (fillColor + col) % 255);
}

void draw() {
background(0);

// draw a rect with the given size and fill color
fill(fillColor, 120, 120);
rect(width/2., height/2., 5 * size, 5 * size);
}

void mousePressed() {

// on mouse press call two different services and get new data...

// first one for getting a new size
// 1: create call
OOCSICall call1 = oocsi2.call("colorChannel", "newNumber", 200);
// 2: send out and wait until either there is a response or the timeout has passed
call1.sendAndWait();
// 3: check for response
if (call1.hasResponse()) {
// 4: get data out of the first response
size = call1.getFirstResponse().getInt("number", 0);
}

// second one for getting a new color
// 1: create call with parameter "color", similar to normal OOCSI events
OOCSICall call2 = oocsi2.call("colorChannel", "newColor", 200).data("color", frameCount);
// 2: send out and wait until either there is a response or the timeout has passed
call2.sendAndWait();
// 3: check for response
if (call2.hasResponse()) {
// 4: get data out of the first response
fillColor = call2.getFirstResponse().getInt("color", 0);
}
}
4 changes: 2 additions & 2 deletions dist/oocsi/library.properties
Original file line number Diff line number Diff line change
@@ -40,11 +40,11 @@ paragraph = This library provides easy ways to connect a Processing sketch to a
# compare different versions of the same library, and check if an update is
# available. You should think of it as a counter, counting the total number of
# releases you've had.
version = 136
version = 137

# The version as the user will see it. If blank, the version attribute will be
# used here. This should be a single word, with no spaces.
prettyVersion = 1.3.6
prettyVersion = 1.3.7

# The min and max revision of Processing compatible with your library.
# Note that these fields use the revision and not the version of Processing,
Binary file modified dist/oocsi/library/oocsi.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions dist/oocsi/reference/allclasses-frame.html
Original file line number Diff line number Diff line change
@@ -2,9 +2,9 @@
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (1.8.0_51) on Wed Dec 27 11:18:43 CET 2017 -->
<!-- Generated by javadoc (1.8.0_51) on Fri Mar 30 11:21:51 CEST 2018 -->
<title>All Classes</title>
<meta name="date" content="2017-12-27">
<meta name="date" content="2018-03-30">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<script type="text/javascript" src="script.js"></script>
</head>
4 changes: 2 additions & 2 deletions dist/oocsi/reference/allclasses-noframe.html
Original file line number Diff line number Diff line change
@@ -2,9 +2,9 @@
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (1.8.0_51) on Wed Dec 27 11:18:43 CET 2017 -->
<!-- Generated by javadoc (1.8.0_51) on Fri Mar 30 11:21:51 CEST 2018 -->
<title>All Classes</title>
<meta name="date" content="2017-12-27">
<meta name="date" content="2018-03-30">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<script type="text/javascript" src="script.js"></script>
</head>
6 changes: 3 additions & 3 deletions dist/oocsi/reference/constant-values.html
Original file line number Diff line number Diff line change
@@ -2,9 +2,9 @@
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (1.8.0_51) on Wed Dec 27 11:18:43 CET 2017 -->
<!-- Generated by javadoc (1.8.0_51) on Fri Mar 30 11:21:51 CEST 2018 -->
<title>Constant Field Values</title>
<meta name="date" content="2017-12-27">
<meta name="date" content="2018-03-30">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<script type="text/javascript" src="script.js"></script>
</head>
@@ -122,7 +122,7 @@ <h2 title="nl.tue">nl.tue.*</h2>
<!-- -->
</a><code>public&nbsp;static&nbsp;final&nbsp;java.lang.String</code></td>
<td><code><a href="nl/tue/id/oocsi/client/OOCSIClient.html#VERSION">VERSION</a></code></td>
<td class="colLast"><code>"1.3.6"</code></td>
<td class="colLast"><code>"1.3.7"</code></td>
</tr>
</tbody>
</table>
4 changes: 2 additions & 2 deletions dist/oocsi/reference/deprecated-list.html
Original file line number Diff line number Diff line change
@@ -2,9 +2,9 @@
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (1.8.0_51) on Wed Dec 27 11:18:43 CET 2017 -->
<!-- Generated by javadoc (1.8.0_51) on Fri Mar 30 11:21:51 CEST 2018 -->
<title>Deprecated List</title>
<meta name="date" content="2017-12-27">
<meta name="date" content="2018-03-30">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<script type="text/javascript" src="script.js"></script>
</head>
4 changes: 2 additions & 2 deletions dist/oocsi/reference/help-doc.html
Original file line number Diff line number Diff line change
@@ -2,9 +2,9 @@
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (1.8.0_51) on Wed Dec 27 11:18:43 CET 2017 -->
<!-- Generated by javadoc (1.8.0_51) on Fri Mar 30 11:21:51 CEST 2018 -->
<title>API Help</title>
<meta name="date" content="2017-12-27">
<meta name="date" content="2018-03-30">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<script type="text/javascript" src="script.js"></script>
</head>
Loading

0 comments on commit 8d13a16

Please sign in to comment.