com.backendless.rt.messaging.MessagingSubscription Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-sdk-common Show documentation
Show all versions of java-sdk-common Show documentation
Provides access to Backendless API
The newest version!
package com.backendless.rt.messaging;
import com.backendless.rt.RTCallback;
import com.backendless.rt.RTSubscription;
import com.backendless.rt.SubscriptionNames;
public class MessagingSubscription extends RTSubscription
{
protected MessagingSubscription( SubscriptionNames subscriptionName, RTCallback callback )
{
super( subscriptionName, callback );
}
public static MessagingSubscription connect( String channel, RTCallback callback )
{
if(channel == null || channel.isEmpty())
throw createChannelNullException();
final MessagingSubscription messagingSubscription = new MessagingSubscription( SubscriptionNames.PUB_SUB_CONNECT, callback );
messagingSubscription.putOption( "channel", channel );
return messagingSubscription;
}
private static IllegalArgumentException createChannelNullException()
{
return new IllegalArgumentException( "channel can't be null or empty" );
}
public static MessagingSubscription subscribe( String channel, RTCallback callback )
{
if(channel == null || channel.isEmpty())
throw createChannelNullException();
final MessagingSubscription messagingSubscription = new MessagingSubscription( SubscriptionNames.PUB_SUB_MESSAGES, callback );
messagingSubscription.putOption( "channel", channel );
return messagingSubscription;
}
public static MessagingSubscription subscribe( String channel, String selector, RTCallback callback )
{
final MessagingSubscription messagingSubscription = subscribe( channel, callback );
messagingSubscription.putOption( "selector", selector );
return messagingSubscription;
}
public static MessagingSubscription command( String channel, RTCallback callback )
{
if(channel == null || channel.isEmpty())
throw createChannelNullException();
final MessagingSubscription messagingSubscription = new MessagingSubscription( SubscriptionNames.PUB_SUB_COMMANDS, callback );
messagingSubscription.putOption( "channel", channel );
return messagingSubscription;
}
public static MessagingSubscription userStatus( String channel, RTCallback callback )
{
if(channel == null || channel.isEmpty())
throw createChannelNullException();
final MessagingSubscription messagingSubscription = new MessagingSubscription( SubscriptionNames.PUB_SUB_USERS, callback );
messagingSubscription.putOption( "channel", channel );
return messagingSubscription;
}
String getSelector()
{
return (String) getOption( "selector" );
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy