Skip to content
Browse files

updated Wookie integration to support Wookie 0.10.0

  • Loading branch information...
1 parent 7fce12f commit ce9f351facd4958de97055851f701cc9e3bc1830 @scottbw committed Apr 12, 2012
Showing with 26 additions and 25 deletions.
  1. +12 −14 examples/wookie/feature/nodewave/wave.js
  2. +14 −11 examples/wookie/wookie_patch.txt
View
26 examples/wookie/feature/nodewave/wave.js
@@ -111,30 +111,28 @@
// Initialize the wave client
//
this.init = function(){
+
// Automatically set the Viewer and Shared Data Key if we're in a Wookie context
if (window.Widget) {
if (widget.viewerId){
- wave.setSharedDataKey(widget.preferences.sharedDataKey);
- wave.setViewer(widget.viewerId, widget.viewerDisplayName, widget.viewerThumbnailUrl);
+ wave.setSharedDataKey(widget.sharedDataKey);
+ wave.__setViewer(widget.viewerId, widget.viewerDisplayName, widget.viewerThumbnailUrl);
}
}
// Setup websockets
- io.setPath('socketio/');
- this.socket = new io.Socket("localhost", {"port":"8081"});
- this.socket.connect();
+ this.socket = io.connect("http://localhost:8081");
- //Setup events and callbacks
- this.socket.addEvent('message', function(data){
- var json = JSON.parse(data);
+ // Setup events and callbacks
+ this.socket.on('message', function(data){
// There are two types of data we can get - participants and state
- if (json.type == 'participants'){
- wave.__setParticipants(json.data);
+ if (data.type == 'participants'){
+ wave.__setParticipants(data.data);
if (wave.participant_callback) wave.participant_callback();
}
- if (json.type == 'state'){
+ if (data.type == 'state'){
// Apply delta to current state
- wave.getState().__applyPatches(json.data);
+ wave.getState().__applyPatches(data.data);
//wave.setState(json.data);
if (wave.state_callback) wave.state_callback();
}
@@ -190,7 +188,7 @@
if (window.Widget) msg.idkey = Widget.instanceid_key;
msg.sharedDataKey = wave.sharedDataKey;
msg.viewer = this.viewer;
- this.socket.send(JSON.stringify(msg));
+ this.socket.json.send(msg);
}
// Update the internal participants array
@@ -232,7 +230,7 @@
msg.key = "0";
if (window.widget) msg.key = Widget.instanceid_key;
msg.delta = thedelta;
- this.socket.send(JSON.stringify(msg));
+ this.socket.json.send(msg);
}
}
View
25 examples/wookie/wookie_patch.txt
@@ -2,35 +2,38 @@
#P wookie
Index: src/org/apache/wookie/ajaxmodel/impl/WidgetAPIImpl.java
===================================================================
---- src/org/apache/wookie/ajaxmodel/impl/WidgetAPIImpl.java (revision 1134049)
+--- src/org/apache/wookie/ajaxmodel/impl/WidgetAPIImpl.java (revision 1238828)
+++ src/org/apache/wookie/ajaxmodel/impl/WidgetAPIImpl.java (working copy)
-@@ -26,6 +26,7 @@
+@@ -26,12 +26,15 @@
import org.apache.wookie.ajaxmodel.IWidgetAPI;
import org.apache.wookie.beans.IDescription;
import org.apache.wookie.beans.IName;
+import org.apache.wookie.beans.IParticipant;
import org.apache.wookie.beans.IPreference;
- import org.apache.wookie.beans.ISharedData;
import org.apache.wookie.beans.IWidget;
-@@ -35,6 +36,7 @@
+ import org.apache.wookie.beans.IWidgetInstance;
++import org.apache.wookie.beans.SharedContext;
+ import org.apache.wookie.beans.util.IPersistenceManager;
+ import org.apache.wookie.beans.util.PersistenceManagerFactory;
import org.apache.wookie.controller.PropertiesController;
- import org.apache.wookie.controller.WidgetInstancesController;
- import org.apache.wookie.helpers.Notifier;
-+import org.apache.wookie.helpers.ParticipantHelper;
- import org.apache.wookie.helpers.SharedDataHelper;
++import org.apache.wookie.helpers.SharedDataHelper;
import org.apache.wookie.queues.QueueManager;
import org.apache.wookie.server.ContextListener;
-@@ -145,6 +147,13 @@
+ import org.apache.wookie.server.LocaleHandler;
+@@ -125,6 +128,16 @@
map.put("width", width);//$NON-NLS-1$
map.put("height", height);//$NON-NLS-1$
+ // Extra Viewer information
-+ IParticipant viewer = persistenceManager.findParticipantViewer(widgetInstance);
++ IParticipant viewer = new SharedContext(widgetInstance).getViewer(widgetInstance);
+ if (viewer != null){
+ map.put("viewerId", viewer.getParticipantId());
+ map.put("viewerDisplayName", viewer.getParticipantDisplayName());
+ map.put("viewerThumbnailUrl", viewer.getParticipantThumbnailUrl());
+ }
++ // Shared data
++ map.put("sharedDataKey", SharedDataHelper.getExternalSharedDataKey(widgetInstance));
++
return map;
}
-
+

0 comments on commit ce9f351

Please sign in to comment.
Something went wrong with that request. Please try again.