Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable Channel Duration #7

Open
vidalborromeo opened this issue Oct 12, 2016 · 0 comments
Open

Configurable Channel Duration #7

vidalborromeo opened this issue Oct 12, 2016 · 0 comments

Comments

@vidalborromeo
Copy link

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant