[Spread-users] getMembershipInfo() from java

John de la Garza john at jjdev.com
Thu Mar 27 22:45:22 EDT 2008


I'm new to spread and trying to write some demo code.  I can't get  
getMembershipInfo() to return to me anything but null.  Am I doing  
something wrong?

Here is what I'm doing:
-----

import spread.*;
import java.net.*;

//public class Flooder extends Thread implements AdvancedMessageListener
public class Sender
{
     public static void main(String[] args)
     {
         try{
             SpreadConnection conn = new SpreadConnection();
             conn.connect(InetAddress.getByName("localhost"), 4803,  
"tester", false, false);
             SpreadGroup group = new SpreadGroup();
             group.join(conn, "mygroup");
             SpreadMessage msg = new SpreadMessage();
             String str1 = "Hello User";
             byte[] b = str1.getBytes();
             msg.setData(b);
             msg.addGroup("mygroup");
             msg.setReliable();
             conn.multicast(msg);
             if(conn!=null){
             System.out.println("wait for message");
               msg = conn.receive();
             }
             System.out.println("New membership message from " +  
msg.getMembershipInfo());//.getGroup());
             System.out.print("Message=" + new String(msg.getData()));
             conn.disconnect();
     } catch(Exception e) {
         e.printStackTrace();
     }

         System.out.println("done");
     }
}





More information about the Spread-users mailing list