Package com.esotericsoftware.kryonet

Examples of com.esotericsoftware.kryonet.Listener$QueuedListener


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

    startEndPoint(server);
    server.bind(tcpPort, udpPort);
    server.addListener(new Listener() {
      public void connected (Connection connection) {
        data.stuff[3] = 4;
        server.sendToAllTCP(data);

        data.stuff[3] = 123;
        connection.sendTCP(data);

        data.stuff[3] = 125;
        connection.sendTCP(data);

        data.stuff[3] = 127;
        SomeOtherData someOtherData = new SomeOtherData();
        someOtherData.data = data; // This child object will be delta compressed.
        someOtherData.text = "abcdefghijklmnop";
        connection.sendTCP(someOtherData);
      }

      public void received (Connection connection, Object object) {
      }
    });

    // ----

    Client client = new Client();
    register(client.getKryo());
    startEndPoint(client);
    client.addListener(new Listener() {
      public void received (Connection connection, Object object) {
        if (object instanceof SomeData) {
          SomeData data = (SomeData)object;
          System.out.println(data.stuff[3]);
        } else if (object instanceof SomeOtherData) {
View Full Code Here


    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);
      }
    });

    // ----

    final Client client = new Client();
    register(client.getKryo());
    startEndPoint(client);
    client.addListener(new Listener() {
      public void received (Connection connection, Object object) {
        if (object instanceof SomeData) {
          SomeData data = (SomeData)object;
          System.out.println(data.stuff[3]);
        } else if (object instanceof ArrayList) {
View Full Code Here

    public RemoteInvocationHandler (Connection connection, final int objectID) {
      super();
      this.connection = connection;
      this.objectID = objectID;

      responseListener = new Listener() {
        public void received (Connection connection, Object object) {
          if (!(object instanceof InvokeMethodResult)) return;
          InvokeMethodResult invokeMethodResult = (InvokeMethodResult)object;
          if (invokeMethodResult.objectID != objectID) return;
          synchronized (responseQueue) {
View Full Code Here

    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);
      }

      public void received (Connection connection, Object object) {
        if (!(object instanceof MessageWithTestObject)) return;
        MessageWithTestObject m = (MessageWithTestObject)object;
        System.out.println(serverTestObject.value);
        System.out.println(((TestObjectImpl)m.testObject).value);
        assertEquals(4321f, m.testObject.other());
        stopEndPoints(2000);
      }
    });

    // ----

    Client client = new Client();
    register(client.getKryo());

    ObjectSpace clientObjectSpace = new ObjectSpace(client);
    final TestObjectImpl clientTestObject = new TestObjectImpl(1234);
    clientObjectSpace.register((short)12, clientTestObject);

    startEndPoint(client);
    client.addListener(new Listener() {
      public void connected (final Connection connection) {
        RmiTest.runTest(connection, 42, 4321);
      }

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

    // For consistency, the classes to be sent over the network are
    // registered by the same method for both the client and server.
    Network.register(server);

    server.addListener(new Listener() {
      public void received (Connection c, Object object) {
        // We know all connections for this server are actually CharacterConnections.
        CharacterConnection connection = (CharacterConnection)c;
        Character character = connection.character;
View Full Code Here

    // For consistency, the classes to be sent over the network are
    // registered by the same method for both the client and server.
    Network.register(client);

    // ThreadedListener runs the listener methods on a different thread.
    client.addListener(new ThreadedListener(new Listener() {
      public void connected (Connection connection) {
      }

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

    // For consistency, the classes to be sent over the network are
    // registered by the same method for both the client and server.
    Network.register(client);

    client.addListener(new Listener() {
      public void connected (Connection connection) {
        RegisterName registerName = new RegisterName();
        registerName.name = "meow";
        client.sendTCP(registerName);
      }
View Full Code Here

    // Get the Player on the other end of the connection.
    // This allows the client to call methods on the server.
    player = ObjectSpace.getRemoteObject(client, Network.PLAYER, IPlayer.class);

    client.addListener(new Listener() {
      public void disconnected (Connection connection) {
        EventQueue.invokeLater(new Runnable() {
          public void run () {
            // Closing the frame calls the close listener which will stop the client's update thread.
            chatFrame.dispose();
View Full Code Here

     
      // For consistency, the classes to be sent over the network are
        // registered by the same method for both the client and server.
        Network.register(server);
       
        server.addListener(new Listener() {
            public void received (Connection c, Object object) {
                // We know all connections for this server are actually ChatConnections.
              WarTugConnection connection = (WarTugConnection)c;

                if (object instanceof RegisterName) {
View Full Code Here

     
      // For consistency, the classes to be sent over the network are
        // registered by the same method for both the client and server.
        Network.register(server);
       
        server.addListener(new Listener() {
            public void received (Connection c, Object object) {
                // We know all connections for this server are actually ChatConnections.
              WarTugConnection connection = (WarTugConnection)c;

                if (object instanceof RegisterName) {
View Full Code Here

TOP

Related Classes of com.esotericsoftware.kryonet.Listener$QueuedListener

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.