f3b2cbc498d1ab61a684589b0bb5a286cdc92ac0
[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 localportsend = 5011;
15                 int localportrecv = 6011;
16                 int portsend = 5000;
17                 int portrecv = 6000;
18                 //String address = "localhost";
19                 //String address = "192.168.2.191";     // RPi2
20                 //String skeletonAddress = "128.195.136.170";   // dc-9.calit2.uci.edu
21                 String skeletonAddress = "128.195.204.132";
22                 String callbackAddress = "128.195.204.132";     // dw-2.eecs.uci.edu (this machine)
23                 //String skeletonAddress = "192.168.2.108";     // RPi1
24                 //String callbackAddress = "192.168.2.191";     // RPi2
25                 int rev = 0;
26
27                 TestClassComplete_Stub tcstub = new TestClassComplete_Stub(localportsend, localportrecv, portsend, portrecv, 
28                         skeletonAddress, rev);
29                 System.out.println("==== CALLBACKS ====");
30                 CallBackInterface cbSingle = new CallBack(2354);
31                 tcstub.registerCallback(cbSingle);
32                 System.out.println("Registered callback!");
33                 CallBackInterface cbSingle1 = new CallBack(2356);
34                 tcstub.registerCallback(cbSingle1);
35                 System.out.println("Registered callback!");
36                 CallBackInterface cbSingle2 = new CallBack(2360);
37                 tcstub.registerCallback(cbSingle2);
38                 System.out.println("Registered callback!");
39
40                 System.out.println("Return value from callback 1: " + tcstub.callBack() + "\n\n");
41                 System.out.println("\n\nCalling short one more time value: " + tcstub.getShort((short)4576) + "\n\n");
42                 System.out.println("Return value from callback 2: " + tcstub.callBack() + "\n\n");
43                 System.out.println("\n\nCalling short one more time value: " + tcstub.getShort((short)1233) + "\n\n");
44                 System.out.println("\n\nCalling short one more time value: " + tcstub.getShort((short)1321) + "\n\n");
45                 while(true) {}
46         }
47 }