Android Open Source - non network






From Project

Back to project page non.

License

The source code is released under:

MIT License

If you think the Android project non listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package non.plugins;
//from   ww w  .j av a2  s  . co  m
import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryonet.Connection;
import com.esotericsoftware.kryonet.Client;
import com.esotericsoftware.kryonet.Server;
import com.esotericsoftware.kryonet.EndPoint;
import com.esotericsoftware.kryonet.Listener;

import non.Non;
import non.NonBuffer;

public class network extends Plugin {
    public String author()      { return "Thomas Slusny"; }
    public String license()     { return "MIT"; }
    public String description() { return "Simple networking plugin."; }
    
    public class ScriptListener extends Listener {
        public void connected (Connection connection) {
            Non.script.invoke("network", "connected", connection);
        }
        
        public void received (Connection connection, Object object) {
            if (!(object instanceof byte[])) return;
            Non.script.invoke("network", "received", connection, (byte[])object);
        }

        public void disconnected (Connection connection) {
            Non.script.invoke("network", "disconnected", connection);
        }
    }
    
    public Object connected, disconnected, received;
    
    public Client client() { 
        Client client = new Client();
        register(client);
        client.addListener(new ScriptListener());
        
        return client;
    }
    
    public Server server() { 
        Server server = new Server();
        register(server);
        server.addListener(new ScriptListener());

        return server;
    }
    
    private void register (EndPoint endPoint) {
        Kryo kryo = endPoint.getKryo();
        kryo.register(byte[].class);
    }
}




Java Source Code List

%PACKAGE%.android.AndroidLauncher.java
%PACKAGE%.desktop.DesktopLauncher.java
%PACKAGE%.ios.IOSLauncher.java
launcher.Main.java
non.InputHandle.java
non.Line.java
non.NonBuffer.java
non.Non.java
non.Quad.java
non.languages.Language.java
non.languages.javascript.java
non.languages.lua.java
non.plugins.Plugin.java
non.plugins.audio.java
non.plugins.graphics.java
non.plugins.input.java
non.plugins.lights.java
non.plugins.math.java
non.plugins.network.java
non.plugins.non.java
non.plugins.physics.java