35 public abstract void connect(String server,
int port, String username, String password);
121 public abstract void publish(String topic, String message);
123 private static final class CppProxy
extends MqttSession
125 private final long nativeRef;
126 private final AtomicBoolean destroyed =
new AtomicBoolean(
false);
128 private CppProxy(
long nativeRef)
130 if (nativeRef == 0)
throw new RuntimeException(
"nativeRef is zero");
131 this.nativeRef = nativeRef;
134 private native
void nativeDestroy(
long nativeRef);
135 public void _djinni_private_destroy()
137 boolean destroyed = this.destroyed.getAndSet(
true);
138 if (!destroyed) nativeDestroy(this.nativeRef);
140 protected void finalize() throws
java.lang.Throwable
142 _djinni_private_destroy();
149 public void connect(String server,
int port, String username, String password)
151 assert !this.destroyed.get() :
"trying to use a destroyed object";
152 native_connect(this.nativeRef, server, port, username, password);
154 private native
void native_connect(
long _nativeRef, String server,
int port, String username, String password);
157 public void setSubTopic(String subTopic)
159 assert !this.destroyed.get() :
"trying to use a destroyed object";
160 native_setSubTopic(this.nativeRef, subTopic);
162 private native
void native_setSubTopic(
long _nativeRef, String subTopic);
167 assert !this.destroyed.get() :
"trying to use a destroyed object";
168 native_addListener(this.nativeRef, listener);
170 private native
void native_addListener(
long _nativeRef, MqttSessionListener listener);
173 public void removeListener(MqttSessionListener listener)
175 assert !this.destroyed.get() :
"trying to use a destroyed object";
176 native_removeListener(this.nativeRef, listener);
178 private native
void native_removeListener(
long _nativeRef, MqttSessionListener listener);
181 public void disconnect()
183 assert !this.destroyed.get() :
"trying to use a destroyed object";
184 native_disconnect(this.nativeRef);
186 private native
void native_disconnect(
long _nativeRef);
189 public void publish(String topic, String message)
191 assert !this.destroyed.get() :
"trying to use a destroyed object";
192 native_publish(this.nativeRef, topic, message);
194 private native
void native_publish(
long _nativeRef, String topic, String message);