Introduction Installing the Web Services

8-4 Developers Guide SimpleReference sr = new SimpleReference; sr.setCorrelator; sr.setInterfaceName; sr.setEndpoint; consumer.subscribePresence sip.presentitytest.example.com , pat, unused, sr;

8.5.2 Interface: PresenceConsumer, Operation: getUserPresence

Call this operation to retrieve a subscribed presentity presence. If the person is offline, it returns ActivityNone and the hardstate note is written to PresenceAttribute.note. If it returns Activity_Other, the description of the activity is returned in the OtherValue field. If the Name field is equal to ServiceAndDeviceNote, OtherValue is a combination of the service note and the device note. Note that there can be more than one ServiceAndDeviceNote when the presentity is logged into multiple clients.

8.5.2.1 Code Example

PresenceAttributeType pat = PresenceAttributeType.ACTIVITY; ListPresenceAttribute result = consumer.getUserPresencepresentity, pat; for PresenceAttribute pa : result { Check to see if it is an activity type. if pa.getTypeAndValue.getUnionElement == PresenceAttributeType.ACTIVITY{ Get the presence status. System.out.printlnACTIVITY: + pa.getTypeAndValue.getActivity.toString; Get the customized presence note. if pa.getNote.length 0{ System.out.printlnNote: + pa.getNote; } } If this is of type OTHER, then we need to extract different type of information. if pa.getTypeAndValue.getUnionElement == PresenceAttributeType.OTHER{ This is Activity_Other, a custom presence status. if pa.getTypeAndValue.getOther .getName.compareToIgnoreCaseACTIVITY_OTHER == 0{ System.out.printlnOther Activity- + pa.getTypeAndValue.getOther.getValue + \n; } else { Currently, the only other value beside ACTIVITY_OTHER is ServiceAndDeviceNote which is the service note + device note. System.out.printlnCombined Note- + pa.getTypeAndValue.getOther.getValue + \n; } } }

8.5.3 Interface: PresenceNotification, Operation: statusChanged

This asynchronous operation is called by the Web Service when an attribute for which notifications were requested changes. Parlay X Presence Web Services 8-5

8.5.3.1 Code Example

public void statusChangedString context, String correlator, String uri, ListPresenceAttribute presenceAttributes { System.out.printlnstatusChanged Called:-; System.out.printlnContext = + context; System.out.printlnCorrelator = + correlator; System.out.printlnPresentity = + uri; }

8.5.4 Interface: PresenceNotification, Operation: statusEnd

This method is called when the duration for the notifications identified by the correlator is over. In case of an error or explicit call to endPresenceNotification, this method is not called.

8.5.4.1 Code Example

public void statusEndString context, String correlator System.out.printlnstatusEnd Called:-; System.out.printlnContext = + context; System.out.printlnCorrelator = + correlator; }

8.5.5 Interface: PresenceNotification, Operation: notifySubscription

This asynchronous method notifies the watcher that the presentity handled the pending subscription.

8.5.5.1 Code Example

public void notifySubscriptionString context, String uri, ListPresencePermission presencePermissions { System.out.printlnnotifySubscription Called:-; System.out.printlnContext = + context; System.out.printlnUri = + uri; if presencePermissions.size 0{ for PresencePermission p:presencePermissions{ System.out.printlnPermission + p.getPresenceAttribute.value + - + p.isDecision; } } }

8.5.6 Interface: PresenceNotification, Operation: subscriptionEnded

This asynchronous operation is called by the Web Service to notify the watcher that the subscription has terminated.

8.5.6.1 Code Example

public void subscriptionEndedString context, String uri, String reason { System.out.printlnsubscriptionEnded Called:-; System.out.printlnContext = + context; System.out.printlnUri = + uri; System.out.printlnReason = + reason; }