2 * //******************************************************************
\r
4 * // Copyright 2015 Intel Corporation.
\r
6 * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
\r
8 * // Licensed under the Apache License, Version 2.0 (the "License");
\r
9 * // you may not use this file except in compliance with the License.
\r
10 * // You may obtain a copy of the License at
\r
12 * // http://www.apache.org/licenses/LICENSE-2.0
\r
14 * // Unless required by applicable law or agreed to in writing, software
\r
15 * // distributed under the License is distributed on an "AS IS" BASIS,
\r
16 * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
17 * // See the License for the specific language governing permissions and
\r
18 * // limitations under the License.
\r
20 * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
\r
23 package org.iotivity.base;
\r
25 import org.iotivity.ca.CaInterface;
\r
27 import java.util.EnumSet;
\r
28 import java.util.Iterator;
\r
29 import java.util.List;
\r
32 * Contains the main entrance/functionality of the product. To set a custom configuration, the
\r
33 * implementer must make a call to OcPlatform.Configure before the first usage of a function in this
\r
36 public final class OcPlatform {
\r
39 System.loadLibrary("oc_logger");
\r
40 System.loadLibrary("octbstack");
\r
41 System.loadLibrary("connectivity_abstraction");
\r
42 System.loadLibrary("oc");
\r
43 System.loadLibrary("ocstack-jni");
\r
49 public static final String DEFAULT_INTERFACE = "oic.if.baseline";
\r
52 * Used in discovering (GET) links to other resources of a collection
\r
54 public static final String LINK_INTERFACE = "oic.if.ll";
\r
57 * Used in GET, PUT, POST, DELETE methods on links to other resources of a collection
\r
59 public static final String BATCH_INTERFACE = "oic.if.b";
\r
62 * Used in GET, PUT, POST methods on links to other remote resources of a group
\r
64 public static final String GROUP_INTERFACE = "oic.mi.grp";
\r
66 public static final String WELL_KNOWN_QUERY = "224.0.1.187:5683/oic/res";
\r
67 public static final String MULTICAST_PREFIX = "224.0.1.187:5683";
\r
68 public static final String MULTICAST_IP = "224.0.1.187";
\r
69 public static final int MULTICAST_PORT = 5683;
\r
70 public static final int DEFAULT_PRESENCE_TTL = 60;
\r
71 public static final String DEVICE_URI = "/oic/d";
\r
72 public static final String PRESENCE_URI = "/oic/ad";
\r
74 private static volatile boolean sIsPlatformInitialized = false;
\r
76 private OcPlatform() {
\r
80 * API for setting the configuration of the OcPlatform.
\r
81 * Note: Any calls made to this AFTER the first call to OcPlatform.Configure will have no affect
\r
83 * @param platformConfig platform configuration
\r
85 public synchronized static void Configure(PlatformConfig platformConfig) {
\r
86 if (!sIsPlatformInitialized) {
\r
87 CaInterface.initialize(platformConfig.getContext());
\r
89 OcPlatform.configure(
\r
90 platformConfig.getServiceType().getValue(),
\r
91 platformConfig.getModeType().getValue(),
\r
92 platformConfig.getIpAddress(),
\r
93 platformConfig.getPort(),
\r
94 platformConfig.getQualityOfService().getValue(),
95 platformConfig.getSvrDbPath()
98 sIsPlatformInitialized = true;
\r
102 private static native void configure(int serviceType,
\r
106 int qualityOfService,
110 * API for notifying base that resource's attributes have changed.
\r
112 * @param ocResourceHandle resource handle of the resource
\r
113 * @throws OcException
\r
115 public static void notifyAllObservers(
\r
116 OcResourceHandle ocResourceHandle) throws OcException {
\r
117 OcPlatform.initCheck();
\r
118 OcPlatform.notifyAllObservers0(ocResourceHandle);
\r
121 private static native void notifyAllObservers0(
\r
122 OcResourceHandle ocResourceHandle) throws OcException;
\r
125 * API for notifying base that resource's attributes have changed.
\r
127 * @param ocResourceHandle resource handle of the resource
\r
128 * @param qualityOfService the quality of communication
\r
129 * @throws OcException
\r
131 public static void notifyAllObservers(
\r
132 OcResourceHandle ocResourceHandle,
\r
133 QualityOfService qualityOfService) throws OcException {
\r
134 OcPlatform.initCheck();
\r
135 OcPlatform.notifyAllObservers1(ocResourceHandle, qualityOfService.getValue());
\r
138 private static native void notifyAllObservers1(
\r
139 OcResourceHandle ocResourceHandle,
\r
140 int qualityOfService) throws OcException;
\r
143 * API for notifying only specific clients that resource's attributes have changed.
\r
145 * @param ocResourceHandle resource handle of the resource
\r
146 * @param ocObservationIdList These set of ids are ones which which will be notified upon
\r
148 * @param ocResourceResponse OcResourceResponse object used by app to fill the response for
\r
149 * this resource change
\r
150 * @throws OcException
\r
152 public static void notifyListOfObservers(
\r
153 OcResourceHandle ocResourceHandle,
\r
154 List<Byte> ocObservationIdList,
\r
155 OcResourceResponse ocResourceResponse) throws OcException {
\r
156 OcPlatform.initCheck();
\r
158 byte[] idArr = new byte[ocObservationIdList.size()];
\r
159 Iterator<Byte> it = ocObservationIdList.iterator();
\r
161 while (it.hasNext()) {
\r
162 idArr[i++] = (byte) it.next();
\r
165 OcPlatform.notifyListOfObservers2(
\r
168 ocResourceResponse);
\r
171 private static native void notifyListOfObservers2(
\r
172 OcResourceHandle ocResourceHandle,
\r
173 byte[] ocObservationIdArray,
\r
174 OcResourceResponse ocResourceResponse) throws OcException;
\r
177 * API for notifying only specific clients that resource's attributes have changed.
\r
179 * @param ocResourceHandle resource handle of the resource
\r
180 * @param ocObservationIdList These set of ids are ones which which will be notified upon
\r
182 * @param ocResourceResponse OcResourceResponse object used by app to fill the response for
\r
183 * this resource change
\r
184 * @param qualityOfService the quality of communication
\r
185 * @throws OcException
\r
187 public static void notifyListOfObservers(
\r
188 OcResourceHandle ocResourceHandle,
\r
189 List<Byte> ocObservationIdList,
\r
190 OcResourceResponse ocResourceResponse,
\r
191 QualityOfService qualityOfService) throws OcException {
\r
192 OcPlatform.initCheck();
\r
194 byte[] idArr = new byte[ocObservationIdList.size()];
\r
195 Iterator<Byte> it = ocObservationIdList.iterator();
\r
197 while (it.hasNext()) {
\r
198 idArr[i++] = (byte) it.next();
\r
201 OcPlatform.notifyListOfObservers3(
\r
204 ocResourceResponse,
\r
205 qualityOfService.getValue()
\r
209 private static native void notifyListOfObservers3(
\r
210 OcResourceHandle ocResourceHandle,
\r
211 byte[] ocObservationIdArray,
\r
212 OcResourceResponse ocResourceResponse,
\r
213 int qualityOfService) throws OcException;
\r
216 * API for Service and Resource Discovery. NOTE: This API applies to client side only
\r
218 * @param host Host IP Address of a service to direct resource discovery query.
\r
219 * If empty, performs multicast resource discovery query
\r
220 * @param resourceUri name of the resource. If null or empty, performs search for all
\r
222 * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
\r
224 * @param onResourceFoundListener Handles events, success states and failure states.
\r
225 * @throws OcException
\r
227 public static void findResource(
\r
229 String resourceUri,
\r
230 OcConnectivityType connectivityType,
\r
231 OnResourceFoundListener onResourceFoundListener) throws OcException {
\r
232 OcPlatform.initCheck();
\r
233 OcPlatform.findResource0(
\r
236 connectivityType.getValue(),
\r
237 onResourceFoundListener
\r
241 private static native void findResource0(
\r
243 String resourceUri,
\r
244 int connectivityType,
\r
245 OnResourceFoundListener onResourceFoundListener) throws OcException;
\r
248 * API for Service and Resource Discovery. NOTE: This API applies to client side only
\r
250 * @param host Host IP Address of a service to direct resource discovery query.
\r
251 * If empty, performs multicast resource discovery query
\r
252 * @param resourceUri name of the resource. If null or empty, performs search for all
\r
254 * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
\r
256 * @param onResourceFoundListener Handles events, success states and failure states.
\r
257 * @param qualityOfService the quality of communication
\r
258 * @throws OcException
\r
260 public static void findResource(
\r
262 String resourceUri,
\r
263 OcConnectivityType connectivityType,
\r
264 OnResourceFoundListener onResourceFoundListener,
\r
265 QualityOfService qualityOfService) throws OcException {
\r
266 OcPlatform.initCheck();
\r
267 OcPlatform.findResource1(host,
\r
269 connectivityType.getValue(),
\r
270 onResourceFoundListener,
\r
271 qualityOfService.getValue()
\r
275 private static native void findResource1(
\r
277 String resourceUri,
\r
278 int connectivityType,
\r
279 OnResourceFoundListener onResourceFoundListener,
\r
280 int qualityOfService) throws OcException;
\r
283 * API for Device Discovery
\r
285 * @param host Host IP Address. If null or empty, Multicast is performed.
\r
286 * @param deviceUri Uri containing address to the virtual device
\r
287 * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
\r
289 * @param onDeviceFoundListener Handles events, success states and failure states.
\r
290 * @throws OcException
\r
292 public static void getDeviceInfo(
\r
295 OcConnectivityType connectivityType,
\r
296 OnDeviceFoundListener onDeviceFoundListener) throws OcException {
\r
297 OcPlatform.initCheck();
\r
298 OcPlatform.getDeviceInfo0(
\r
301 connectivityType.getValue(),
\r
302 onDeviceFoundListener
\r
306 private static native void getDeviceInfo0(
\r
309 int connectivityType,
\r
310 OnDeviceFoundListener onDeviceFoundListener) throws OcException;
\r
313 * API for Device Discovery
\r
315 * @param host Host IP Address. If null or empty, Multicast is performed.
\r
316 * @param deviceUri Uri containing address to the virtual device
\r
317 * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
\r
319 * @param onDeviceFoundListener Handles events, success states and failure states.
\r
320 * @param qualityOfService the quality of communication
\r
321 * @throws OcException
\r
323 public static void getDeviceInfo(
\r
326 OcConnectivityType connectivityType,
\r
327 OnDeviceFoundListener onDeviceFoundListener,
\r
328 QualityOfService qualityOfService) throws OcException {
\r
329 OcPlatform.initCheck();
\r
330 OcPlatform.getDeviceInfo1(
\r
333 connectivityType.getValue(),
\r
334 onDeviceFoundListener,
\r
335 qualityOfService.getValue()
\r
339 private static native void getDeviceInfo1(
\r
342 int connectivityType,
\r
343 OnDeviceFoundListener onDeviceFoundListener,
\r
344 int qualityOfService) throws OcException;
\r
347 * This API registers a resource with the server NOTE: This API applies to server side only.
\r
349 * @param ocResource The instance of OcResource with all data filled
\r
350 * @return resource handle
\r
351 * @throws OcException
\r
353 public static OcResourceHandle registerResource(
\r
354 OcResource ocResource) throws OcException {
\r
355 OcPlatform.initCheck();
\r
356 return OcPlatform.registerResource0(ocResource);
\r
359 private static native OcResourceHandle registerResource0(
\r
360 OcResource ocResource) throws OcException;
\r
363 * This API registers a resource with the server NOTE: This API applies to server side only.
\r
365 * @param resourceUri The URI of the resource. Example: "a/light"
\r
366 * @param resourceTypeName The resource type. Example: "light"
\r
367 * @param resourceInterface The resource interface (whether it is collection etc).
\r
368 * @param entityHandler entity handler.
\r
369 * @param resourcePropertySet indicates the property of the resource
\r
370 * @return resource handle
\r
371 * @throws OcException
\r
373 public static OcResourceHandle registerResource(
\r
374 String resourceUri,
\r
375 String resourceTypeName,
\r
376 String resourceInterface,
\r
377 EntityHandler entityHandler,
\r
378 EnumSet<ResourceProperty> resourcePropertySet) throws OcException {
\r
379 OcPlatform.initCheck();
\r
381 int resProperty = 0;
\r
383 for (ResourceProperty prop : ResourceProperty.values()) {
\r
384 if (resourcePropertySet.contains(prop))
\r
385 resProperty |= prop.getValue();
\r
388 return OcPlatform.registerResource1(resourceUri,
\r
395 private static native OcResourceHandle registerResource1(
\r
396 String resourceUri,
\r
397 String resourceTypeName,
\r
398 String resourceInterface,
\r
399 EntityHandler entityHandler,
\r
400 int resourceProperty) throws OcException;
\r
403 * Register Device Info
\r
405 * @param ocDeviceInfo object containing all the device specific information
\r
406 * @throws OcException
\r
408 public static void registerDeviceInfo(
\r
409 OcDeviceInfo ocDeviceInfo) throws OcException {
\r
410 OcPlatform.initCheck();
\r
411 OcPlatform.registerDeviceInfo0(
\r
412 ocDeviceInfo.getDeviceName()
\r
416 private static native void registerDeviceInfo0(
\r
418 ) throws OcException;
\r
421 * This API unregisters a resource with the server NOTE: This API applies to server side only.
\r
423 * @param ocResourceHandle This is the resource handle which we which to unregister from the
\r
425 * @throws OcException
\r
427 public static void unregisterResource(
\r
428 OcResourceHandle ocResourceHandle) throws OcException {
\r
429 OcPlatform.initCheck();
\r
430 OcPlatform.unregisterResource0(ocResourceHandle);
\r
433 private static native void unregisterResource0(
\r
434 OcResourceHandle ocResourceHandle) throws OcException;
\r
438 * Add a resource to a collection resource
\r
440 * @param ocResourceCollectionHandle handle to the collection resource
\r
441 * @param ocResourceHandle handle to resource to be added to the collection resource
\r
442 * @throws OcException
\r
444 public static void bindResource(
\r
445 OcResourceHandle ocResourceCollectionHandle,
\r
446 OcResourceHandle ocResourceHandle) throws OcException {
\r
447 OcPlatform.initCheck();
\r
448 OcPlatform.bindResource0(ocResourceCollectionHandle, ocResourceHandle);
\r
451 private static native void bindResource0(
\r
452 OcResourceHandle ocResourceCollectionHandle,
\r
453 OcResourceHandle ocResourceHandle) throws OcException;
\r
456 * Add multiple resources to a collection resource.
\r
458 * @param ocResourceCollectionHandle handle to the collection resource
\r
459 * @param ocResourceHandleList reference to list of resource handles to be added to the
\r
460 * collection resource
\r
461 * @throws OcException
\r
463 public static void bindResources(
\r
464 OcResourceHandle ocResourceCollectionHandle,
\r
465 List<OcResourceHandle> ocResourceHandleList) throws OcException {
\r
466 OcPlatform.initCheck();
\r
467 OcPlatform.bindResources0(
\r
468 ocResourceCollectionHandle,
\r
469 ocResourceHandleList.toArray(
\r
470 new OcResourceHandle[ocResourceHandleList.size()])
\r
474 private static native void bindResources0(
\r
475 OcResourceHandle ocResourceCollectionHandle,
\r
476 OcResourceHandle[] ocResourceHandleArray) throws OcException;
\r
479 * Unbind a resource from a collection resource.
\r
481 * @param ocResourceCollectionHandle handle to the collection resource
\r
482 * @param ocResourceHandle resource handle to be unbound from the collection resource
\r
483 * @throws OcException
\r
485 public static void unbindResource(
\r
486 OcResourceHandle ocResourceCollectionHandle,
\r
487 OcResourceHandle ocResourceHandle) throws OcException {
\r
488 OcPlatform.initCheck();
\r
489 OcPlatform.unbindResource0(ocResourceCollectionHandle, ocResourceHandle);
\r
492 private static native void unbindResource0(
\r
493 OcResourceHandle ocResourceCollectionHandle,
\r
494 OcResourceHandle ocResourceHandle) throws OcException;
\r
497 * Unbind resources from a collection resource.
\r
499 * @param ocResourceCollectionHandle Handle to the collection resource
\r
500 * @param ocResourceHandleList List of resource handles to be unbound from the collection
\r
502 * @throws OcException
\r
504 public static void unbindResources(
\r
505 OcResourceHandle ocResourceCollectionHandle,
\r
506 List<OcResourceHandle> ocResourceHandleList) throws OcException {
\r
507 OcPlatform.initCheck();
\r
508 OcPlatform.unbindResources0(
\r
509 ocResourceCollectionHandle,
\r
510 ocResourceHandleList.toArray(
\r
511 new OcResourceHandle[ocResourceHandleList.size()])
\r
515 private static native void unbindResources0(
\r
516 OcResourceHandle ocResourceCollectionHandle,
\r
517 OcResourceHandle[] ocResourceHandleArray) throws OcException;
\r
520 * Binds a type to a particular resource
\r
522 * @param ocResourceHandle handle to the resource
\r
523 * @param resourceTypeName new typename to bind to the resource
\r
524 * @throws OcException
\r
526 public static void bindTypeToResource(
\r
527 OcResourceHandle ocResourceHandle,
\r
528 String resourceTypeName) throws OcException {
\r
529 OcPlatform.initCheck();
\r
530 OcPlatform.bindTypeToResource0(ocResourceHandle, resourceTypeName);
\r
533 private static native void bindTypeToResource0(
\r
534 OcResourceHandle ocResourceHandle,
\r
535 String resourceTypeName) throws OcException;
\r
538 * Binds an interface to a particular resource
\r
540 * @param ocResourceHandle handle to the resource
\r
541 * @param resourceInterfaceName new interface to bind to the resource
\r
542 * @throws OcException
\r
544 public static void bindInterfaceToResource(
\r
545 OcResourceHandle ocResourceHandle,
\r
546 String resourceInterfaceName) throws OcException {
\r
547 OcPlatform.initCheck();
\r
548 OcPlatform.bindInterfaceToResource0(ocResourceHandle, resourceInterfaceName);
\r
551 private static native void bindInterfaceToResource0(
\r
552 OcResourceHandle ocResourceHandle,
\r
553 String resourceInterfaceName) throws OcException;
\r
556 * Start Presence announcements.
\r
558 * @param ttl time to live in seconds
\r
559 * @throws OcException
\r
561 public static void startPresence(int ttl) throws OcException {
\r
562 OcPlatform.initCheck();
\r
563 OcPlatform.startPresence0(ttl);
\r
566 private static native void startPresence0(int ttl) throws OcException;
\r
569 * Stop Presence announcements.
\r
571 * @throws OcException
\r
573 public static void stopPresence() throws OcException {
\r
574 OcPlatform.initCheck();
\r
575 OcPlatform.stopPresence0();
\r
578 private static native void stopPresence0() throws OcException;
\r
581 * Subscribes to a server's presence change events. By making this subscription, every time a
\r
582 * server adds/removes/alters a resource, starts or is intentionally stopped
\r
584 * @param host The IP address/addressable name of the server to subscribe to
\r
585 * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
\r
587 * @param onPresenceListener listener that will receive notifications/subscription events
\r
588 * @return a handle object that can be used to identify this subscription request. It can be
\r
589 * used to unsubscribe from these events in the future
\r
590 * @throws OcException
\r
592 public static OcPresenceHandle subscribePresence(
\r
594 OcConnectivityType connectivityType,
\r
595 OnPresenceListener onPresenceListener) throws OcException {
\r
596 OcPlatform.initCheck();
\r
597 return OcPlatform.subscribePresence0(
\r
599 connectivityType.getValue(),
\r
604 private static native OcPresenceHandle subscribePresence0(
\r
606 int connectivityType,
\r
607 OnPresenceListener onPresenceListener) throws OcException;
\r
610 * Subscribes to a server's presence change events. By making this subscription, every time a
\r
611 * server adds/removes/alters a resource, starts or is intentionally stopped
\r
613 * @param host The IP address/addressable name of the server to subscribe to
\r
614 * @param resourceType a resource type specified as a filter for subscription events.
\r
615 * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
\r
617 * @param onPresenceListener listener that will receive notifications/subscription events
\r
618 * @return a handle object that can be used to identify this subscription request. It can be
\r
619 * used to unsubscribe from these events in the future
\r
620 * @throws OcException
\r
622 public static OcPresenceHandle subscribePresence(
\r
624 String resourceType,
\r
625 OcConnectivityType connectivityType,
\r
626 OnPresenceListener onPresenceListener) throws OcException {
\r
627 OcPlatform.initCheck();
\r
628 return OcPlatform.subscribePresence1(
\r
631 connectivityType.getValue(),
\r
632 onPresenceListener);
\r
635 private static native OcPresenceHandle subscribePresence1(
\r
637 String resourceType,
\r
638 int connectivityType,
\r
639 OnPresenceListener onPresenceListener) throws OcException;
\r
642 * Unsubscribes from a previously subscribed server's presence events. Note that you may for
\r
643 * a short time still receive events from the server since it may take time for the
\r
644 * unsubscribe to take effect.
\r
646 * @param ocPresenceHandle the handle object provided by the subscribePresence call that
\r
647 * identifies this subscription
\r
648 * @throws OcException
\r
650 public static void unsubscribePresence(
\r
651 OcPresenceHandle ocPresenceHandle) throws OcException {
\r
652 OcPlatform.initCheck();
\r
653 OcPlatform.unsubscribePresence0(ocPresenceHandle);
\r
656 private static native void unsubscribePresence0(
\r
657 OcPresenceHandle ocPresenceHandle) throws OcException;
\r
660 * Creates a resource proxy object so that get/put/observe functionality can be used without
\r
661 * discovering the object in advance. Note that the consumer of this method needs to provide
\r
662 * all of the details required to correctly contact and observe the object. If the consumer
\r
663 * lacks any of this information, they should discover the resource object normally.
\r
664 * Additionally, you can only create this object if OcPlatform was initialized to be a Client
\r
665 * or Client/Server.
\r
667 * @param host a string containing a resolvable host address of the server holding
\r
669 * @param uri the rest of the resource's URI that will permit messages to be
\r
671 * Example: /a/light
\r
672 * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
\r
674 * @param isObservable a boolean containing whether the resource supports observation
\r
675 * @param resourceTypeList a collection of resource types implemented by the resource
\r
676 * @param interfaceList a collection of interfaces that the resource supports/implements
\r
677 * @return new resource object
\r
678 * @throws OcException
\r
680 public static OcResource constructResourceObject(
\r
683 OcConnectivityType connectivityType,
\r
684 boolean isObservable,
\r
685 List<String> resourceTypeList,
\r
686 List<String> interfaceList) throws OcException {
\r
687 OcPlatform.initCheck();
\r
688 return OcPlatform.constructResourceObject0(
\r
691 connectivityType.getValue(),
\r
693 resourceTypeList.toArray(new String[resourceTypeList.size()]),
\r
694 interfaceList.toArray(new String[interfaceList.size()])
\r
698 private static native OcResource constructResourceObject0(
\r
701 int connectivityType,
\r
702 boolean isObservable,
\r
703 String[] resourceTypes,
\r
704 String[] interfaces) throws OcException;
\r
707 * Allows application entity handler to send response to an incoming request.
\r
709 * @param ocResourceResponse resource response
\r
710 * @throws OcException
\r
712 public static void sendResponse(OcResourceResponse ocResourceResponse)
\r
713 throws OcException {
\r
714 OcPlatform.initCheck();
\r
715 OcPlatform.sendResponse0(ocResourceResponse);
\r
718 private static native void sendResponse0(OcResourceResponse ocResourceResponse)
\r
719 throws OcException;
\r
722 * An OnResourceFoundListener can be registered via the OcPlatform.findResource call.
\r
723 * Event listeners are notified asynchronously
\r
725 public interface OnResourceFoundListener {
\r
726 public void onResourceFound(OcResource resource);
\r
730 * An OnDeviceFoundListener can be registered via the OcPlatform.getDeviceInfo call.
\r
731 * Event listeners are notified asynchronously
\r
733 public interface OnDeviceFoundListener {
\r
734 public void onDeviceFound(OcRepresentation ocRepresentation);
\r
738 * An OnPresenceListener can be registered via the OcPlatform.subscribePresence call.
\r
739 * Event listeners are notified asynchronously
\r
741 public interface OnPresenceListener {
\r
742 public void onPresence(OcPresenceStatus ocPresenceStatus, int nonce, String hostAddress);
\r
746 * An EntityHandler can be registered via the OcPlatform.registerResource call.
\r
747 * Event listeners are notified asynchronously
\r
749 public interface EntityHandler {
\r
750 public EntityHandlerResult handleEntity(OcResourceRequest ocResourceRequest);
\r
753 private static void initCheck() {
\r
754 if (!sIsPlatformInitialized) {
\r
755 throw new IllegalStateException("OcPlatform must be configured by making a call to " +
\r
756 "OcPlatform.Configure before any other API calls are permitted");
\r