Package org.jgroups.demos
Class Draw
- java.lang.Object
-
- org.jgroups.ExtendedReceiverAdapter
-
- org.jgroups.demos.Draw
-
- All Implemented Interfaces:
java.awt.event.ActionListener,java.util.EventListener,ChannelListener,ExtendedMembershipListener,ExtendedMessageListener,ExtendedReceiver,MembershipListener,MessageListener,Receiver
public class Draw extends ExtendedReceiverAdapter implements java.awt.event.ActionListener, ChannelListener
Shared whiteboard, each new instance joins the same group. Each instance chooses a random color, mouse moves are broadcast to all group members, which then apply them to their canvas- Author:
- Bela Ban, Oct 17 2001
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactionPerformed(java.awt.event.ActionEvent e)voidblock()Called (usually by the FLUSH protocol), as an indication that the member should stop sending messages.voidchannelClosed(Channel channel)voidchannelConnected(Channel channel)voidchannelDisconnected(Channel channel)voidchannelReconnected(Address addr)voidchannelShunned()voidclearPanel()java.lang.StringgetGroupName()byte[]getState()Answers the group state; e.g., when joining.voidgetState(java.io.OutputStream ostream)Allows an application to write a state through a provided OutputStream.voidgo()static voidmain(java.lang.String[] args)voidreceive(Message msg)Called when a message is received.voidsendClearPanelMsg()voidsetGroupName(java.lang.String groupname)voidsetState(byte[] state)Sets the group state; e.g., when joining.voidsetState(java.io.InputStream istream)Allows an application to read a state through a provided InputStream.voidstop()voidunblock()Called after the FLUSH protocol has unblocked previously blocked senders, and messages can be sent again.voidviewAccepted(View v)Called when a change in membership has occurred.
-
-
-
Constructor Detail
-
Draw
public Draw(java.lang.String props, boolean no_channel, boolean jmx, boolean use_state, long state_timeout, boolean use_blocking, boolean use_unicasts) throws java.lang.Exception- Throws:
java.lang.Exception
-
Draw
public Draw(Channel channel) throws java.lang.Exception
- Throws:
java.lang.Exception
-
Draw
public Draw(Channel channel, boolean use_state, long state_timeout) throws java.lang.Exception
- Throws:
java.lang.Exception
-
-
Method Detail
-
getGroupName
public java.lang.String getGroupName()
-
setGroupName
public void setGroupName(java.lang.String groupname)
-
main
public static void main(java.lang.String[] args)
-
go
public void go() throws java.lang.Exception- Throws:
java.lang.Exception
-
receive
public void receive(Message msg)
Description copied from interface:MessageListenerCalled when a message is received.- Specified by:
receivein interfaceMessageListener- Overrides:
receivein classExtendedReceiverAdapter
-
viewAccepted
public void viewAccepted(View v)
Description copied from interface:MembershipListenerCalled when a change in membership has occurred. No long running actions or sending of messages should be done in this callback. If some long running action needs to be performed, it should be done in a separate thread. Note that on reception of the first view (a new member just joined), the channel will not yet be in the connected state. This only happens whenChannel.connect(String)returns.- Specified by:
viewAcceptedin interfaceMembershipListener- Overrides:
viewAcceptedin classExtendedReceiverAdapter
-
block
public void block()
Description copied from interface:MembershipListenerCalled (usually by the FLUSH protocol), as an indication that the member should stop sending messages. Any messages sent after returning from this callback might get blocked by the FLUSH protocol. When the FLUSH protocol is done, and messages can be sent again, the FLUSH protocol will simply unblock all pending messages. If a callback for unblocking is desired, implementExtendedMembershipListener.unblock(). Note that block() is the equivalent of reception of a BlockEvent in the pull mode.- Specified by:
blockin interfaceMembershipListener- Overrides:
blockin classExtendedReceiverAdapter
-
unblock
public void unblock()
Description copied from interface:ExtendedMembershipListenerCalled after the FLUSH protocol has unblocked previously blocked senders, and messages can be sent again. This callback only needs to be implemented if we require a notification of that.- Specified by:
unblockin interfaceExtendedMembershipListener- Overrides:
unblockin classExtendedReceiverAdapter
-
getState
public byte[] getState()
Description copied from interface:MessageListenerAnswers the group state; e.g., when joining.- Specified by:
getStatein interfaceMessageListener- Overrides:
getStatein classExtendedReceiverAdapter- Returns:
- byte[]
-
setState
public void setState(byte[] state)
Description copied from interface:MessageListenerSets the group state; e.g., when joining.- Specified by:
setStatein interfaceMessageListener- Overrides:
setStatein classExtendedReceiverAdapter
-
getState
public void getState(java.io.OutputStream ostream)
Description copied from interface:ExtendedMessageListenerAllows an application to write a state through a provided OutputStream. An application is obligated to always close the given OutputStream reference.- Specified by:
getStatein interfaceExtendedMessageListener- Overrides:
getStatein classExtendedReceiverAdapter- Parameters:
ostream- the OutputStream- See Also:
OutputStream.close()
-
setState
public void setState(java.io.InputStream istream)
Description copied from interface:ExtendedMessageListenerAllows an application to read a state through a provided InputStream. An application is obligated to always close the given InputStream reference.- Specified by:
setStatein interfaceExtendedMessageListener- Overrides:
setStatein classExtendedReceiverAdapter- Parameters:
istream- the InputStream- See Also:
InputStream.close()
-
clearPanel
public void clearPanel()
-
sendClearPanelMsg
public void sendClearPanelMsg()
-
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent e)
- Specified by:
actionPerformedin interfacejava.awt.event.ActionListener
-
stop
public void stop()
-
channelConnected
public void channelConnected(Channel channel)
- Specified by:
channelConnectedin interfaceChannelListener
-
channelDisconnected
public void channelDisconnected(Channel channel)
- Specified by:
channelDisconnectedin interfaceChannelListener
-
channelClosed
public void channelClosed(Channel channel)
- Specified by:
channelClosedin interfaceChannelListener
-
channelShunned
public void channelShunned()
- Specified by:
channelShunnedin interfaceChannelListener
-
channelReconnected
public void channelReconnected(Address addr)
- Specified by:
channelReconnectedin interfaceChannelListener
-
-