org.atmosphere.samples.pubsub
Class TypedChannel

java.lang.Object
  extended by org.atmosphere.samples.pubsub.TypedChannel

public class TypedChannel
extends Object

Simple Resource acting like a channel of communication.

Author:
Jeanfrancois Arcand

Constructor Summary
TypedChannel()
           
 
Method Summary
 String handshake()
          Subscribe to "channel" distribution.
 String onMessage(String message)
          Broadcast messages to the "channel" distribution.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TypedChannel

public TypedChannel()
Method Detail

handshake

@Subscribe(value="channel")
public String handshake()
Subscribe to "channel" distribution. With comet, the http connection will be suspended. With websocket, the handshake will gets executed.

Returns:
null - no message is send back to browser yet.

onMessage

@Publish(value="channel")
public String onMessage(String message)
Broadcast messages to the "channel" distribution. This method gets invoked when a WebSocket message arrive and distributed to all websocket connection that has invoked the handshake method. Note that comet application will works as well when sending POST.

Parameters:
message - the message to distribute
Returns:
the message that will be send to the "channel" distribution.


Copyright © 2011. All Rights Reserved.