Giter Club home page Giter Club logo

gwt-channel-api's People

Contributors

eirikb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gwt-channel-api's Issues

send vs onMessage

Your Server code uses "send" but your client code used "onMessage"

This also means there is a compiler error initially because it says you have not implemented "onMessage" in the server code

ChannelServer.java:
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)); }
Client:
public void send(String message, AsyncCallback<Void> callback) {
channelService.onMessage(token, channelName, message, callback);
}

Missing ChannelListenerAsync.java

I created one myself:

package no.eirikb.gwtchannelapi.client;

import com.google.gwt.user.client.rpc.AsyncCallback;

public interface ChannelListenerAsync { void onMessage(String message,AsyncCallback<Void> asyncCallback);
void onOpen(AsyncCallback<Void> asyncCallback);
void onError(int code, String description, AsyncCallback<Void> asyncCallback);
void onClose(AsyncCallback<Void> asyncCallback);
}

onerror() and onclose() missed

I am trying to control the disconnection of a client from a channel, trying to distinguish when a user close the browser of when the token was expired (to renew or create a new token in this last case).

Following the Channel API of Google (https://developers.google.com/appengine/docs/java/channel/overview#Tokens_and_Security), when a token expires 'the socket’s onerror() and onclose() callbacks are called' but I only can find the onReceive method within the ChannelListener, how can I access to this events?

Or how could I control the session of a user (expiration time) in other way?

Thanks so much.

Channel class swallows errors for failed RPC to ChannelService.join()

Hi there, thanks for the great library.
In the Channel.join() method I noticed that the onError() callback for the RPC is empty, i.e. it will hide errors on failed calls to the server:

    public void join() {
        channelService.join(channelName, new AsyncCallback<String>() {
            @Override
            public void onFailure(Throwable throwable) {
                // Exceptions disappear here
            }

            @Override
            public void onSuccess(String t) {
                token = t;
                join(token);
            }
        });
    }

This is probably a rare event, but potentially tricky to debug when it happens.
I can think of a few potential solutions. Here's the first two:

  1. Add onJoinError() to ChannelListener:
public interface ChannelListener extends RemoteService {

    void onJoinError(Throwable caught);

    void onMessage(String message);

    void onOpen();

    void onError(int code, String description);

    void onClose();
}
  1. Add something like FailedJoinCallback and join(FailedJoinCallback callback) to Channel:
public interface FailedJoinCallback {
    void onFailedJoin(Throwable caught);
}
    public void join(FailedJoinCallback callback) {
        channelService.join(channelName, new AsyncCallback<String>() {
            @Override
            public void onFailure(Throwable caught) {
                callback.onFailedJoin(caught);
            }

            @Override
            public void onSuccess(String t) {
                token = t;
                join(token);
            }
        });

/_ah/channel/jsapi missing?

I am trying to get up and running with gwt-channel-api in an existing project. I have set up the required JARs and classpaths in Eclipse, and when I launch GWT Dev mode everything compiles properly.

However, when I load the app web page in the browser, I see an error for a missing resource:
/_ah/channel/jsapi

This is included in the index.jsp, as instructed here.

What is this? A JavaScript file? If so, should it be:
/_ah/channel/jsapi.js?

Where does this come from?
Is it generated by GWT compile?

Thanks,
Don

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.