gwt-gae-channel-1.0-20010325

Useful Information

This page has been generated by maven-confluence-plugin


Description

The Channel API creates a persistent connection between your application and Google servers, allowing your application to send messages to JavaScript clients in real time without the use of polling. This is useful for applications that are designed to update the user about new information immediately or where user input is immediately broadcast to other users. Some examples include collaborative applications, multi-player games, and chat rooms. In general, using Channel API is a better choice than polling in situations where updates can't be predicted or scripted, such as when relaying information between human users or from events not generated systematically.

Introduction

First of all, you should read and be familiar with how to use the App Engine Channel API java on the server-side.

This library simply wraps the client-side JavaScript with GWT bindings to make it accessible in a GWT application, and it doesn't manage telling your client the client ID it should use. That part's up to you, and is described in the documentation for the Channel API.

How To use

Declare dependency (available from Artifactory)

 
 <!-- 
===========================================
CHANNEL API
===========================================
 -->
<dependency>
	<groupId>gwt-gae-channel</groupId>
	<artifactId>gwt-gae-channel</artifactId>
	<version>1.0-20010325</version>
</dependency>
	

Inherit gwt module

In your GWT descriptor you have to include the following inherit declaration

GWT module
 
	<inherits name="com.google.gwt.appengine.channel.Channel"/>

Create a service that generate a unique token to be associated with the event channel

Each channel is identified by an unique token that should be generated by application itself. In order to do this you have to implement a simple service (e.g. servlet) that accomplish this task

Initialize Event Listener (client side)

initialize service from client
 private void initEventsManagement() {
 
	// GET CUSTOM TOKEN FROM SERVLET
	RequestBuilder request = new RequestBuilder(RequestBuilder.POST, GWT.getModuleBaseURL() + "/service/events/token");
	
	try {
		request.sendRequest("",new RequestCallback() {
			
			@Override
			public void onResponseReceived(Request req, Response res) {
				GWT.log("onResponseReceived " + res.getText() );
				
				// REGISTER CHANNEL FOR GIVEN TOKEN (see below)
				registerChannel(res.getText());
				
			}
			
			@Override
			public void onError(Request req, Throwable t) {
				GWT.log("onError ", t );
			}
		});
	} catch (RequestException e) {
		e.printStackTrace();
	}
	
  }
    
  private void registerChannel( String token ) {

	GWT.log("Event Module load!");
	
	ChannelFactory.createChannel(token, new ChannelCreatedCallback() {
		  @Override
		  public void onChannelCreated(Channel channel) {
		    channel.open(new SocketListener() {
		      @Override
		      public void onOpen() {
		        GWT.log("Event Channel opened!");
		      }
		      @Override
		      public void onMessage(String message) {
		    	  GWT.log("Event Received: " + message);
		      }
		      @Override
		      public void onError(SocketError error) {
		    	  GWT.log("Event Channel creation error: " + error.getDescription());
		      }
		      @Override
		      public void onClose() {
		    	  GWT.log("Channel closed!");
		      }
		    });
		  }
		});		
	}

Send event (server side)

The following is a simple example of how to open a channel and send event to the client listeners when receives a message.

send event from server
public void sendEvent(String event) {
      ChannelService channelService = ChannelServiceFactory.getChannelService();
      channelService.sendMessage(new ChannelMessage( token /* the same token generated by application, see above */, event));

}

Project Summary

Project Information

Field Value
Name GWT GAE channel API
Description GWT bindings for the App Engine Channel API client
Homepage http://code.google.com/p/gwt-gae-channel/

Project Organization

Field Value
Name Google, Inc.
URL http://www.google.com

Build Information

Field Value
GroupId gwt-gae-channel
ArtifactId gwt-gae-channel
Version 1.0-20010325
Type jar

Issue Tracking


Source Repository

Overview

This project uses Subversion
to manage its source code. Instructions on Subversion use can be found at http://svnbook.red-bean.com/
.

Web Access

The following is a link to the online source repository.

[http://code.google.com/p/gwt-gae-channel/source/browse|http://code.google.com/p/gwt-gae-channel/source/browse]

Anonymous access

The source can be checked out anonymously from SVN with this command:

$ svn checkout http://gwt-gae-channel.googlecode.com/svn/trunk gwt-gae-channel

Developer access

Everyone can access the Subversion repository via HTTP, but Committers must checkout the Subversion repository via HTTPS.

$ svn checkout https://gwt-gae-channel.googlecode.com/svn/trunk gwt-gae-channel

To commit changes to the repository, execute the following command to commit your changes (svn will prompt you for your password)

$ svn commit --username your-username -m "A message"

Access from behind a firewall

For those users who are stuck behind a corporate firewall which is blocking HTTP access to the Subversion repository, you can try to access it via the developer connection:

$ svn checkout https://gwt-gae-channel.googlecode.com/svn/trunk gwt-gae-channel

Access through a proxy

The Subversion client can go through a proxy, if you configure it to do so. First, edit your "servers" configuration file to indicate which proxy to use. The file's location depends on your operating system. On Linux or Unix it is located in the directory "~/.subversion". On Windows it is in "%APPDATA%\Subversion". (Try "echo %APPDATA%", note this is a hidden directory.)
There are comments in the file explaining what to do. If you don't have that file, get the latest Subversion client and run any command; this will cause the configuration directory and template files to be created.
Example: Edit the 'servers' file and add something like:

[global]
http-proxy-host = your.proxy.name
http-proxy-port = 3128

Project Dependencies

provided

The following is a list of provided dependencies for this project. These dependencies are required to compile the application, but should be provided by default when using the library:

GroupId ArtifactId Version Classifier Type Optional
com.google.gwt gwt-user 2.1.0 - jar -

Project Transitive Dependencies

The following is a list of transitive dependencies for this project. Transitive dependencies are the dependencies of the project dependencies.

Project Dependency Graph

Dependency Tree


Dependency File Details

GWT GAE channel API
GWT bindings for the App Engine Channel API client
http://code.google.com/p/gwt-gae-channel/

gwt-user
Sonatype helps open source projects to set up Maven repositories on https://oss.sonatype.org/
http://code.google.com/webtoolkit/gwt-user/

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.