mirror of
https://github.com/fergalmoran/chrometophone.git
synced 2025-12-30 05:31:19 +00:00
Add browser channel support and bump SDK ver to 1.3.6
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="src" path="src"/>
|
<classpathentry kind="src" path="src"/>
|
||||||
<classpathentry kind="src" path="c2dm"/>
|
<classpathentry kind="src" path="c2dm"/>
|
||||||
<classpathentry kind="con" path="com.google.appengine.eclipse.core.GAE_CONTAINER"/>
|
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||||
|
<classpathentry kind="con" path="com.google.appengine.eclipse.core.GAE_CONTAINER/App Engine"/>
|
||||||
<classpathentry kind="output" path="war/WEB-INF/classes"/>
|
<classpathentry kind="output" path="war/WEB-INF/classes"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#Mon May 31 20:22:11 BST 2010
|
#Sun Aug 29 18:14:05 BST 2010
|
||||||
eclipse.preferences.version=1
|
eclipse.preferences.version=1
|
||||||
filesCopiedToWebInfLib=appengine-api-1.0-sdk-1.3.4.jar|appengine-api-labs-1.3.4.jar|appengine-jsr107cache-1.3.4.jar|jsr107cache-1.1.jar|datanucleus-appengine-1.0.7.final.jar|datanucleus-core-1.1.5.jar|datanucleus-jpa-1.1.5.jar|geronimo-jpa_3.0_spec-1.1.1.jar|geronimo-jta_1.1_spec-1.1.1.jar|jdo2-api-2.3-eb.jar
|
filesCopiedToWebInfLib=appengine-api-1.0-sdk-1.3.6.jar|appengine-api-labs-1.3.6.jar|appengine-jsr107cache-1.3.6.jar|jsr107cache-1.1.jar|datanucleus-appengine-1.0.7.final.jar|datanucleus-core-1.1.5.jar|datanucleus-jpa-1.1.5.jar|geronimo-jpa_3.0_spec-1.1.1.jar|geronimo-jta_1.1_spec-1.1.1.jar|jdo2-api-2.3-eb.jar
|
||||||
ormEnhancementInclusions=src/**|c2dm/**
|
ormEnhancementInclusions=src/**|c2dm/**
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010 Google Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.google.android.chrometophone.server;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServlet;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import com.google.appengine.api.channel.ChannelMessage;
|
||||||
|
import com.google.appengine.api.channel.ChannelService;
|
||||||
|
import com.google.appengine.api.channel.ChannelServiceFactory;
|
||||||
|
import com.google.appengine.api.users.User;
|
||||||
|
|
||||||
|
@SuppressWarnings("serial")
|
||||||
|
public class BrowserChannelServlet extends HttpServlet {
|
||||||
|
private static final String OK_STATUS = "OK";
|
||||||
|
private static final String LOGIN_REQUIRED_STATUS = "LOGIN_REQUIRED";
|
||||||
|
private static final String ERROR_STATUS = "ERROR";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
|
||||||
|
resp.setContentType("text/plain");
|
||||||
|
|
||||||
|
// Basic XSRF protection
|
||||||
|
if (req.getHeader("X-Same-Domain") == null) {
|
||||||
|
resp.setStatus(400);
|
||||||
|
resp.getWriter().println(ERROR_STATUS);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
User user = RegisterServlet.checkUser(req, resp, false);
|
||||||
|
if (user == null) {
|
||||||
|
resp.setStatus(400);
|
||||||
|
resp.getWriter().println(LOGIN_REQUIRED_STATUS);
|
||||||
|
} else {
|
||||||
|
String channelToken = String.valueOf(user.hashCode()); // channel per user
|
||||||
|
String data = req.getParameter("data");
|
||||||
|
if (data != null) { // send data
|
||||||
|
getChannelService().sendMessage(new ChannelMessage(channelToken, data));
|
||||||
|
resp.getWriter().print(OK_STATUS);
|
||||||
|
} else { // setup channel
|
||||||
|
String channelId = getChannelService().createChannel(channelToken);
|
||||||
|
resp.getWriter().print(channelId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private ChannelService getChannelService() {
|
||||||
|
return ChannelServiceFactory.getChannelService();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
-->
|
-->
|
||||||
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
|
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
|
||||||
<application>chrometophone</application>
|
<application>chrometophone</application>
|
||||||
<version>4</version>
|
<version>5</version>
|
||||||
<system-properties>
|
<system-properties>
|
||||||
<property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
|
<property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
|
||||||
</system-properties>
|
</system-properties>
|
||||||
|
|||||||
@@ -41,6 +41,12 @@
|
|||||||
<servlet-class>com.google.android.chrometophone.server.AuthServlet
|
<servlet-class>com.google.android.chrometophone.server.AuthServlet
|
||||||
</servlet-class>
|
</servlet-class>
|
||||||
</servlet>
|
</servlet>
|
||||||
|
|
||||||
|
<servlet>
|
||||||
|
<servlet-name>BrowserChannelServlet</servlet-name>
|
||||||
|
<servlet-class>com.google.android.chrometophone.server.BrowserChannelServlet
|
||||||
|
</servlet-class>
|
||||||
|
</servlet>
|
||||||
|
|
||||||
<servlet>
|
<servlet>
|
||||||
<servlet-name>dataMessagingServlet</servlet-name>
|
<servlet-name>dataMessagingServlet</servlet-name>
|
||||||
@@ -73,6 +79,11 @@
|
|||||||
<servlet-name>AuthServlet</servlet-name>
|
<servlet-name>AuthServlet</servlet-name>
|
||||||
<url-pattern>/signout</url-pattern>
|
<url-pattern>/signout</url-pattern>
|
||||||
</servlet-mapping>
|
</servlet-mapping>
|
||||||
|
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>BrowserChannelServlet</servlet-name>
|
||||||
|
<url-pattern>/browserchannel</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
|
||||||
<servlet-mapping>
|
<servlet-mapping>
|
||||||
<servlet-name>dataMessagingServlet</servlet-name>
|
<servlet-name>dataMessagingServlet</servlet-name>
|
||||||
|
|||||||
Reference in New Issue
Block a user