I have LibGDX Application in which I paint and a Thread for Client or Server. Connections are done using Kryonet. When your opponent creates does something a message is recieved linke so:
public void received(Connection con, Object object) {
TroopMessage tm = (TroopMessage)object;
fortress.map.addSoldier(tm.kind, true);
System.out.println("recieved");
connection = con;
}
When this callback is called (and it is correctly) I get "No OpenGL context found in the current thread". I think it is looking for the object fortress within the MyClient Thread. I want to call to fortress.map.addSoldier which refers to an object currently existing in another thread.
public class Fortress extends Game implements ApplicationListener{
private OrthographicCamera camera;
private SpriteBatch batcher;
public static MyServer server;
public static MyClient client;
public static Map map;
[....]
How can I call the method in from another thread?
thanks in advance
Object
does not belong to or exist in a specific thread, so that is not the problem here. – Dessiedessma