Problem with object modifications not sending over network

The variables are not the same for some reason.

Here is where I receive the object:


			if(omsg instanceof ServerPlayerStateMessage){
				ServerPlayerStateMessage msg = (ServerPlayerStateMessage) omsg;
				for(int i=0; i<msg.players.length; i++){
					PlayerModel newModel = msg.players[i];

					PlayerModel oldModel = playerManager.getByID(newModel.clientID);
					
					
					if(oldModel != null){
						oldModel.setTilePos(newModel.tileX,newModel.tileY);
					}

				}
			}

Here is where I send:


				if(msg instanceof ClientMoveMessage){
					System.out.println("Client move msg");
					
					ClientMoveMessage msg2 = (ClientMoveMessage) msg;
					
					cThread1.getPlayerModel().setTilePos(msg2.tileX, msg2.tileY);
				}



	public void sendPlayerStates(){
		ArrayList<PlayerModel> playerModels = new ArrayList<PlayerModel>();
		
		for(int i=0; i<cThreads.size(); i++){
			ClientThread t = cThreads.get(i);
			playerModels.add(t.getPlayerModel());
		}
		
			
		ServerPlayerStateMessage msg = new ServerPlayerStateMessage();
		
		msg.players = new PlayerModel[playerModels.size()];
		
		msg.players = playerModels.toArray(msg.players);
		
		broadcast(msg);
			
	}

Here is the actual objectoutputstream writing:


	public void sendAll() {
		if(socket.isConnected()){
			Object msg = null;
			while((msg = outQueue.poll()) != null){
				try {
					out.writeUnshared(msg);
					out.flush();
					out.reset();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}
	}


public class ServerPlayerStateMessage implements Serializable {
	
	public PlayerModel[] players;
}



public class PlayerModel implements Serializable {
	
	//Owner of this player model
	public int clientID;
	public int tileX;
	public int tileY;
	
	public void setTilePos(int tileX, int tileY){
		this.tileX = tileX;
		this.tileY = tileY;
	}
	
}


I bet it’s a protocol mistake.

Maybe it’s a logical problem and oldModel is actually null, you should add asserts or debugging print statements.

okay as I was writing this message I found the error. My objectoutputstream thread for writing had 2 class files because I moved it at some point. I made the modification to reset the stream to the wrong file! Darn