Skip to content

Commit

Permalink
Draw: overriding receive(Message)
Browse files Browse the repository at this point in the history
  • Loading branch information
belaban committed Feb 25, 2016
1 parent 40af083 commit 9867c16
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 26 deletions.
48 changes: 22 additions & 26 deletions src/org/jgroups/demos/Draw.java
Expand Up @@ -6,7 +6,6 @@
import org.jgroups.*; import org.jgroups.*;
import org.jgroups.jmx.JmxConfigurator; import org.jgroups.jmx.JmxConfigurator;
import org.jgroups.stack.AddressGenerator; import org.jgroups.stack.AddressGenerator;
import org.jgroups.util.MessageBatch;
import org.jgroups.util.OneTimeAddressGenerator; import org.jgroups.util.OneTimeAddressGenerator;
import org.jgroups.util.Util; import org.jgroups.util.Util;


Expand Down Expand Up @@ -249,34 +248,31 @@ void setTitle() {
setTitle(null); setTitle(null);
} }


public void receive(Message msg) {
byte[] buf=msg.getRawBuffer();
if(buf == null) {
System.err.printf("%s: received null buffer from %s, headers: %s\n", channel.getAddress(), msg.src(), msg.printHeaders());
return;
}


public void receive(MessageBatch batch) { try {
for(Message msg: batch) { DrawCommand comm=(DrawCommand)Util.streamableFromByteBuffer(DrawCommand.class, buf, msg.getOffset(), msg.getLength());
byte[] buf=msg.getRawBuffer(); switch(comm.mode) {
if(buf == null) { case DrawCommand.DRAW:
System.err.printf("%s: received null buffer from %s, headers: %s\n", channel.getAddress(), msg.src(), msg.printHeaders()); if(panel != null)
continue; panel.drawPoint(comm);
} break;

case DrawCommand.CLEAR:
try { clearPanel();
DrawCommand comm=(DrawCommand)Util.streamableFromByteBuffer(DrawCommand.class, buf, msg.getOffset(), msg.getLength()); break;
switch(comm.mode) { default:
case DrawCommand.DRAW: System.err.println("***** received invalid draw command " + comm.mode);
if(panel != null) break;
panel.drawPoint(comm);
break;
case DrawCommand.CLEAR:
clearPanel();
break;
default:
System.err.println("***** received invalid draw command " + comm.mode);
break;
}
}
catch(Exception e) {
e.printStackTrace();
} }
} }
catch(Exception e) {
e.printStackTrace();
}
} }


public void viewAccepted(View v) { public void viewAccepted(View v) {
Expand Down
23 changes: 23 additions & 0 deletions tests/junit-functional/org/jgroups/protocols/ECRYPTTest.java
@@ -0,0 +1,23 @@
package org.jgroups.protocols;

import org.jgroups.Global;
import org.jgroups.JChannel;
import org.testng.annotations.Test;

/**
* @author Bela Ban
* @since 4.0
*/
@Test(groups=Global.FUNCTIONAL,singleThreaded=true)
public class ECRYPTTest {
protected JChannel a,b,c,rogue;

protected void init() {
a=create("A");
}


protected JChannel create(String name) {
return null;
}
}

0 comments on commit 9867c16

Please sign in to comment.