Packagecom.adobe.rtc.sharedModel
Classpublic class Baton
InheritanceBaton Inheritance flash.events.EventDispatcher
ImplementsISessionSubscriber

Baton is a model class which provides a workflow between users. Essentially, it tracks the "holder" of a given resource and provides APIs for grabbing, putting down, and giving control to others. Users with an owner role always have the power to grab the baton, put it down, or give it to others regardless of who has the baton. Users with a publisher role must wait according to the grabbable property: By default, a baton will timeout in five seconds and be released. This timeout can be adjusted in the constructor and extended during use of the resource in question using extendTimer.

Note that users with an owner role may adjust the roles of other users relative to the baton using allowUserToGrab (which makes that user a publisher) and allowUserToAdminister (which makes that user an owner).

This component also supports "piggybacking" on existing CollectionNodes through its constructor. Developers can avoid CollectionNode proliferation in their applications by pre-supplying a CollectionNode and a nodeName for the baton to use. If none is supplied, the baton will create its own collection node for sending and receiving messages.

See also

com.adobe.rtc.sharedModel.CollectionNode
com.adobe.rtc.messaging.UserRoles


Public Properties
 PropertyDefined by
  accessModel : int
Role value which is required for seeing the baton
Baton
  amIHolding : Boolean
[read-only] Determines whether the current user is holding the baton.
Baton
  available : Boolean
[read-only] Determines whether the baton is up for grabs because it has no current holder.
Baton
  canIAdminister : Boolean
[read-only] Determines whether the current user has permission to administer the baton by taking it from someone or forcing them to put it down.
Baton
  canIGrab : Boolean
[read-only] Determines whether the current user has permission to grab the baton when available.
Baton
  collectionNode : CollectionNode
Sets the Collection Node to which the shared property subscribes/publishes
Baton
  connectSession : IConnectSession
The IConnectSession with which this component is associated.
Baton
  grabbable : Boolean
Whether or not to allow users with a publisher role to grab an available baton.
Baton
  holderID : String
[read-only] Specifies the userID of the person controlling the baton.
Baton
  isSynchronized : Boolean
[read-only] Determines whether the component has connected to the server and has fully synchronized.
Baton
  nodeName : String
Sets the Node Name to which the value is published
Baton
  publishModel : int
Role Value required to grab the baton
Baton
  sharedID : String
Defines the logical location of the component on the service - typically this assigns the sharedID of the collectionNode used by the component.
Baton
  timeOut : int
Number of seconds after which the baton times out If 0, no timeout is used.
Baton
Public Methods
 MethodDefined by
  
Constructor.
Baton
  
canUserAdminister(p_userID:String):Boolean
Determines whether a specified user can administer the baton from others.
Baton
  
canUserGrab(p_userID:String):Boolean
Determines whether a specified user can grab the baton if it's available.
Baton
  
close():void
Cleans up all networking and event handling; recommended for garbage collection.
Baton
  
extendTimer():void
Extends the timeout if the baton has one.
Baton
  
Gets the NodeConfiguration of the Baton Node.
Baton
  
getUserRole(p_userID:String):int
Returns the role of a given user for the baton.
Baton
  
giveTo(p_userID:String):void
If the baton is grabbable, the holding user can hand the baton to a specified user.
Baton
  
grab():void
If grabbable, users with a publisher role can grab the control if it's available by using this method.
Baton
  
putDown():void
Users with an publisher role in control can use this method to release their control.
Baton
  
setNodeConfiguration(p_nodeConfiguration:NodeConfiguration):void
Sets the NodeConfiguration on the baton node.
Baton
  
setUserRole(p_userID:String, p_role:Number):void
When called by an owner, setUserRole() sets the role of the specified user with respect to this baton.
Baton
  
subscribe():void
Tells the component to begin synchronizing with the service.
Baton
Events
 EventSummaryDefined by
   Dispatched when the baton is given to someone or put down.Baton
   Dispatched when the component has fully connected and synchronized with the service or when it loses the connection.Baton
Property detail
accessModelproperty
accessModel:int  [read-write]

Role value which is required for seeing the baton

Implementation
    public function get accessModel():int
    public function set accessModel(value:int):void
amIHoldingproperty 
amIHolding:Boolean  [read-only]

Determines whether the current user is holding the baton.

Implementation
    public function get amIHolding():Boolean
availableproperty 
available:Boolean  [read-only]

Determines whether the baton is up for grabs because it has no current holder.

Implementation
    public function get available():Boolean
canIAdministerproperty 
canIAdminister:Boolean  [read-only]

Determines whether the current user has permission to administer the baton by taking it from someone or forcing them to put it down.

Implementation
    public function get canIAdminister():Boolean
canIGrabproperty 
canIGrab:Boolean  [read-only]

Determines whether the current user has permission to grab the baton when available.

Implementation
    public function get canIGrab():Boolean
collectionNodeproperty 
collectionNode:CollectionNode  [read-write]

Sets the Collection Node to which the shared property subscribes/publishes

Implementation
    public function get collectionNode():CollectionNode
    public function set collectionNode(value:CollectionNode):void
connectSessionproperty 
connectSession:IConnectSession  [read-write]

The IConnectSession with which this component is associated. Note that this may only be set once before subscribe is called; re-sessioning of components is not supported. Defaults to the first IConnectSession created in the application.

Implementation
    public function get connectSession():IConnectSession
    public function set connectSession(value:IConnectSession):void
grabbableproperty 
grabbable:Boolean  [read-write]

Whether or not to allow users with a publisher role to grab an available baton. When false, the baton can only be handed off by users with an owner role.

Implementation
    public function get grabbable():Boolean
    public function set grabbable(value:Boolean):void
holderIDproperty 
holderID:String  [read-only]

Specifies the userID of the person controlling the baton. Returns null if noone has the baton. For example, this function might be used to create a "controlled by XXX" tooltip for your component.

Implementation
    public function get holderID():String
isSynchronizedproperty 
isSynchronized:Boolean  [read-only]

Determines whether the component has connected to the server and has fully synchronized.

This property can be used as the source for data binding.

Implementation
    public function get isSynchronized():Boolean

See also

com.adobe.rtc.messaging.CollectionNode
nodeNameproperty 
nodeName:String  [read-write]

Sets the Node Name to which the value is published

Implementation
    public function get nodeName():String
    public function set nodeName(value:String):void
publishModelproperty 
publishModel:int  [read-write]

Role Value required to grab the baton

Implementation
    public function get publishModel():int
    public function set publishModel(value:int):void
sharedIDproperty 
sharedID:String  [read-write]

Defines the logical location of the component on the service - typically this assigns the sharedID of the collectionNode used by the component. sharedIDs should be unique within a room (if they're expressing 2 unique locations). Note that this can only be assigned once (before subscribe() is called). For components with an id property, sharedID defaults to that value.

Implementation
    public function get sharedID():String
    public function set sharedID(value:String):void
timeOutproperty 
timeOut:int  [read-write]

Number of seconds after which the baton times out If 0, no timeout is used.

Implementation
    public function get timeOut():int
    public function set timeOut(value:int):void
Constructor detail
Baton()constructor
public function Baton()

Constructor.

Method detail
canUserAdminister()method
public function canUserAdminister(p_userID:String):Boolean

Determines whether a specified user can administer the baton from others.

Parameters
p_userID:String — The userID of the user to check if they have adminstrator rights.

Returns
Boolean
canUserGrab()method 
public function canUserGrab(p_userID:String):Boolean

Determines whether a specified user can grab the baton if it's available.

Parameters
p_userID:String — The userID of the user to check if they can grab the baton.

Returns
Boolean
close()method 
public function close():void

Cleans up all networking and event handling; recommended for garbage collection.

extendTimer()method 
public function extendTimer():void

Extends the timeout if the baton has one.

getNodeConfiguration()method 
public function getNodeConfiguration():NodeConfiguration

Gets the NodeConfiguration of the Baton Node.

Returns
NodeConfiguration
getUserRole()method 
public function getUserRole(p_userID:String):int

Returns the role of a given user for the baton.

Parameters
p_userID:String — UserID of the user in question

Returns
int
giveTo()method 
public function giveTo(p_userID:String):void

If the baton is grabbable, the holding user can hand the baton to a specified user. A user with an owner role can give a baton to anyone with the required permissions at any time.

Parameters
p_userID:String — The userID of the user to allow to grab the baton.
grab()method 
public function grab():void

If grabbable, users with a publisher role can grab the control if it's available by using this method. Users with an owner role may grab the baton at any time.

putDown()method 
public function putDown():void

Users with an publisher role in control can use this method to release their control. Users with an owner role can use this method to remove the baton from a user who has it.

setNodeConfiguration()method 
public function setNodeConfiguration(p_nodeConfiguration:NodeConfiguration):void

Sets the NodeConfiguration on the baton node.

Parameters
p_nodeConfiguration:NodeConfiguration — The node Configuration of the baton node to be set.
setUserRole()method 
public function setUserRole(p_userID:String, p_role:Number):void

When called by an owner, setUserRole() sets the role of the specified user with respect to this baton. The following rules apply:

Parameters
p_userID:String — The userID of the user to set the role for.
 
p_role:Number — The new role for that user.
subscribe()method 
public function subscribe():void

Tells the component to begin synchronizing with the service. For "headless" components such as this one, this method must be called explicitly.

Event detail
batonHolderChangeevent 
Event object type: com.adobe.rtc.events.SharedModelEvent

Dispatched when the baton is given to someone or put down.

synchronizationChangeevent  
Event object type: com.adobe.rtc.events.CollectionNodeEvent

Dispatched when the component has fully connected and synchronized with the service or when it loses the connection.





 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/labs/acrobatcom/com/adobe/rtc/sharedModel/Baton.html