1 package SpeakerController;
3 import java.io.IOException;
5 import java.util.ArrayList;
6 import java.util.Arrays;
8 import java.util.HashMap;
9 import java.util.concurrent.atomic.AtomicBoolean;
10 import iotrmi.Java.IoTRMIComm;
11 import iotrmi.Java.IoTRMICommClient;
12 import iotrmi.Java.IoTRMICommServer;
13 import iotrmi.Java.IoTRMIUtil;
15 import iotcode.interfaces.*;
17 public class GPSGatewaySmart_Stub implements GPSGatewaySmart {
19 private int objectId = 3;
20 private IoTRMIComm rmiComm;
21 // Synchronization variables
22 private AtomicBoolean retValueReceived3 = new AtomicBoolean(false);
23 private AtomicBoolean retValueReceived4 = new AtomicBoolean(false);
26 public GPSGatewaySmart_Stub(int _localPortSend, int _localPortRecv, int _portSend, int _portRecv, String _skeletonAddress, int _rev) throws Exception {
27 if (_localPortSend != 0 && _localPortRecv != 0) {
28 rmiComm = new IoTRMICommClient(_localPortSend, _localPortRecv, _portSend, _portRecv, _skeletonAddress, _rev);
31 rmiComm = new IoTRMICommClient(_portSend, _portRecv, _skeletonAddress, _rev);
33 rmiComm.registerStub(objectId, 3, retValueReceived3);
34 rmiComm.registerStub(objectId, 4, retValueReceived4);
35 IoTRMIUtil.mapStub.put(objectId, this);
38 public GPSGatewaySmart_Stub(IoTRMIComm _rmiComm, int _objectId) throws Exception {
41 rmiComm.registerStub(objectId, 3, retValueReceived3);
42 rmiComm.registerStub(objectId, 4, retValueReceived4);
45 public void setNewRoomIDAvailable(boolean bValue) {
47 Class<?> retType = void.class;
48 Class<?>[] paramCls = new Class<?>[] { boolean.class };
49 Object[] paramObj = new Object[] { bValue };
50 rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
53 public void setNewRingStatusAvailable(boolean bValue) {
55 Class<?> retType = void.class;
56 Class<?>[] paramCls = new Class<?>[] { boolean.class };
57 Object[] paramObj = new Object[] { bValue };
58 rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
63 Class<?> retType = void.class;
64 Class<?>[] paramCls = new Class<?>[] { };
65 Object[] paramObj = new Object[] { };
66 rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
71 Class<?> retType = void.class;
72 Class<?>[] paramCls = new Class<?>[] { };
73 Object[] paramObj = new Object[] { };
74 rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
79 Class<?> retType = void.class;
80 Class<?>[] paramCls = new Class<?>[] { };
81 Object[] paramObj = new Object[] { };
82 rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
85 public int getRoomID() {
87 Class<?> retType = int.class;
88 Class<?>[] paramCls = new Class<?>[] { };
89 Object[] paramObj = new Object[] { };
90 rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
91 // Waiting for return value
92 while (!retValueReceived3.get());
93 Object retObj = rmiComm.getReturnValue(retType, null);
94 retValueReceived3.set(false);
95 rmiComm.setGetReturnBytes();
100 public void registerCallback(GPSGatewayCallback _callbackTo) {
101 int[] objIdSent0 = new int[1];
103 if (!IoTRMIUtil.mapSkel.containsKey(_callbackTo)) {
104 int newObjIdSent = rmiComm.getObjectIdCounter();
105 objIdSent0[0] = newObjIdSent;
106 rmiComm.decrementObjectIdCounter();
107 GPSGatewayCallback_Skeleton skel0 = new GPSGatewayCallback_Skeleton(_callbackTo, rmiComm, newObjIdSent);
108 IoTRMIUtil.mapSkel.put(_callbackTo, skel0);
109 IoTRMIUtil.mapSkelId.put(_callbackTo, newObjIdSent);
110 Thread thread = new Thread() {
113 skel0.___waitRequestInvokeMethod();
114 } catch (Exception ex) {
115 ex.printStackTrace();
116 throw new Error("Exception when trying to run ___waitRequestInvokeMethod() for GPSGatewayCallback_Skeleton!");
121 while(!skel0.didAlreadyInitWaitInvoke());
125 int newObjIdSent = IoTRMIUtil.mapSkelId.get(_callbackTo);
126 objIdSent0[0] = newObjIdSent;
128 } catch (Exception ex) {
129 ex.printStackTrace();
130 throw new Error("Exception when generating skeleton objects!");
134 Class<?> retType = void.class;
135 Class<?>[] paramCls = new Class<?>[] { int[].class };
136 Object[] paramObj = new Object[] { objIdSent0 };
137 rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
140 public boolean getRingStatus() {
142 Class<?> retType = boolean.class;
143 Class<?>[] paramCls = new Class<?>[] { };
144 Object[] paramObj = new Object[] { };
145 rmiComm.remoteCall(objectId, methodId, paramCls, paramObj);
146 // Waiting for return value
147 while (!retValueReceived4.get());
148 Object retObj = rmiComm.getReturnValue(retType, null);
149 retValueReceived4.set(false);
150 rmiComm.setGetReturnBytes();
152 return (boolean)retObj;