gwt-channel-api
gwt-channel-api copied to clipboard
Configurable Channel Duration
Hi there. I ran into a minor hurdle with this. It would be helpful to be able to configure the channel duration when creating the channel. For example, with the burstiness of my current project, I would be setting the duration to just 30 minutes or less, whereas the default is 2 hours.
For reference, the Channel API has rate-limiting for the number of channel-hours requested per minute...
- Free Tier: 12 hours requested/minute (i.e. max of 6 people open channels within a minute).
- Paid Tier: 180 hours requested/minute (i.e. max of 90 people open channels within a minute).
One possible approach (which is also backwards-compatible) might look like this:
public abstract class ChannelServer extends RemoteServiceServlet implements ChannelService {
// ADDED THIS
/**
* Defaults to 2 hours. Override if needed.
*/
protected int getChannelDuration() {
return 2*60;
}
protected static void send(String channel, Object o) {
AutoBean bean = AutoBeanUtils.getAutoBean(o);
String serialized = AutoBeanCodex.encode(bean).getPayload();
ChannelServiceFactory.getChannelService().sendMessage(new ChannelMessage(channel, serialized));
}
@Override
public final String join(String channelName) {
// MODIFIED THIS
String token = ChannelServiceFactory.getChannelService().createChannel(channelName, getChannelDuration());
onJoin(token, channelName);
return token;
}
protected abstract void onJoin(String token, String channelName);
}
That's my 2 cents. Cheers :)