com.esotericsoftware.kryonet.Server Java Examples
The following examples show how to use
com.esotericsoftware.kryonet.Server.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ServerConnection.java From RuinsOfRevenge with MIT License | 6 votes |
public ServerConnection(ServerMaster master, int tcpPort, int udpPort) throws IOException { this.master = master; this.server = new Server(); this.queue = new LinkedBlockingQueue<>(); this.connectedClients = new ObjectMap<>(); Register.registerAll(server.getKryo()); server.start(); server.bind(tcpPort, udpPort); server.addListener(new QueuedListener(this) { @Override protected void queue(Runnable runnable) { queue.add(runnable); } }); }
Example #2
Source File: LobbyScreen.java From killingspree with MIT License | 5 votes |
public void setServer(boolean isServer) { this.isServer = isServer; try { if (isServer) { server = new Server(); NetworkRegisterer.register(server); serverListener = new LobbyServerListener(); server.addListener(serverListener); server.start(); server.bind(Constants.DISCOVERY_TCP_PORT, Constants.DISCOVERY_UDP_PORT); // Thread.currentThread().sleep(200); } client = new Client(); NetworkRegisterer.register(client); client.start(); clientListener = new LobbyClientListener(); client.addListener(clientListener); client.connect(5000, host, Constants.DISCOVERY_TCP_PORT, Constants.DISCOVERY_UDP_PORT); } catch (Exception e) { currentButton = backButton; markForDispose = true; e.printStackTrace(); } addAllButtons(); }
Example #3
Source File: GameScreen.java From killingspree with MIT License | 5 votes |
public void startServer(boolean lonely) { isServer = true; if (!lonely) { server = new Server(); NetworkRegisterer.register(server); server.start(); try { server.bind(Constants.GAME_TCP_PORT, Constants.GAME_UDP_PORT); } catch (Exception e) { e.printStackTrace(); } } }
Example #4
Source File: NetServer.java From gdx-proto with Apache License 2.0 | 5 votes |
public NetServer() { clientMap = new ObjectMap<>(); server = new Server(NetManager.writeBufferSize, NetManager.objectBufferSize); NetManager.registerKryoClasses(server.getKryo()); try { server.bind(NetManager.tcpPort, NetManager.udpPort); server.start(); server.addListener(createListener(simulateLag)); Log.debug("server is listening at: " + NetManager.host + ":" + NetManager.tcpPort); } catch (IOException e) { Log.error(e.toString()); throw new GdxRuntimeException(e); } }
Example #5
Source File: BenchServer.java From rpc-bench with Apache License 2.0 | 4 votes |
public BenchServer() { running = new AtomicBoolean(true); SigInt.register(() -> running.set(false)); server = new Server(WRITE_BUFFER, OBJECT_BUFFER); }
Example #6
Source File: WorldManager.java From killingspree with MIT License | 4 votes |
public WorldManager(final Server server){ i = 0; playerPositions = new ArrayList<Vector2>(); playerPositions.add(new Vector2(50,85)); playerPositions.add(new Vector2(395,85)); playerPositions.add(new Vector2(50,230)); playerPositions.add(new Vector2(395,230)); playerList = new ConcurrentHashMap<Integer, ServerPlayer>(); world = new World(new Vector2(0, -500f)); serverListener = new WorldManagerServerListener(); if (server != null) { server.addListener(serverListener); } this.server = server; entities = new ArrayList<ServerEntity>(); incomingEventQueue = new ArrayList<Event>(); outgoingEventQueue = new ArrayList<Event>(); dummyConnection = new MyConnection(); incomingEventQueue.add(MessageObjectPool.instance. eventPool.obtain().set(State.CONNECTED, null)); outgoingEventQueue.add(MessageObjectPool.instance. eventPool.obtain().set(State.CONNECTED, null)); audio = new AudioMessage(); worldBodyUtils = new WorldBodyUtils(worldManager); id = 0; // frog = new ServerFrog(id++, 20, 100, worldBodyUtils); // entities.add(frog); // fly = new ServerFly(id++, 20, 100, worldBodyUtils); // entities.add(fly); // blob = new ServerBlob(id++, 20, 100, worldBodyUtils); // entities.add(blob); if (server == null) loader = new LevelLoader("maps/retro-small.txt", this); }
Example #7
Source File: ServerConnection.java From RuinsOfRevenge with MIT License | 4 votes |
public Server getServer() { return server; }