Skip to content

Pusher on App Engine sample #798

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

Merged
merged 15 commits into from
Aug 9, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
using static vars in JSP for pusher app id, cluster info
  • Loading branch information
jabubake committed Aug 9, 2017
commit a3967b55afba79662c20f9ce4a0a04e6e2fdd81e
2 changes: 0 additions & 2 deletions appengine/pusher-chat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ If this is your first time creating an App engine application:

- Create a [Pusher] application and note down the `app_id`, `app_key`, `app_secret` and the cluster.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is [Pusher] enough?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that seems to work.

- Update [appengine-web.xml](src/main/webapp/WEB-INF/appengine-web.xml) with these credentials.
- Update Line 71 in [chat.jsp](src/main/webapp/WEB-INF/view/chat.jsp) with the `app_id` and cluster information.


## Running locally

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@
import com.pusher.rest.Pusher;

// [START pusher_server_initialize]
abstract class PusherService {
public abstract class PusherService {

public static final String APP_KEY = System.getenv("PUSHER_APP_KEY");
public static final String CLUSTER = System.getenv("PUSHER_CLUSTER");

private static final String APP_ID = System.getenv("PUSHER_APP_ID");
private static final String APP_KEY = System.getenv("PUSHER_APP_KEY");
private static final String APP_SECRET = System.getenv("PUSHER_APP_SECRET");
private static final String CLUSTER = System.getenv("PUSHER_CLUSTER");

private static Pusher instance;

Expand Down
5 changes: 3 additions & 2 deletions appengine/pusher-chat/src/main/webapp/WEB-INF/view/chat.jsp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!DOCTYPE HTML>
<%@ page import="com.example.appengine.pusher.ChatServlet" %>
<%@ page import="com.example.appengine.pusher.PusherService" %>
<%@ page import="java.util.Date" %>
<%--
Copyright 2017 Google Inc.
Expand Down Expand Up @@ -68,8 +69,8 @@

// Connect to Pusher with auth endpoint on your server for private/presence channels
// (default auth endpoint : /pusher/auth)
var pusher = new Pusher("pusher_app_key", {
cluster: "pusher_cluster",
var pusher = new Pusher('<%= PusherService.APP_KEY %>', {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched to static vars, @lesv

cluster: '<%= PusherService.CLUSTER %>',
authEndpoint: '/authorize',
encrypted: true
});
Expand Down