ch.unifr.pai.twice.multipointer.client
Class ExtendedWebsocketControl

java.lang.Object
  extended by ch.unifr.pai.twice.multipointer.client.MultiCursorController
      extended by ch.unifr.pai.twice.multipointer.client.ExtendedWebsocketControl
All Implemented Interfaces:
com.google.gwt.event.logical.shared.ResizeHandler, com.google.gwt.event.shared.EventHandler

public class ExtendedWebsocketControl
extends MultiCursorController
implements com.google.gwt.event.logical.shared.ResizeHandler

The currently used controller for multi-cursor device types

Author:
Oliver Schmid

Nested Class Summary
private  class ExtendedWebsocketControl.CursorColor
          A map between the cursor name (related to the .png's in the public folder) and their corresponding HTML color codes.
 
Field Summary
private  java.util.Map<java.lang.String,MouseCursor> assignedMouseCursors
           
(package private)  int currentCursor
           
private  java.util.List<ExtendedWebsocketControl.CursorColor> cursorColors
           
private  boolean opened
           
(package private)  com.google.gwt.event.shared.HandlerRegistration r
           
private  com.google.gwt.storage.client.Storage storage
           
private  java.util.List<MouseCursor> visibleCursors
           
private  com.google.gwt.core.client.JavaScriptObject websocket
           
 
Constructor Summary
ExtendedWebsocketControl()
           
 
Method Summary
private  com.google.gwt.core.client.JavaScriptObject createOnBeforeUnloadHandler(com.google.gwt.core.client.JavaScriptObject websocket)
          stops the web socket connection before unload to prevent connections to be unused.
private  com.google.gwt.core.client.JavaScriptObject createWebsocket(ExtendedWebsocketControl w, java.lang.String url)
          Initializes a websocket connection if available
private  MouseCursor defineMouseCursor(java.lang.String cursor, java.lang.String color)
          Create and attach a new mouse pointer representation
private  MouseCursor getOrCreateCursor(java.lang.String uuid)
          Looks up the assigned mouse pointer for a specific device (by the uuid) and returns it.
private  void initializeCursorList()
          Initializes the available cursor colors.
 boolean isInIFrame()
           
 void notifyCursor(java.lang.String uuid, java.lang.String action)
          Notify the cursor with the given unique identifier about a given action
private  void onClose()
          actions on close of the web socket server
private  void onMessage(java.lang.String data)
          If a message arrives, it is analyzed and provided to the MouseCursor for further interpretation.
private  void onOpen()
          As soon as the web socket channel is opened, the component sends its screen dimensions to the server
 void onResize(com.google.gwt.event.logical.shared.ResizeEvent event)
          If the screen of the shared device is resized, the component updates the information on the server side.
private  void send(com.google.gwt.core.client.JavaScriptObject websocket, java.lang.String message)
          Sends a message through the websocket to the server
 void start()
          Start the execution of the component
 void stop()
          Stop the execution of the component
private  com.google.gwt.core.client.JavaScriptObject stopWebsocket(com.google.gwt.core.client.JavaScriptObject websocket)
          stops the websocket connection
 
Methods inherited from class ch.unifr.pai.twice.multipointer.client.MultiCursorController
getColorNative, getInstance, getMaxCursorsOnScreen, getUUID, isDefaultCursor, setMaxCursorsOnScreen
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

opened

private boolean opened

websocket

private com.google.gwt.core.client.JavaScriptObject websocket

visibleCursors

private final java.util.List<MouseCursor> visibleCursors

assignedMouseCursors

private final java.util.Map<java.lang.String,MouseCursor> assignedMouseCursors

storage

private final com.google.gwt.storage.client.Storage storage

cursorColors

private final java.util.List<ExtendedWebsocketControl.CursorColor> cursorColors

currentCursor

int currentCursor

r

com.google.gwt.event.shared.HandlerRegistration r
Constructor Detail

ExtendedWebsocketControl

public ExtendedWebsocketControl()
Method Detail

initializeCursorList

private void initializeCursorList()
Initializes the available cursor colors.


defineMouseCursor

private MouseCursor defineMouseCursor(java.lang.String cursor,
                                      java.lang.String color)
Create and attach a new mouse pointer representation

Parameters:
cursor -
color -
Returns:

isInIFrame

public boolean isInIFrame()
Returns:
if the component is executed within a frame

start

public void start()
Description copied from class: MultiCursorController
Start the execution of the component

Overrides:
start in class MultiCursorController

stop

public void stop()
Description copied from class: MultiCursorController
Stop the execution of the component

Overrides:
stop in class MultiCursorController

send

private void send(com.google.gwt.core.client.JavaScriptObject websocket,
                  java.lang.String message)
Sends a message through the websocket to the server

Parameters:
websocket -
message -

createOnBeforeUnloadHandler

private com.google.gwt.core.client.JavaScriptObject createOnBeforeUnloadHandler(com.google.gwt.core.client.JavaScriptObject websocket)
stops the web socket connection before unload to prevent connections to be unused.

Parameters:
websocket -
Returns:

stopWebsocket

private com.google.gwt.core.client.JavaScriptObject stopWebsocket(com.google.gwt.core.client.JavaScriptObject websocket)
stops the websocket connection

Parameters:
websocket -
Returns:

createWebsocket

private com.google.gwt.core.client.JavaScriptObject createWebsocket(ExtendedWebsocketControl w,
                                                                    java.lang.String url)
Initializes a websocket connection if available

Parameters:
w -
url -
Returns:

onMessage

private void onMessage(java.lang.String data)
If a message arrives, it is analyzed and provided to the MouseCursor for further interpretation.

Parameters:
data -

getOrCreateCursor

private MouseCursor getOrCreateCursor(java.lang.String uuid)
Looks up the assigned mouse pointer for a specific device (by the uuid) and returns it. If no mouse pointer is assigned to this UUID, a new cursor is assigned to this device and returned. This method also informs the web socket server about the new assignment for passing through that information to the according client.

Parameters:
uuid -
Returns:

onOpen

private void onOpen()
As soon as the web socket channel is opened, the component sends its screen dimensions to the server


onClose

private void onClose()
actions on close of the web socket server


onResize

public void onResize(com.google.gwt.event.logical.shared.ResizeEvent event)
If the screen of the shared device is resized, the component updates the information on the server side.

Specified by:
onResize in interface com.google.gwt.event.logical.shared.ResizeHandler
See Also:
ResizeHandler.onResize(com.google.gwt.event.logical.shared.ResizeEvent)

notifyCursor

public void notifyCursor(java.lang.String uuid,
                         java.lang.String action)
Description copied from class: MultiCursorController
Notify the cursor with the given unique identifier about a given action

Overrides:
notifyCursor in class MultiCursorController