Package com.esotericsoftware.kryonet

Examples of com.esotericsoftware.kryonet.Server


    this.manager = manager;

    // int buffere50mo = 52428800;
    int buffer1mo = 1024000;
    int bufferSize = buffer1mo;
    server = new Server(bufferSize, bufferSize);
    server.start();
    server.bind(portTCP, portTCP + 1);

    NetworkKryoInit init = new NetworkKryoInit();
    init.registerKryo(server.getKryo());
View Full Code Here


public class ChatRmiServer {
  Server server;
  ArrayList<Player> players = new ArrayList();

  public ChatRmiServer () throws IOException {
    server = new Server() {
      protected Connection newConnection () {
        // Each connection represents a player and has fields
        // to store state and methods to perform actions.
        Player player = new Player();
        players.add(player);
View Full Code Here

import com.esotericsoftware.kryonet.Listener;
import com.esotericsoftware.kryonet.Server;

public class RmiTest extends KryoNetTestCase {
  public void testRMI () throws IOException {
    Server server = new Server();
    register(server.getKryo());
    startEndPoint(server);
    server.bind(tcpPort);

    final ObjectSpace serverObjectSpace = new ObjectSpace();
    final TestObjectImpl serverTestObject = new TestObjectImpl(4321);
    serverObjectSpace.register((short)42, serverTestObject);

    server.addListener(new Listener() {
      public void connected (final Connection connection) {
        serverObjectSpace.addConnection(connection);
        runTest(connection, 12, 1234);
      }
View Full Code Here

public class ChatServer {
  Server server;

  public ChatServer () throws IOException {
    server = new Server() {
      protected Connection newConnection () {
        // By providing our own connection implementation, we can store per
        // connection state without a connection ID to state look up.
        return new ChatConnection();
      }
View Full Code Here

import com.esotericsoftware.kryonet.Listener;
import com.esotericsoftware.kryonet.Server;

public class DeflateTest extends KryoNetTestCase {
  public void testDeflate () throws IOException {
    final Server server = new Server();
    register(server.getKryo());

    final SomeData data = new SomeData();
    data.text = "some text here aaaaaaaaaabbbbbbbbbbbcccccccccc";
    data.stuff = new short[] {1, 2, 3, 4, 5, 6, 7, 8};

    final ArrayList a = new ArrayList();
    a.add(12);
    a.add(null);
    a.add(34);

    startEndPoint(server);
    server.bind(tcpPort, udpPort);
    server.addListener(new Listener() {
      public void connected (Connection connection) {
        server.sendToAllTCP(data);
        connection.sendTCP(data);
        connection.sendTCP(a);
      }
    });
View Full Code Here

public class PositionServer {
  Server server;
  HashSet<Character> loggedIn = new HashSet();

  public PositionServer () throws IOException {
    server = new Server() {
      protected Connection newConnection () {
        // By providing our own connection implementation, we can store per
        // connection state without a connection ID to state look up.
        return new CharacterConnection();
      }
View Full Code Here

public class RmiTest extends KryoNetTestCase {
  /** In this test both the client and server have an ObjectSpace that contains a TestObject. When the client connects, the same
   * test is run on both the client and server. The test excersizes a number of remote method calls and other features. */
  public void testRMI () throws IOException {
    Server server = new Server();
    Kryo serverKryo = server.getKryo();
    register(serverKryo);

    startEndPoint(server);
    server.bind(tcpPort, udpPort);

    final TestObjectImpl serverTestObject = new TestObjectImpl(4321);

    final ObjectSpace serverObjectSpace = new ObjectSpace();
    serverObjectSpace.register(42, serverTestObject);

    server.addListener(new Listener() {
      public void connected (final Connection connection) {
        serverObjectSpace.addConnection(connection);
        runTest(connection, 12, 1234);
      }

View Full Code Here

    waitForThreads();
  }

  public void testMany () throws IOException {
    Server server = new Server();
    Kryo serverKryo = server.getKryo();
    register(serverKryo);

    startEndPoint(server);
    server.bind(tcpPort);

    final TestObjectImpl serverTestObject = new TestObjectImpl(4321);

    final ObjectSpace serverObjectSpace = new ObjectSpace();
    serverObjectSpace.register(42, serverTestObject);

    server.addListener(new Listener() {
      public void connected (final Connection connection) {
        serverObjectSpace.addConnection(connection);
      }

      public void received (Connection connection, Object object) {
View Full Code Here

public class RmiSendObjectTest extends KryoNetTestCase {
  /** In this test the server has two objects in an object space. The client uses the first remote object to get the second remote
   * object. */
  public void testRMI () throws IOException {
    Server server = new Server();
    Kryo serverKryo = server.getKryo();
    register(serverKryo);

    // After all common registrations, register OtherObjectImpl only on the server using the remote object interface ID.
    // This causes OtherObjectImpl to be serialized as OtherObject.
    int otherObjectID = serverKryo.getRegistration(OtherObject.class).getId();
    serverKryo.register(OtherObjectImpl.class, new RemoteObjectSerializer(), otherObjectID);

    startEndPoint(server);
    server.bind(tcpPort);

    // TestObjectImpl has a reference to an OtherObjectImpl.
    final TestObjectImpl serverTestObject = new TestObjectImpl();
    serverTestObject.otherObject = new OtherObjectImpl();

    // Both objects must be registered with the ObjectSpace.
    final ObjectSpace serverObjectSpace = new ObjectSpace();
    serverObjectSpace.register(42, serverTestObject);
    serverObjectSpace.register(777, serverTestObject.getOtherObject());

    server.addListener(new Listener() {
      public void connected (final Connection connection) {
        // Allow the connection to access objects in the ObjectSpace.
        serverObjectSpace.addConnection(connection);
      }

View Full Code Here

    public boolean start() {
        LOG.log(Level.INFO, "[SERVER] Server startup initiated.");
        if (server != null) {
            return false;
        }
        server = new Server();

        KryoRegistration.register(server.getKryo());

        server.start();
View Full Code Here

TOP

Related Classes of com.esotericsoftware.kryonet.Server

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.