81b20dd25dab5eedbe22daedb801bedb7b5730c0
[iot2.git] / iotjava / iotrmi / Java / basics / TestClassCallbacks_Stub.java
1 import java.util.Arrays;
2 import java.util.List;
3 import java.util.ArrayList;
4 import iotruntime.master.CommunicationHandler;
5
6 public class TestClassCallbacks_Stub {
7
8         public static void main(String[] args) throws Exception {
9
10                 CommunicationHandler comHan = new CommunicationHandler(true);
11                 int numOfPorts = 2;
12                 int[] ports = comHan.getCallbackPorts(numOfPorts);
13
14                 int localport = 5011;
15                 int port = 5010;
16                 //String address = "localhost";
17                 //String address = "192.168.2.191";     // RPi2
18                 //String skeletonAddress = "128.195.136.170";   // dc-9.calit2.uci.edu
19                 String skeletonAddress = "128.195.204.132";
20                 String callbackAddress = "128.195.204.132";     // dw-2.eecs.uci.edu (this machine)
21                 //String skeletonAddress = "192.168.2.108";     // RPi1
22                 //String callbackAddress = "192.168.2.191";     // RPi2
23                 int rev = 0;
24
25                 TestClassComplete_Stub tcstub = new TestClassComplete_Stub(localport, port, skeletonAddress, callbackAddress, rev, ports);
26                 System.out.println("==== CALLBACKS ====");
27                 CallBackInterface cbSingle = new CallBack(2354);
28                 tcstub.registerCallback(cbSingle);
29                 System.out.println("Registered callback!");
30                 //CallBackInterface cbSingle1 = new CallBack(2356);
31                 //tcstub.registerCallback(cbSingle1);
32                 System.out.println("Registered callback!");
33
34                 System.out.println("Return value from callback 1: " + tcstub.callBack() + "\n\n");
35                 //System.out.println("\n\nCalling short one more time value: " + tcstub.getShort((short)4576) + "\n\n");
36                 System.out.println("Return value from callback 2: " + tcstub.callBack() + "\n\n");
37                 //System.out.println("\n\nCalling short one more time value: " + tcstub.getShort((short)1233) + "\n\n");
38                 //System.out.println("\n\nCalling short one more time value: " + tcstub.getShort((short)1321) + "\n\n");
39                 while(true) {}
40         }
41 }