Subscriptions [message #1393947] |
Fri, 04 July 2014 10:27  |
Eclipse User |
|
|
|
How can the Network Application subscribe to GA resources ? Is this supported in the current implementation ? Can you please share code level details.
Also, what is the use of SubscriptionController in the Router and what functionality does it provide ?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: Subscriptions [message #1737311 is a reply to message #1737219] |
Thu, 07 July 2016 04:45   |
Eclipse User |
|
|
|
Hello mahdi,
I am doing the same thing as Trung, and i already write some lines of code. I pasted it below, i juste don't know how to give the notificationURI to this function? Could you help me and Trung for this?
Code in my RequestSender:
private RequestSender(){}
public static ResponsePrimitive createResource(String targetId, String name, Resource resource, int resourceType){
RequestPrimitive request = new RequestPrimitive();
request.setFrom(Constants.ADMIN_REQUESTING_ENTITY);
request.setTargetId(targetId);
request.setResourceType(BigInteger.valueOf(resourceType));
request.setRequestContentType(MimeMediaType.OBJ);
request.setReturnContentType(MimeMediaType.OBJ);
request.setContent(resource);
request.setName(name);
request.setOperation(Operation.CREATE);
return CSE.doRequest(request);
}
///////////////////request for subscription////////////////////
public static ResponsePrimitive createSubscription(String targetId, String name, Subscription resource){
return createResource(targetId, name, resource, ResourceType.SUBSCRIPTION);
}
//////////////////////////////////////////////////////////////
relative Code in my monitor():
public void createSensorResources(){
String targetId, content;
targetId = "/" + CSE_ID + "/" + CSE_NAME;
AE ae = new AE();
ae.setRequestReachability(true);
ae.setAppID(ipeId);
ae.getPointOfAccess().add(ipeId);
ResponsePrimitive response = RequestSender.createAE(ae, sensorId);
if(response.getResponseStatusCode().equals(ResponseStatusCode.CREATED)){
// Create the subscription for the monitor in IN
targetId = "/" + CSE_ID + "/" + CSE_NAME + "/" + sensorId + "/" + DATA;
ContentInstance sub = new ContentInstance();
sub.setContent(content);
sub.setContentInfo(MimeMediaType.OBIX);
RequestSender.createSubscription(targetId,); (here i don't know how to give the "nu"!!!!)
///////////////////////////////////////
Recording to my understand, create a subscription is just like to create a contentinstance in DATA container? but where should i give my value of "nu" to this function?
Thanks in advance.
Can
[Updated on: Thu, 07 July 2016 04:50] by Moderator
|
|
|
|
|
|
Re: Subscriptions [message #1738068 is a reply to message #1737391] |
Fri, 15 July 2016 10:13  |
Eclipse User |
|
|
|
Hi Mahdi,
Thank you very much.
I changed my code like this:
targetId = "/" + CSE_ID + "/" + CSE_NAME + "/" + sensorId + "/"
+ DATA;
Subscription sub = new Subscription();
sub.getNotificationURI().add("http://XX.XX.XX.223:1400/Monitor");
sub.setNotificationContentType(BigInteger.valueOf(2));
RequestSender.createSubscription(targetId,SUB,sub);
And in my requestsender:
public static ResponsePrimitive createSubscription(String targetId, String name, Subscription resource){
return createResource(targetId, name, resource, ResourceType.SUBSCRIPTION);
There is no error shows up.
But i have another question. In fact, i download the source of Monitor.jar and i made it into a plugin in my IN side.
My question is How do i give the "nu" value if it is a plugin in IN?
Thanks in advance and have a good day!
Can
|
|
|
Powered by
FUDForum. Page generated in 0.04527 seconds