Package com.kii.cloud.storage
Class KiiTopic
- java.lang.Object
-
- com.kii.cloud.storage.KiiTopic
-
- All Implemented Interfaces:
KiiSubscribable
public class KiiTopic extends java.lang.Object implements KiiSubscribable
KiiTopic is entity can be a target sending/subscribe push message.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description KiiACL
acl()
Get the ACL handle of this KiiTopic.void
delete()
Delete the topic.Only the scope owner or topic creator is allowed to perform delete operation.int
delete(KiiTopicCallBack callback)
Asynchronous call fordelete()
.boolean
exists()
Checks whether the topic already exists or not.void
exists(KiiCallback<java.lang.Boolean> callback)
Asynchronous call ofexists()
A background task will be initiated to execute the task.java.lang.String
getName()
Returns topic name.void
save()
Save this topic on KiiCloud.int
save(KiiTopicCallBack callback)
Asynchronous call ofsave()
Background task will be initiated to execute the task.void
sendMessage(KiiPushMessage message)
Send message to this topic.int
sendMessage(KiiPushMessage message, KiiTopicCallBack callback)
Asynchronous call ofsendMessage(KiiPushMessage)
Background task will be initiated to execute the task.
-
-
-
Method Detail
-
exists
@WorkerThread public boolean exists() throws BadRequestException, UnauthorizedException, ForbiddenException, ConflictException, NotFoundException, UndefinedException, java.io.IOException
Checks whether the topic already exists or not.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Returns:
- true if the topic already exists, otherwise false.
- Throws:
java.io.IOException
ForbiddenException
UnauthorizedException
BadRequestException
ConflictException
NotFoundException
UndefinedException
-
exists
public void exists(@NonNull KiiCallback<java.lang.Boolean> callback)
Asynchronous call ofexists()
A background task will be initiated to execute the task.- Parameters:
callback
- notifies events.
-
save
@WorkerThread public void save() throws BadRequestException, UnauthorizedException, ForbiddenException, ConflictException, NotFoundException, UndefinedException, java.io.IOException
Save this topic on KiiCloud. If topic already exist,ConflictException
will be thrown. If the topic is in application scope, UnsupportedOperationException will be thrown. Application scope topic can not create from device sdk.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Throws:
BadRequestException
UnauthorizedException
ForbiddenException
ConflictException
NotFoundException
UndefinedException
java.io.IOException
java.lang.UnsupportedOperationException
- thrown when try to save application scope topic.java.lang.IllegalStateException
- thrwon when no user logged in.
-
save
public int save(@NonNull KiiTopicCallBack callback)
Asynchronous call ofsave()
Background task will be initiated to execute the task.- Parameters:
callback
- notifies events.- Returns:
- id of this task. Can be used to cancel this operation by
Kii.cancelTask(int)
-
sendMessage
@WorkerThread public void sendMessage(@NonNull KiiPushMessage message) throws java.io.IOException, BadRequestException, UnauthorizedException, ForbiddenException, ConflictException, NotFoundException, UndefinedException
Send message to this topic. Message will be delivered to users who subscribes this topic.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Parameters:
message
- to send.- Throws:
java.io.IOException
BadRequestException
- Thrown if request data sent to the server is 'malformed'. Note that, if the size of the payload that is intended to send to APNS devices exceeds 256 bytes, will be considered as invalid request and also thrown BadRequestException in this case.UnauthorizedException
ForbiddenException
ConflictException
NotFoundException
UndefinedException
java.lang.UnsupportedOperationException
- thrown when try to save application scope topic.java.lang.IllegalStateException
- thrown when no user logged in.
-
sendMessage
public int sendMessage(@NonNull KiiPushMessage message, @NonNull KiiTopicCallBack callback)
Asynchronous call ofsendMessage(KiiPushMessage)
Background task will be initiated to execute the task.- Parameters:
callback
- notifies events.- Returns:
- id of this task. Can be used to cancel this operation by
Kii.cancelTask(int)
-
delete
@WorkerThread public void delete() throws java.io.IOException, BadRequestException, ConflictException, ForbiddenException, NotFoundException, UnauthorizedException, UndefinedException
Delete the topic.Only the scope owner or topic creator is allowed to perform delete operation.
NOTE: This api access to server. Should not be executed in UI/Main thread.- Throws:
java.io.IOException
- When network related error has happenedUndefinedException
NotFoundException
- Thrown if the topic does not exist in the cloud.ConflictException
ForbiddenException
BadRequestException
UnauthorizedException
- Thrown if operating user is other than scope owner or topic creator.java.lang.UnsupportedOperationException
- thrown when try to delete application scope topic.
-
delete
public int delete(@NonNull KiiTopicCallBack callback)
Asynchronous call fordelete()
. A background task will be initiated to execute the task.- Parameters:
callback
- notifies events- Returns:
- id used for cancel this operation. see also
Kii.cancelTask(int)
-
acl
public KiiACL acl()
Get the ACL handle of this KiiTopic.- Returns:
- ACL of this KiiTopic
- See Also:
KiiACL
-
getName
public java.lang.String getName()
Returns topic name.- Returns:
- name of the topic.
-
-