1 package iotrmi.Java.sample;
3 import java.io.IOException;
5 import java.util.Arrays;
6 import iotrmi.Java.IoTRMIObject;
8 public class CallBack_Skeleton implements CallBackInterface {
10 private int objectId = 0; // Default value is 0
11 private CallBackInterface cb;
12 private IoTRMIObject rmiObj;
18 public CallBack_Skeleton(CallBackInterface _cb, int _port) throws
19 ClassNotFoundException, InstantiationException,
20 IllegalAccessException, IOException {
23 System.out.println("Creating CallBack_Skeleton and waiting!");
24 rmiObj = new IoTRMIObject(_port);
25 ___waitRequestInvokeMethod();
29 public int printInt() {
34 public void ___printInt() throws IOException {
35 Object retObj = printInt();
36 rmiObj.sendReturnObj(retObj);
40 public void setInt(int _i) {
45 public void ___setInt() {
46 Object[] paramObj = rmiObj.getMethodParams(new Class<?>[] { int.class },
47 new Class<?>[] { null }, new Class<?>[] { null });
48 setInt((int) paramObj[0]);
52 private void ___waitRequestInvokeMethod() throws IOException {
54 // Loop continuously waiting for incoming bytes
57 rmiObj.getMethodBytes();
58 int objId = rmiObj.getObjectId();
59 if (objId == objectId) {
60 // Multiplex based on object Id
61 rmiObj.getMethodBytes();
62 int methodId = rmiObj.getMethodId();
65 case 0: ___printInt(); break;
66 case 1: ___setInt(); break;
68 throw new Error("Method Id not recognized!");
75 public static void main(String[] args) throws Exception {
78 CallBack cb = new CallBack(23);
79 CallBack_Skeleton cbSkel = new CallBack_Skeleton(cb, port);
80 //cbSkel.waitRequestInvokeMethod();