Sending messages to other clients in client connect event <Solved>

<SOLVED - See end for statement>



I have been having some trouble with my code. I have a server that the clients connect to. On connecting I listen for a clientConnect message on the server and send some information over to the connecting client using a normal send. I then try to notify the other clients connected that there is a new one. This is where I have run into problems. If I try and broadcaseExcept (or loop through the clients and use send) it breaks the message sending to all previously connected clients (the new one is fine). There is still a connection (the new client can see the graphics sent from the old ones and the old clients can send messages out) it is just the old clients no longer receive any new messages.



[java]

public void clientConnected(final Client client) {



try {



//add the items to our server

Box b = new Box(Vector3f.ZERO, 1, 1, 1);

final Geometry geom = new Geometry(String.valueOf(client.getPlayerID()), b);

geom.updateModelBound();



Material mat = new Material(assetManager, “Common/MatDefs/Misc/SolidColor.j3md”);

mat.setColor(“m_Color”, ColorRGBA.Blue);

geom.setMaterial(mat);



// Create a appropriate physical shape for it

CapsuleCollisionShape capsuleShape = new CapsuleCollisionShape(1.5f, 6f, 1);

final CharacterControl cc = new CharacterControl(capsuleShape, 0.1f);

cc.setFallSpeed(0);

cc.setGravity(0);

geom.addControl(new PlayerControl(cc));

geom.addControl(cc);



Future fut = enqueue(new Callable() {

public List<String> call() throws Exception {

List<String> ss = new ArrayList<String>();

rootNode.attachChild(geom);

bulletAppState.getPhysicsSpace().add(cc);



for (Spatial s : rootNode.getChildren()) {

ss.add(s.getName());

}

return ss;

}

});



try {

List<String> strings = (List<String>)fut.get();



ConnectedMessage sm = new ConnectedMessage(getServerTimeInMilis());

sm.setItems(strings);

System.out.println(String.format(“Server connecting at %d”, getServerTimeInMilis()));



//send a message detailing the current dynamic items on the server

client.send(sm);



//broadcast to the other clients that this one has just been added

PlayerConnectedMessage pcm =

new PlayerConnectedMessage(getServerTimeInMilis(), geom.getName());

myServer.broadcastExcept(client, pcm);



} catch (InterruptedException e) {

System.out.println(e.getLocalizedMessage());

} catch (ConcurrentModificationException e) {

System.out.println(e.getLocalizedMessage());

} catch (ExecutionException e) {

System.out.println(e.getLocalizedMessage());

}

} catch (IOException e) {

System.out.println(e.getLocalizedMessage());

}

}





[/java]



Is this the correct behaviour (i.e. am I using it wrong?) If not I will happily debug it, but don’t want to spend the time doing this if it is user error!



Thanks,



Matt



EDIT: The problem was, as expected, all my side. I had not designated my PlayerConnectedMessage as serializable. Sorry for wasting peoples time!