Advertisement
Guest User

Multiplayer Class

a guest
Jun 27th, 2016
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.69 KB | None | 0 0
  1. public class Multiplayer {
  2.  
  3.     public Client client;
  4.     public static final String ip = "localhost";
  5.     public static final int tcpPort = 32000, udpPort = 32556;
  6.     public static boolean messageRecieved = false;
  7.  
  8.     public Multiplayer() {
  9.         try {
  10.             client = new Client();
  11.             register();
  12.  
  13.             NetworkListener nl = new NetworkListener();
  14.             nl.init(client);
  15.             client.addListener(nl);
  16.  
  17.             client.start();
  18.             client.connect(5000, ip, tcpPort, udpPort);
  19.         } catch (IOException e) {
  20.             e.printStackTrace();
  21.             client.stop();
  22.         }
  23.     }
  24.  
  25.     private synchronized void register() {
  26.         Kryo kryo = new Kryo();
  27.         kryo.register(Packet00LoginRequest.class);
  28.         kryo.register(Packet01LoginAnswer.class);
  29.     }
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement