hi, I'm working on a world server.
I'm sturgeling with getting player's already online and show them.
What I now do is create a worldsendThread (a listener for movement and connecting) and add it to a
then in the
1 2 3
| public worldsendThread(Socket client){ } |
Here is the actual code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| private Socket client; public static PrintWriter out; public static BufferedReader in; public WorldSendThread(Socket worldClient){ this.client = worldClient; RealmWorldServer.clients.addThread(this); } @Override public void run(){ try { out = new PrintWriter(client.getOutputStream(),true); in = new BufferedReader(new InputStreamReader(client.getInputStream())); String line = ""; while ((line = in.readLine()) != null){ System.out.println(line); Scanner sc = new Scanner(line); RealmWorldServer.clients.sendMessage("create player X 200 Y 200"); }
out.close(); in.close(); } catch (IOException e) { e.printStackTrace(); } } public void sendMessage(String message){ out.println(message); } |
The problem is with this code, when I connect It draws a player without anyone else being that player.
Anybode knows how to solve this?
Thanks!