├── java
├── .idea
│ ├── .name
│ ├── scopes
│ │ └── scope_settings.xml
│ ├── encodings.xml
│ ├── vcs.xml
│ ├── gradle.xml
│ ├── modules.xml
│ ├── misc.xml
│ ├── compiler.xml
│ └── workspace.xml
├── settings.gradle
├── java.iml
├── client
│ ├── src
│ │ └── main
│ │ │ └── java
│ │ │ ├── log4j.properties
│ │ │ └── net
│ │ │ └── demo
│ │ │ └── client
│ │ │ ├── DemoClientPipelineFactory.java
│ │ │ ├── DemoClient.java
│ │ │ ├── DemoClientChannelHandler.java
│ │ │ └── ClientThread.java
│ └── client.iml
├── server
│ ├── src
│ │ └── main
│ │ │ └── java
│ │ │ ├── log4j.properties
│ │ │ └── net
│ │ │ └── demo
│ │ │ └── server
│ │ │ ├── DemoServerPipelineFactory.java
│ │ │ ├── DemoServer.java
│ │ │ └── DemoServerChannelHandler.java
│ └── server.iml
├── build.gradle
├── proto
│ ├── proto.iml
│ └── src
│ │ └── main
│ │ └── java
│ │ └── net
│ │ └── demo
│ │ └── proto
│ │ └── KVCommand.java
├── java.ipr
└── java.iws
├── CodeWriter.dll
├── CodeGenerator.exe
├── .gitignore
├── c#
└── Example
│ └── Assets
│ ├── demo.unity.meta
│ ├── Plugins.meta
│ ├── Plugins
│ ├── TNet.meta
│ ├── Message.meta
│ ├── TNet
│ │ ├── common.meta
│ │ ├── common
│ │ │ ├── Interface.meta
│ │ │ ├── Agent.cs.meta
│ │ │ ├── TNetMsg.cs.meta
│ │ │ ├── AgentHolder.cs.meta
│ │ │ ├── Singleton.cs.meta
│ │ │ ├── TNetReader.cs.meta
│ │ │ ├── TNetWriter.cs.meta
│ │ │ ├── Interface
│ │ │ │ ├── ITNetAdapter.cs.meta
│ │ │ │ ├── ITNetReader.cs.meta
│ │ │ │ ├── ITNetWriter.cs.meta
│ │ │ │ ├── ITNetWriter.cs
│ │ │ │ ├── ITNetAdapter.cs
│ │ │ │ └── ITNetReader.cs
│ │ │ ├── Singleton.cs
│ │ │ ├── TNetMsg.cs
│ │ │ ├── AgentHolder.cs
│ │ │ ├── TNetWriter.cs
│ │ │ ├── TNetReader.cs
│ │ │ └── Agent.cs
│ │ ├── Client.cs.meta
│ │ └── Client.cs
│ └── Message
│ │ ├── KVCommand.cs.meta
│ │ ├── ProtocolParser.cs.meta
│ │ ├── KVCommand.Serializer.cs.meta
│ │ ├── KVCommand.cs
│ │ └── ProtocolParser.cs
│ ├── Test.cs.meta
│ ├── TestAdapter.cs.meta
│ ├── Test.cs
│ ├── TestAdapter.cs
│ └── demo.unity
├── README.md
├── KVCommand.proto
└── py
├── c.py
├── s.py
└── KVCommand_pb2.py
/java/.idea/.name:
--------------------------------------------------------------------------------
1 | ProtoBufDemo
--------------------------------------------------------------------------------
/java/settings.gradle:
--------------------------------------------------------------------------------
1 | include ('proto', 'server', 'client')
2 |
--------------------------------------------------------------------------------
/CodeWriter.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lite/ProtobufDemo/master/CodeWriter.dll
--------------------------------------------------------------------------------
/CodeGenerator.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lite/ProtobufDemo/master/CodeGenerator.exe
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.pyc
2 | *.class
3 | java/log/
4 | java/out/
5 | java/*/build/
6 | java/build/
7 | java/.gradle/
--------------------------------------------------------------------------------
/c#/Example/Assets/demo.unity.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3ab4571fcf9e14bbcadf24102f70b51c
3 | DefaultImporter:
4 | userData:
5 |
--------------------------------------------------------------------------------
/c#/Example/Assets/Plugins.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 4e597ac849963433bac6c6007aa06c32
3 | folderAsset: yes
4 | DefaultImporter:
5 | userData:
6 |
--------------------------------------------------------------------------------
/c#/Example/Assets/Plugins/TNet.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 2eefd9b61eede4d159b65e85f4a2201e
3 | folderAsset: yes
4 | DefaultImporter:
5 | userData:
6 |
--------------------------------------------------------------------------------
/c#/Example/Assets/Plugins/Message.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 97d20b1f9817146d4936009727936b90
3 | folderAsset: yes
4 | DefaultImporter:
5 | userData:
6 |
--------------------------------------------------------------------------------
/c#/Example/Assets/Plugins/TNet/common.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 34c7392e43c26475cbda76fb90855a17
3 | folderAsset: yes
4 | DefaultImporter:
5 | userData:
6 |
--------------------------------------------------------------------------------
/c#/Example/Assets/Plugins/TNet/common/Interface.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 1bbf4f617f03c407c8a4875ac2df717f
3 | folderAsset: yes
4 | DefaultImporter:
5 | userData:
6 |
--------------------------------------------------------------------------------
/java/.idea/scopes/scope_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/java/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/java/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/c#/Example/Assets/Test.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 09d6a8b5ec4c249ddb6016eb4292cdc7
3 | MonoImporter:
4 | serializedVersion: 2
5 | defaultReferences: []
6 | executionOrder: 0
7 | icon: {instanceID: 0}
8 | userData:
9 |
--------------------------------------------------------------------------------
/c#/Example/Assets/TestAdapter.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 5a61ed63a5fcf4b9d872efbca350b803
3 | MonoImporter:
4 | serializedVersion: 2
5 | defaultReferences: []
6 | executionOrder: 0
7 | icon: {instanceID: 0}
8 | userData:
9 |
--------------------------------------------------------------------------------
/java/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/c#/Example/Assets/Plugins/TNet/Client.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f61f1443d610a421da129398bcfc39b7
3 | MonoImporter:
4 | serializedVersion: 2
5 | defaultReferences: []
6 | executionOrder: 0
7 | icon: {instanceID: 0}
8 | userData:
9 |
--------------------------------------------------------------------------------
/c#/Example/Assets/Plugins/Message/KVCommand.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3e142732524e94fc6ba26e5b1883a967
3 | MonoImporter:
4 | serializedVersion: 2
5 | defaultReferences: []
6 | executionOrder: 0
7 | icon: {instanceID: 0}
8 | userData:
9 |
--------------------------------------------------------------------------------
/c#/Example/Assets/Plugins/TNet/common/Agent.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: bfdffbd1a4fa8422799941549f97ab06
3 | MonoImporter:
4 | serializedVersion: 2
5 | defaultReferences: []
6 | executionOrder: 0
7 | icon: {instanceID: 0}
8 | userData:
9 |
--------------------------------------------------------------------------------
/c#/Example/Assets/Plugins/TNet/common/TNetMsg.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: d8c9231963d7e47d5b6caffaf6fbf1c1
3 | MonoImporter:
4 | serializedVersion: 2
5 | defaultReferences: []
6 | executionOrder: 0
7 | icon: {instanceID: 0}
8 | userData:
9 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # protobuf
2 |
3 | java and python
4 |
5 | protoc --java_out=./java/proto/src/main/java/net/demo/proto/ --python_out=./py KVCommand.proto
6 |
7 | C#
8 |
9 | mono CodeGenerator.exe KVCommand.proto C#/KVCommand.cs
10 |
11 |
12 |
--------------------------------------------------------------------------------
/c#/Example/Assets/Plugins/Message/ProtocolParser.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 0d7b6ce09eb274bc7a1ed52ca8c3440c
3 | MonoImporter:
4 | serializedVersion: 2
5 | defaultReferences: []
6 | executionOrder: 0
7 | icon: {instanceID: 0}
8 | userData:
9 |
--------------------------------------------------------------------------------
/c#/Example/Assets/Plugins/TNet/common/AgentHolder.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 43a3e221f56a4447c8cd72537fe3923a
3 | MonoImporter:
4 | serializedVersion: 2
5 | defaultReferences: []
6 | executionOrder: 0
7 | icon: {instanceID: 0}
8 | userData:
9 |
--------------------------------------------------------------------------------
/c#/Example/Assets/Plugins/TNet/common/Singleton.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e55bfdb21cf1e44929a37828e94bb8ef
3 | MonoImporter:
4 | serializedVersion: 2
5 | defaultReferences: []
6 | executionOrder: 0
7 | icon: {instanceID: 0}
8 | userData:
9 |
--------------------------------------------------------------------------------
/c#/Example/Assets/Plugins/TNet/common/TNetReader.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b1520c46720844db6879d00543736c47
3 | MonoImporter:
4 | serializedVersion: 2
5 | defaultReferences: []
6 | executionOrder: 0
7 | icon: {instanceID: 0}
8 | userData:
9 |
--------------------------------------------------------------------------------
/c#/Example/Assets/Plugins/TNet/common/TNetWriter.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: c381d5ec812054c10906448c45e49c62
3 | MonoImporter:
4 | serializedVersion: 2
5 | defaultReferences: []
6 | executionOrder: 0
7 | icon: {instanceID: 0}
8 | userData:
9 |
--------------------------------------------------------------------------------
/c#/Example/Assets/Plugins/Message/KVCommand.Serializer.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 9ff7b2da5125945fcb13ff5034138d2b
3 | MonoImporter:
4 | serializedVersion: 2
5 | defaultReferences: []
6 | executionOrder: 0
7 | icon: {instanceID: 0}
8 | userData:
9 |
--------------------------------------------------------------------------------
/c#/Example/Assets/Plugins/TNet/common/Interface/ITNetAdapter.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 1f4ac4b7a3d364b759fed06ca508d64f
3 | MonoImporter:
4 | serializedVersion: 2
5 | defaultReferences: []
6 | executionOrder: 0
7 | icon: {instanceID: 0}
8 | userData:
9 |
--------------------------------------------------------------------------------
/c#/Example/Assets/Plugins/TNet/common/Interface/ITNetReader.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ea1ef9ec315a0453fb2595bd58fcea01
3 | MonoImporter:
4 | serializedVersion: 2
5 | defaultReferences: []
6 | executionOrder: 0
7 | icon: {instanceID: 0}
8 | userData:
9 |
--------------------------------------------------------------------------------
/c#/Example/Assets/Plugins/TNet/common/Interface/ITNetWriter.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: d0ea6ef2bfc194972bde62943321a58c
3 | MonoImporter:
4 | serializedVersion: 2
5 | defaultReferences: []
6 | executionOrder: 0
7 | icon: {instanceID: 0}
8 | userData:
9 |
--------------------------------------------------------------------------------
/java/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/java/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/c#/Example/Assets/Plugins/TNet/common/Interface/ITNetWriter.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Tunner Net - Data interception use ProtoBuf in game Development.
3 | e-mail : dongliang17@126.com
4 | project: https://github.com/dongliang/Tuner-Net
5 | */
6 | using System.IO;
7 | namespace Tuner.Net
8 | {
9 | public interface ITNetWriter
10 | {
11 | byte[] MakeStream(int msgID, MemoryStream data);
12 |
13 | void Reset();
14 | MemoryStream Serialize(T instance);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/c#/Example/Assets/Plugins/TNet/common/Singleton.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Tunner Net - Data interception use ProtoBuf in game Development.
3 | e-mail : dongliang17@126.com
4 | project: https://github.com/dongliang/Tuner-Net
5 | */
6 | namespace Tuner
7 | {
8 | public class Singleton where T : new()
9 | {
10 | protected Singleton() { }
11 | protected static T instance = new T();
12 | public static T Instance
13 | {
14 | get { return instance; }
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/java/java.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/java/client/src/main/java/log4j.properties:
--------------------------------------------------------------------------------
1 | log4j.rootLogger=DEBUG, stdout, stderr
2 |
3 | log4j.appender.stdout = org.apache.log4j.ConsoleAppender
4 | log4j.appender.stdout.Threshold = DEBUG
5 | log4j.appender.stdout.Target = System.out
6 | log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
7 | log4j.appender.stdout.layout.ConversionPattern = %-5p %d [%t][%F:%L] : %m%n
8 |
9 | log4j.appender.stderr = org.apache.log4j.ConsoleAppender
10 | log4j.appender.stderr.Threshold = WARN
11 | log4j.appender.stderr.Target = System.err
12 | log4j.appender.stderr.layout = org.apache.log4j.PatternLayout
13 | log4j.appender.stderr.layout.ConversionPattern = %-5p %d [%t][%F:%L] : %m%n
--------------------------------------------------------------------------------
/java/server/src/main/java/log4j.properties:
--------------------------------------------------------------------------------
1 | log4j.rootLogger=DEBUG, stdout, stderr
2 |
3 | log4j.appender.stdout = org.apache.log4j.ConsoleAppender
4 | log4j.appender.stdout.Threshold = DEBUG
5 | log4j.appender.stdout.Target = System.out
6 | log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
7 | log4j.appender.stdout.layout.ConversionPattern = %-5p %d [%t][%F:%L] : %m%n
8 |
9 | log4j.appender.stderr = org.apache.log4j.ConsoleAppender
10 | log4j.appender.stderr.Threshold = WARN
11 | log4j.appender.stderr.Target = System.err
12 | log4j.appender.stderr.layout = org.apache.log4j.PatternLayout
13 | log4j.appender.stderr.layout.ConversionPattern = %-5p %d [%t][%F:%L] : %m%n
--------------------------------------------------------------------------------
/c#/Example/Assets/Plugins/TNet/common/Interface/ITNetAdapter.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Tunner Net - Data interception use ProtoBuf in game Development.
3 | e-mail : dongliang17@126.com
4 | project: https://github.com/dongliang/Tuner-Net
5 | */
6 | namespace Tuner.Net
7 | {
8 | public delegate void CallBackEvtDel ();
9 | public interface ITNetAdapter
10 | {
11 | void HandleMsg (System.Object state, TNetMsg msg);
12 |
13 | ITNetWriter createMsgWriter ();
14 |
15 | ITNetReader createMsgReader ();
16 |
17 | void onConnected ();
18 |
19 | void onAccepted ();
20 |
21 | void onReConnected ();
22 |
23 | void onNetWorkFailed ();
24 |
25 | void onReConnectBegin ();
26 | }
27 | }
--------------------------------------------------------------------------------
/c#/Example/Assets/Plugins/TNet/common/Interface/ITNetReader.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Tunner Net - Data interception use ProtoBuf in game Development.
3 | e-mail : dongliang17@126.com
4 | project: https://github.com/dongliang/Tuner-Net
5 | */
6 | namespace Tuner.Net
7 | {
8 | public delegate void HandleMsgDel (System.Object state,TNetMsg msg);
9 |
10 | public interface ITNetReader
11 | {
12 | ///
13 | /// read the data and send message to the client adapter.
14 | ///
15 | /// buffer
16 | /// size
17 | /// start
18 | /// new start
19 | int DidReadData (byte[] data, int start, int tail, HandleMsgDel handle, System.Object state);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/java/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/c#/Example/Assets/Plugins/TNet/common/TNetMsg.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Tunner Net - Data interception use ProtoBuf in game Development.
3 | e-mail : dongliang17@126.com
4 | project: https://github.com/dongliang/Tuner-Net
5 | */
6 |
7 | using System.IO;
8 | namespace Tuner.Net
9 | {
10 | public class TNetMsg
11 | {
12 | public int m_nMsgID = 0;
13 | public MemoryStream m_DataMsg;
14 | //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
15 | // public T DeSerializeProtocol()
16 | // {
17 |
18 | /// TunerSerializer temp = new TunerSerializer();
19 | // object o = new object();
20 | // return (T) temp.Deserialize(m_DataMsg, o, typeof(T));
21 | //m_DataMsg.Position = 0;
22 | //return ProtoBuf.Serializer.Deserialize(m_DataMsg);
23 | // }
24 | }
25 | }
--------------------------------------------------------------------------------
/java/client/src/main/java/net/demo/client/DemoClientPipelineFactory.java:
--------------------------------------------------------------------------------
1 | package net.demo.client;
2 |
3 | import org.jboss.netty.channel.ChannelPipeline;
4 | import org.jboss.netty.channel.ChannelPipelineFactory;
5 | import org.jboss.netty.channel.Channels;
6 | import org.jboss.netty.handler.codec.protobuf.ProtobufDecoder;
7 | import org.jboss.netty.handler.codec.protobuf.ProtobufEncoder;
8 |
9 | import net.demo.proto.KVCommand.KVItem;
10 |
11 | public class DemoClientPipelineFactory implements ChannelPipelineFactory {
12 |
13 | public ChannelPipeline getPipeline() throws Exception {
14 | ChannelPipeline pipeline = Channels.pipeline();
15 |
16 | pipeline.addLast("decoder", new ProtobufDecoder(KVItem.getDefaultInstance()));
17 | pipeline.addLast("encoder", new ProtobufEncoder());
18 | pipeline.addLast("handler", new DemoClientChannelHandler());
19 |
20 | return pipeline;
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/java/server/src/main/java/net/demo/server/DemoServerPipelineFactory.java:
--------------------------------------------------------------------------------
1 | package net.demo.server;
2 |
3 | import org.jboss.netty.channel.ChannelPipeline;
4 | import org.jboss.netty.channel.ChannelPipelineFactory;
5 | import org.jboss.netty.channel.Channels;
6 | import org.jboss.netty.handler.codec.protobuf.ProtobufDecoder;
7 | import org.jboss.netty.handler.codec.protobuf.ProtobufEncoder;
8 |
9 | import net.demo.proto.KVCommand.KVItem;
10 |
11 | public class DemoServerPipelineFactory implements ChannelPipelineFactory {
12 |
13 | public ChannelPipeline getPipeline() throws Exception {
14 | ChannelPipeline pipeline = Channels.pipeline();
15 |
16 | pipeline.addLast("decoder", new ProtobufDecoder(KVItem.getDefaultInstance()));
17 | pipeline.addLast("encoder", new ProtobufEncoder());
18 | pipeline.addLast("handler", new DemoServerChannelHandler());
19 |
20 | return pipeline;
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/java/client/src/main/java/net/demo/client/DemoClient.java:
--------------------------------------------------------------------------------
1 | package net.demo.client;
2 |
3 | import net.demo.proto.KVCommand;
4 | import org.jboss.netty.bootstrap.ClientBootstrap;
5 | import org.jboss.netty.channel.Channel;
6 | import org.jboss.netty.channel.ChannelFuture;
7 | import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory;
8 |
9 | import java.net.InetSocketAddress;
10 | import java.util.concurrent.Executors;
11 |
12 | public class DemoClient {
13 | public static void main(String[] args)
14 | {
15 | Thread t = new Thread(new ClientThread());
16 | // Lets run Thread in background..
17 | // Sometimes you need to run thread in background for your Timer application..
18 | t.start(); // starts thread in background..
19 | // t.run(); // is going to execute the code in the thread's run method on the current thread..
20 | System.out.println("Main() Program Exited...\n");
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/java/server/src/main/java/net/demo/server/DemoServer.java:
--------------------------------------------------------------------------------
1 | package net.demo.server;
2 |
3 | import org.jboss.netty.bootstrap.ServerBootstrap;
4 | import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
5 |
6 | import java.net.InetSocketAddress;
7 | import java.util.concurrent.Executors;
8 |
9 | public class DemoServer {
10 |
11 | public static void main(String[] args) {
12 | ServerBootstrap bootstrap = new ServerBootstrap(
13 | new NioServerSocketChannelFactory(
14 | Executors.newCachedThreadPool(),
15 | Executors.newCachedThreadPool()));
16 |
17 | bootstrap.setPipelineFactory(new DemoServerPipelineFactory());
18 | bootstrap.setOption("child.tcpNoDelay", true);
19 | bootstrap.setOption("child.keepAlive", true);
20 |
21 | int port = 8080;
22 | bootstrap.bind(new InetSocketAddress(port));
23 | System.out.println("listening port: " + port + " server is starting……");
24 | }
25 | }
--------------------------------------------------------------------------------
/c#/Example/Assets/Plugins/TNet/common/AgentHolder.cs:
--------------------------------------------------------------------------------
1 | namespace Tuner.Net
2 | {
3 | public class AgentHolder
4 | {
5 | public virtual void Init (ITNetAdapter adapter)
6 | {
7 | mAdapter = adapter;
8 | }
9 |
10 | protected ITNetAdapter mAdapter = null;
11 |
12 | public ITNetAdapter Adapter {
13 | get {
14 | return mAdapter;
15 | }
16 | }
17 |
18 | protected ITNetWriter mWriter = null;
19 |
20 | public ITNetWriter Writer {
21 | get {
22 | if (mWriter == null) {
23 | mWriter = mAdapter.createMsgWriter ();
24 | }
25 | return mWriter;
26 | }
27 | }
28 |
29 | protected ITNetReader mReader = null;
30 |
31 | public ITNetReader Reader {
32 | get {
33 | if (mReader == null) {
34 | mReader = mAdapter.createMsgReader ();
35 | }
36 | return mReader;
37 | }
38 | }
39 |
40 | public virtual void closeAgent (Agent agent)
41 | {
42 | agent.Release ();
43 | }
44 |
45 | public virtual void Update ()
46 | {
47 | //Update the contain Agent.
48 | }
49 | }
50 | }
--------------------------------------------------------------------------------
/KVCommand.proto:
--------------------------------------------------------------------------------
1 | option java_package = "net.demo.proto";
2 | option java_outer_classname = "KVCommand";
3 |
4 | message KVMessage{
5 | required uint32 id = 1;
6 | required uint32 len = 2;
7 | optional KVRequest request = 3;
8 | optional KVResponse response = 4;
9 | }
10 |
11 | message KVResponse{
12 | required uint32 status = 1;
13 | optional string message = 2;
14 | }
15 |
16 | message KVRequest{
17 | enum RequestType {
18 | ITEM = 0;
19 | LOGIN = 1;
20 | }
21 |
22 | required RequestType type = 1 [default = ITEM];
23 | optional KVItem item = 2;
24 | optional KVLogin login = 3;
25 | }
26 |
27 | message KVItem {
28 | required string command = 1;
29 | }
30 |
31 | message KVLogin{
32 | required string username = 1;
33 | required string password = 2;
34 | }
35 |
36 | // message RequestCommand {
37 | // required string command = 1;
38 | // optional string auth = 3;
39 | // optional bytes payload = 4;
40 | // repeated KVItem items = 2;
41 | // }
42 | //
43 | // message KVItem {
44 | // required string key = 1;
45 | // optional bytes value = 2;
46 | // }
47 | //
48 | // message ResponseCommand {
49 | // required bool success = 1;
50 | // optional string message = 2;
51 | // optional string error = 3;
52 | // repeated KVItem items = 5;
53 | // }
--------------------------------------------------------------------------------
/java/build.gradle:
--------------------------------------------------------------------------------
1 | sourceCompatibility = 1.6
2 | version = 1.0
3 |
4 | allprojects {
5 | apply plugin: 'idea'
6 | apply plugin: 'java'
7 | }
8 |
9 | subprojects {
10 | apply plugin: 'java'
11 | repositories {
12 | mavenCentral()
13 | }
14 |
15 | dependencies {
16 | compile (
17 | 'io.netty:netty:3.5.0.Final',
18 | 'com.google.guava:guava:r09',
19 | 'log4j:log4j:1.2.16',
20 | 'com.google.protobuf:protobuf-java:2.5.0'
21 | )
22 | testCompile(
23 | 'junit:junit:4.7',
24 | 'org.mockito:mockito-all:1.9.0',
25 | )
26 | }
27 | }
28 |
29 |
30 | project(':proto') {
31 | }
32 |
33 | project(':server') {
34 | jar {
35 | from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
36 | manifest { attributes 'Main-Class': 'net.demo.server.DemoServer' }
37 | }
38 |
39 | dependencies {
40 | compile(
41 | project(':proto')
42 | )
43 | }
44 | }
45 |
46 | project(':client') {
47 | jar {
48 | from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
49 | manifest { attributes 'Main-Class': 'net.demo.client.DemoClient' }
50 | }
51 |
52 | dependencies {
53 | compile(
54 | project(':proto')
55 | )
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/c#/Example/Assets/Test.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using System.Collections;
3 | using Tuner.Net;
4 | using System.IO;
5 |
6 | public class Test : MonoBehaviour
7 | {
8 | TestAdapter adapter;
9 |
10 | void Start()
11 | {
12 | adapter = new TestAdapter();
13 | }
14 |
15 | void OnGUI()
16 | {
17 | if (!Client.Instance.IsConnected())
18 | {
19 | if (GUILayout.Button("Connect"))
20 | {
21 | testConnect();
22 | }
23 | return;
24 | }
25 | if (GUILayout.Button("Disconnect"))
26 | {
27 | testDisconnect();
28 | }
29 | if (GUILayout.Button("Login"))
30 | {
31 | testLogin();
32 | }
33 | if (GUILayout.Button("Item"))
34 | {
35 | testItem();
36 | }
37 | if (adapter != null)
38 | {
39 | GUILayout.Label(adapter.Message);
40 | }
41 | }
42 |
43 | void testConnect()
44 | {
45 | Client.Instance.Init(adapter);
46 | Client.Instance.Connect("127.0.0.1", 8080);
47 | }
48 |
49 | void testDisconnect()
50 | {
51 | Client.Instance.DisConnect();
52 | }
53 |
54 | void testLogin()
55 | {
56 | Client.Instance.SendMessage(1, adapter.Login("user", "pass"));
57 | }
58 |
59 | void testItem()
60 | {
61 | Client.Instance.SendMessage(1, adapter.Item("bbb"));
62 | }
63 |
64 | void Update()
65 | {
66 | Client.Instance.Update();
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/java/client/src/main/java/net/demo/client/DemoClientChannelHandler.java:
--------------------------------------------------------------------------------
1 | package net.demo.client;
2 |
3 | import org.apache.log4j.Logger;
4 | import org.jboss.netty.channel.*;
5 |
6 | import java.util.concurrent.BlockingQueue;
7 | import java.util.concurrent.LinkedBlockingQueue;
8 |
9 | import net.demo.proto.KVCommand.KVItem;
10 |
11 | public class DemoClientChannelHandler extends SimpleChannelHandler {
12 |
13 | private static final Logger logger = Logger.getLogger(
14 | DemoClientChannelHandler.class.getName());
15 |
16 | @Override
17 | public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e)
18 | throws Exception {
19 | super.channelOpen(ctx, e);
20 | }
21 |
22 | @Override
23 | public void handleUpstream(
24 | ChannelHandlerContext ctx, ChannelEvent e) throws Exception {
25 | if (e instanceof ChannelStateEvent) {
26 | logger.info(e.toString());
27 | }
28 | super.handleUpstream(ctx, e);
29 | }
30 |
31 | @Override
32 | public void exceptionCaught(
33 | ChannelHandlerContext ctx, ExceptionEvent e) {
34 | logger.warn("Unexpected exception from downstream.", e.getCause());
35 | e.getChannel().close();
36 | }
37 |
38 | public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) {
39 | KVItem item = (KVItem)e.getMessage();
40 | logger.info(item.getCommand());
41 | }
42 | }
--------------------------------------------------------------------------------
/java/server/src/main/java/net/demo/server/DemoServerChannelHandler.java:
--------------------------------------------------------------------------------
1 | package net.demo.server;
2 |
3 | import org.apache.log4j.Logger;
4 | import org.jboss.netty.channel.*;
5 |
6 | import java.util.concurrent.BlockingQueue;
7 | import java.util.concurrent.LinkedBlockingQueue;
8 | import net.demo.proto.KVCommand.KVItem;
9 |
10 | public class DemoServerChannelHandler extends SimpleChannelHandler {
11 |
12 | private static final Logger logger = Logger.getLogger(
13 | DemoServerChannelHandler.class.getName());
14 |
15 | private volatile Channel channel;
16 | private final BlockingQueue answer = new LinkedBlockingQueue();
17 |
18 | @Override
19 | public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e)
20 | throws Exception {
21 | channel = e.getChannel();
22 | super.channelOpen(ctx, e);
23 | }
24 |
25 | @Override
26 | public void handleUpstream(
27 | ChannelHandlerContext ctx, ChannelEvent e) throws Exception {
28 | if (e instanceof ChannelStateEvent) {
29 | logger.info(e.toString());
30 | }
31 | super.handleUpstream(ctx, e);
32 | }
33 |
34 | @Override
35 | public void exceptionCaught(
36 | ChannelHandlerContext ctx, ExceptionEvent e) {
37 | logger.warn("Unexpected exception from downstream.", e.getCause());
38 | e.getChannel().close();
39 | }
40 |
41 | public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) {
42 | KVItem item = (KVItem) e.getMessage();
43 |
44 | KVItem.Builder builder = KVItem.newBuilder();
45 | String command = item.getCommand();
46 | logger.info(command);
47 | builder.setCommand(command);
48 |
49 | e.getChannel().write(builder.build());
50 | }
51 |
52 | }
--------------------------------------------------------------------------------
/py/c.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #!encoding:utf-8
3 |
4 | import KVCommand_pb2 as pb
5 | import time
6 | import sys
7 | import socket
8 | import struct
9 |
10 | class SocketService():
11 | def __init__(self, host = "localhost", port = 8080):
12 | try:
13 | self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
14 | self.s.connect((host , port))
15 | except socket.error, msg:
16 | print 'Failed to create socket. Error code: ' + str(msg[0]) + ' , Error message : ' + msg[1]
17 | sys.exit()
18 |
19 | def send(self, message):
20 | self.s.sendall(message)
21 |
22 | def recv(self, buff = 4096):
23 | return self.s.recv(buff)
24 |
25 | def __del__(self):
26 | self.s.close()
27 |
28 | def test_command_pb():
29 | request = pb.KVRequest()
30 | request.type = pb.KVRequest.ITEM;
31 | request.item.command = "bbb"
32 | return send_recv(request)
33 |
34 | def test_login_pb():
35 | request = pb.KVRequest()
36 | request.type = pb.KVRequest.LOGIN;
37 | request.login.username = "user"
38 | request.login.password = "pass"
39 | return send_recv(request)
40 |
41 | def send_recv(request):
42 | s = SocketService(host = "localhost", port = 8080)
43 | tmp = request.SerializeToString()
44 | # print tmp
45 | packet = struct.pack("!II%ds"%(len(tmp)), 0xFEDCB000, len(tmp), tmp)
46 | print repr(packet), len(packet)
47 | s.send(packet)
48 | buf = s.recv(4096)
49 | print buf
50 | msg_id, msg_len, packet = struct.unpack("!II%ds"%(len(buf)-8), buf)
51 | response = pb.KVResponse()
52 | response.ParseFromString(packet)
53 | return response
54 |
55 | if __name__ == '__main__':
56 | #response = test_command_pb()
57 | response = test_login_pb()
58 | print response
59 |
--------------------------------------------------------------------------------
/c#/Example/Assets/TestAdapter.cs:
--------------------------------------------------------------------------------
1 | using Tuner.Net;
2 | using UnityEngine;
3 | using System.IO;
4 |
5 | public class TestAdapter : ITNetAdapter
6 | {
7 | private string message;
8 |
9 | public string Message {
10 | get {
11 | return message;
12 | }
13 | }
14 |
15 | public MemoryStream Login(string user, string pass){
16 | Example.KVRequest request = new Example.KVRequest ();
17 | request.Type = Example.KVRequest.RequestType.LOGIN;
18 | request.Login = new Example.KVLogin ();
19 | request.Login.Username = user;
20 | request.Login.Password = pass;
21 | return RequestToMemoryStream (request);
22 | }
23 |
24 | public MemoryStream Item(string command){
25 | Example.KVRequest request = new Example.KVRequest ();
26 | request.Type = Example.KVRequest.RequestType.ITEM;
27 | request.Item = new Example.KVItem ();
28 | request.Item.Command = command;
29 |
30 | return RequestToMemoryStream (request);
31 | }
32 |
33 | static MemoryStream RequestToMemoryStream (Example.KVRequest request)
34 | {
35 | MemoryStream tempStream = new MemoryStream ();
36 | Example.KVRequest.Serialize (tempStream, request);
37 | return tempStream;
38 | }
39 |
40 | public void HandleMsg (System.Object state, TNetMsg msg)
41 | {
42 | Example.KVResponse response = Example.KVResponse.Deserialize (msg.m_DataMsg);
43 | message = response.Message;
44 | }
45 |
46 | public ITNetWriter createMsgWriter ()
47 | {
48 | return new TNetWriter ();
49 | }
50 |
51 | public ITNetReader createMsgReader ()
52 | {
53 | return new TNetReader ();
54 | }
55 |
56 | public void onConnected ()
57 | {
58 | Debug.Log ("onConnected");
59 | }
60 |
61 | public void onAccepted ()
62 | {
63 | }
64 |
65 | public void onReConnected ()
66 | {
67 | }
68 |
69 | public void onNetWorkFailed ()
70 | {
71 | }
72 |
73 | public void onReConnectBegin ()
74 | {
75 | }
76 | }
--------------------------------------------------------------------------------
/c#/Example/Assets/Plugins/TNet/common/TNetWriter.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Tunner Net - Data interception use ProtoBuf in game Development.
3 | e-mail : dongliang17@126.com
4 | project: https://github.com/dongliang/Tuner-Net
5 | */
6 | using System.IO;
7 | using System.Net;
8 | using System;
9 | namespace Tuner.Net
10 | {
11 |
12 | public class TNetWriter : ITNetWriter
13 | {
14 | private MemoryStream m_Buffer = new MemoryStream();
15 |
16 | public byte[] MakeStream(int msgID, MemoryStream data)
17 | {
18 |
19 |
20 | m_Buffer.SetLength(0);
21 | int net_data_size = data != null ? (int)data.Length : 0;
22 |
23 |
24 | if (BitConverter.IsLittleEndian)
25 | {
26 | net_data_size = IPAddress.HostToNetworkOrder(net_data_size);
27 | msgID = IPAddress.HostToNetworkOrder(msgID);
28 | }
29 |
30 | byte[] msgID_Bytes = BitConverter.GetBytes(msgID);
31 | byte[] net_data_size_Bytes = BitConverter.GetBytes(net_data_size);
32 |
33 | m_Buffer.Write(msgID_Bytes, 0, 4);
34 | m_Buffer.Write(net_data_size_Bytes, 0, 4);
35 | if (data != null)
36 | m_Buffer.Write(data.GetBuffer(), 0, (int)data.Length);
37 | return m_Buffer.ToArray();
38 | }
39 |
40 | public void Reset()
41 | {
42 | m_Buffer.SetLength(0);
43 | }
44 |
45 | private MemoryStream m_streamBuff = new MemoryStream();
46 | //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
47 | public MemoryStream Serialize(T instance)
48 | {
49 | m_streamBuff.SetLength(0);
50 | // TunerSerializer temp = new TunerSerializer();
51 | // temp.Serialize(m_streamBuff, instance);
52 | return m_streamBuff;
53 | }
54 | }
55 | }
--------------------------------------------------------------------------------
/c#/Example/Assets/Plugins/TNet/common/TNetReader.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Tunner Net - Data interception use ProtoBuf in game Development.
3 | e-mail : dongliang17@126.com
4 | project: https://github.com/dongliang/Tuner-Net
5 | */
6 | using System;
7 | using System.IO;
8 | using System.Net;
9 | using UnityEngine;
10 |
11 | namespace Tuner.Net
12 | {
13 | //Buffer
14 | public class TNetReader : ITNetReader
15 | {
16 | ///
17 | /// read the data and send message to the client adapter.
18 | ///
19 | /// buffer
20 | /// size
21 | /// start
22 | /// new start
23 | public int DidReadData (byte[] data, int start, int tail, HandleMsgDel handle, System.Object state)
24 | {
25 | int size = tail - start;
26 | int msg_id = 0;
27 | int data_size = 0;
28 |
29 |
30 | if (size > 8) {
31 | //read message head
32 | msg_id = BitConverter.ToInt32 (data, start);
33 | data_size = BitConverter.ToInt32 (data, start + 4);
34 |
35 | if (BitConverter.IsLittleEndian) {
36 | msg_id = IPAddress.NetworkToHostOrder (msg_id);
37 | data_size = IPAddress.NetworkToHostOrder (data_size);
38 | }
39 | } else {
40 | return start;
41 | }
42 |
43 | Debug.Log (string.Format("msg_id is: {0:x}, data_size is: {1:x}", msg_id, data_size));
44 |
45 | //check body
46 | if (size >= data_size + 8) {
47 | //send message to adapter
48 |
49 | //create message
50 | TNetMsg msg = new TNetMsg ();
51 |
52 | MemoryStream msg_data_body = new MemoryStream ();
53 | msg_data_body.SetLength (0);
54 | msg_data_body.Write (data, start + 8, data_size);
55 | msg_data_body.Position = 0;
56 | msg.m_nMsgID = msg_id;
57 | msg.m_DataMsg = msg_data_body;
58 |
59 | handle (state, msg);
60 | } else {
61 | return start;
62 | }
63 |
64 | //recurrence passing the new start address.
65 | return DidReadData (data, start + data_size + 8, tail, handle, state);
66 | }
67 | }
68 | }
--------------------------------------------------------------------------------
/py/s.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #!encoding:utf-8
3 |
4 | import time
5 | import KVCommand_pb2 as pb
6 | import socket
7 | import thread
8 | import struct
9 |
10 | def handle_login(login):
11 | response = pb.KVResponse()
12 | response.status = 0
13 | response.message = "handle_login" + login.username + login.password
14 | return response
15 |
16 | def handle_item(item):
17 | response = pb.KVResponse()
18 | response.status = 0
19 | response.message = "handle_item" + item.command
20 | return response
21 |
22 | def handler(conn):
23 | while 1:
24 | try:
25 | conn.settimeout(5)
26 | buf = conn.recv(100)
27 | if len(buf) > 0:
28 | # print "Received request: ", len(buf)
29 | # print repr(buf), len(buf)
30 | msg_id, msg_len, packet = struct.unpack("!II%ds"%(len(buf)-8), buf)
31 | print "%x"%(msg_id), msg_len, repr(packet)
32 | if len(buf) == msg_len+8:
33 | request = pb.KVRequest()
34 | request.ParseFromString(packet)
35 | if request.type == pb.KVRequest.ITEM:
36 | response = handle_item(request.item)
37 | else:
38 | response = handle_login(request.login)
39 |
40 | print response
41 | tmp = response.SerializeToString()
42 | packet = struct.pack("!II%ds"%(len(tmp)), 0xFEDCB000, len(tmp), tmp)
43 | conn.send(packet)
44 |
45 | time.sleep(1)
46 | except socket.timeout:
47 | print 'time out'
48 | except:
49 | # print 'exception'
50 | break
51 |
52 | conn.close()
53 |
54 | if __name__=='__main__':
55 | s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
56 | s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
57 | s.bind(('', 8080))
58 | s.listen(5)
59 |
60 | while True:
61 | conn, addr = s.accept()
62 | thread.start_new_thread(handler, (conn, ))
63 |
--------------------------------------------------------------------------------
/java/client/src/main/java/net/demo/client/ClientThread.java:
--------------------------------------------------------------------------------
1 | package net.demo.client;
2 |
3 | import static org.jboss.netty.channel.Channels.pipeline;
4 |
5 | import java.net.InetSocketAddress;
6 | import java.util.concurrent.Executors;
7 |
8 | import net.demo.proto.KVCommand;
9 | import org.jboss.netty.bootstrap.ClientBootstrap;
10 | import org.jboss.netty.channel.Channel;
11 | import org.jboss.netty.channel.ChannelFuture;
12 | import org.jboss.netty.channel.ChannelPipeline;
13 | import org.jboss.netty.channel.ChannelPipelineFactory;
14 | import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory;
15 | import org.jboss.netty.handler.codec.string.StringDecoder;
16 | import org.jboss.netty.handler.codec.string.StringEncoder;
17 |
18 | public class ClientThread implements Runnable
19 | {
20 | private Channel channel;
21 |
22 | @Override
23 | public void run()
24 | {
25 | ClientBootstrap bootstrap = new ClientBootstrap(
26 | new NioClientSocketChannelFactory(
27 | Executors.newCachedThreadPool(),
28 | Executors.newCachedThreadPool()));
29 |
30 | bootstrap.setPipelineFactory(new DemoClientPipelineFactory());
31 | ChannelFuture future = bootstrap.connect(new InetSocketAddress("localhost", 8080));
32 | channel = future.awaitUninterruptibly().getChannel();
33 |
34 | for(int i=0; i<3; i++){
35 | try{
36 | Thread.sleep(1000);
37 | } catch (InterruptedException e){
38 | e.printStackTrace();
39 | }
40 | this.sendMsg();
41 | }
42 |
43 | channel.close().awaitUninterruptibly();
44 | bootstrap.releaseExternalResources();
45 | }
46 |
47 | public void sendMsg()
48 | {
49 | if(channel == null) return;
50 |
51 | KVCommand.KVItem.Builder builder = KVCommand.KVItem.newBuilder();
52 | builder.setCommand("hello");
53 | ChannelFuture lastWriteFuture = channel.write(builder.build());
54 |
55 | // Wait until all messages are flushed before closing the channel.
56 | if (lastWriteFuture != null) {
57 | lastWriteFuture.awaitUninterruptibly();
58 | }
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/c#/Example/Assets/Plugins/Message/KVCommand.cs:
--------------------------------------------------------------------------------
1 | // Classes and structures being serialized
2 |
3 | // Generated by ProtocolBuffer
4 | // - a pure c# code generation implementation of protocol buffers
5 | // Report bugs to: https://silentorbit.com/protobuf/
6 |
7 | // DO NOT EDIT
8 | // This file will be overwritten when CodeGenerator is run.
9 | // To make custom modifications, edit the .proto file and add //:external before the message line
10 | // then write the code and the changes in a separate file.
11 | using System;
12 | using System.Collections.Generic;
13 |
14 | namespace Example
15 | {
16 | public partial class KVMessage
17 | {
18 | public uint Id { get; set; }
19 |
20 | public uint Len { get; set; }
21 |
22 | public Example.KVRequest Request { get; set; }
23 |
24 | public Example.KVResponse Response { get; set; }
25 |
26 | // ProtocolBuffers wire field id
27 | public const int IdFieldID = 1;
28 | public const int LenFieldID = 2;
29 | public const int RequestFieldID = 3;
30 | public const int ResponseFieldID = 4;
31 | }
32 |
33 | public partial class KVResponse
34 | {
35 | public uint Status { get; set; }
36 |
37 | public string Message { get; set; }
38 |
39 | // ProtocolBuffers wire field id
40 | public const int StatusFieldID = 1;
41 | public const int MessageFieldID = 2;
42 | }
43 |
44 | public partial class KVRequest
45 | {
46 | public enum RequestType
47 | {
48 | ITEM = 0,
49 | LOGIN = 1,
50 | }
51 |
52 | public Example.KVRequest.RequestType Type { get; set; }
53 |
54 | public Example.KVItem Item { get; set; }
55 |
56 | public Example.KVLogin Login { get; set; }
57 |
58 | // ProtocolBuffers wire field id
59 | public const int TypeFieldID = 1;
60 | public const int ItemFieldID = 2;
61 | public const int LoginFieldID = 3;
62 | }
63 |
64 | public partial class KVItem
65 | {
66 | public string Command { get; set; }
67 |
68 | // ProtocolBuffers wire field id
69 | public const int CommandFieldID = 1;
70 | }
71 |
72 | public partial class KVLogin
73 | {
74 | public string Username { get; set; }
75 |
76 | public string Password { get; set; }
77 |
78 | // ProtocolBuffers wire field id
79 | public const int UsernameFieldID = 1;
80 | public const int PasswordFieldID = 2;
81 | }
82 |
83 | }
84 |
--------------------------------------------------------------------------------
/c#/Example/Assets/Plugins/TNet/Client.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Net.Sockets;
3 | using System.Net;
4 | using System.IO;
5 | using UnityEngine;
6 |
7 | namespace Tuner.Net
8 | {
9 | public class Client:AgentHolder
10 | {
11 | string m_strRomoteIP = "127.0.0.1";
12 | ushort m_uRemotePort = 0;
13 | Agent mMainAgent = null;
14 | bool isReConnect = false;
15 | protected static Client instance = new Client ();
16 |
17 | public static Client Instance {
18 | get { return instance; }
19 | }
20 |
21 | public void Connect (string a_strRomoteIP, ushort a_uPort)
22 | {
23 | if (mMainAgent != null) {
24 |
25 | closeAgent (mMainAgent);
26 | }
27 |
28 | try {
29 | Socket clientSocket = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
30 | IPAddress ip = IPAddress.Parse (a_strRomoteIP);
31 | clientSocket.BeginConnect (ip, a_uPort, new AsyncCallback (ConnectCallback), clientSocket);
32 | m_strRomoteIP = a_strRomoteIP;
33 | m_uRemotePort = a_uPort;
34 |
35 | } catch (Exception e) {
36 |
37 | Debug.LogError (e.Message);
38 | }
39 | }
40 |
41 | private void ConnectCallback (IAsyncResult ar)
42 | {
43 | try {
44 | ar.AsyncWaitHandle.Close ();
45 |
46 | Socket socket = (Socket)ar.AsyncState;
47 | socket.EndConnect (ar);
48 | socket.Blocking = false;
49 | mMainAgent = new Agent (this, socket, 0);
50 |
51 | mMainAgent.Receive ();
52 |
53 | if (!isReConnect) {
54 | mAdapter.onConnected ();
55 | } else {
56 | Adapter.onReConnected ();
57 | isReConnect = false;
58 | }
59 | } catch (Exception e) {
60 |
61 | Debug.LogError (e.Message);
62 | mAdapter.onNetWorkFailed ();
63 | }
64 | }
65 |
66 | public override void Update ()
67 | {
68 | base.Update ();
69 | if (mMainAgent != null) {
70 | mMainAgent.Update ();
71 | }
72 |
73 | }
74 |
75 | public bool ReConnect ()
76 | {
77 | if (m_strRomoteIP != null) {
78 | DisConnect ();
79 |
80 | isReConnect = true;
81 | Adapter.onReConnectBegin ();
82 | //First Release Socket Resource
83 | Connect (m_strRomoteIP, m_uRemotePort);
84 | return true;
85 | } else {
86 | return false;
87 | }
88 | }
89 |
90 | public bool IsConnected ()
91 | {
92 | return mMainAgent != null ? mMainAgent.IsConnected () : false;
93 | }
94 |
95 | public override void closeAgent (Agent agent)
96 | {
97 | if (agent != null) {
98 | base.closeAgent (agent);
99 | mMainAgent = null;
100 | }
101 | }
102 |
103 | public bool SendMessage (int msgID, MemoryStream data)
104 | {
105 | return mMainAgent.SendMessage (msgID, data);
106 | }
107 |
108 | public void DisConnect ()
109 | {
110 | closeAgent (mMainAgent);
111 | }
112 |
113 | public void SetSocketSendNoDeley (bool nodelay)
114 | {
115 | mMainAgent.SetSocketSendNoDeley (nodelay);
116 | }
117 | }
118 | }
--------------------------------------------------------------------------------
/java/proto/proto.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/java/client/client.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
--------------------------------------------------------------------------------
/java/server/server.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
--------------------------------------------------------------------------------
/c#/Example/Assets/Plugins/TNet/common/Agent.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Net.Sockets;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using UnityEngine;
6 |
7 | namespace Tuner.Net
8 | {
9 | public class Agent
10 | {
11 | //common
12 | Socket mSocket = null;
13 | AgentHolder mHolder = null;
14 | public int mSessionId = 0;
15 | //recv
16 | public bool mIsRecving = false;
17 | IAsyncResult m_ar_Recv = null;
18 | public const int m_RecBufferSize = 65536;
19 | byte[] m_RecBuffer = new byte[m_RecBufferSize];
20 | int mRecvHead = 0;
21 | //point the first valid address
22 | int mRecvTail = 0;
23 | //point to the last valid address 's next address.
24 | //send
25 | private IAsyncResult m_ar_Send = null;
26 | private Queue m_SendQueue = new Queue ();
27 |
28 | public Agent (AgentHolder holder, Socket socket, int sessionId)
29 | {
30 | mSessionId = sessionId;
31 | mHolder = holder;
32 | mSocket = socket;
33 | }
34 |
35 | public void Receive ()
36 | {
37 | try {
38 | if (m_RecBufferSize == mRecvTail) {
39 | System.Buffer.BlockCopy (m_RecBuffer, mRecvHead, m_RecBuffer, 0, mRecvTail - mRecvHead);
40 | mRecvTail -= mRecvHead;
41 | mRecvHead = 0;
42 | }
43 |
44 | if (m_RecBufferSize == mRecvTail) {
45 | throw new Exception ("Receive buffer is full");
46 | }
47 | m_ar_Recv = mSocket.BeginReceive (m_RecBuffer, mRecvTail, m_RecBufferSize - mRecvTail, 0, new AsyncCallback (ReceiveCallback), 0);
48 | Debug.Log ("BeginReceive");
49 | mIsRecving = true;
50 | } catch (Exception e) {
51 | Debug.LogError (e.Message);
52 | }
53 | }
54 |
55 | public void SetSocketSendNoDeley (bool nodelay)
56 | {
57 | if (mSocket != null) {
58 | mSocket.SetSocketOption (SocketOptionLevel.Tcp, SocketOptionName.NoDelay, nodelay ? 1 : 0);
59 | }
60 | }
61 |
62 | private void ReceiveCallback (IAsyncResult ar)
63 | {
64 | try {
65 | ar.AsyncWaitHandle.Close ();
66 | m_ar_Recv = null;
67 | Socket client = mSocket;
68 | int bytesRead = client.EndReceive (ar);
69 | if (bytesRead > 0) {
70 | mRecvTail += bytesRead;
71 | Debug.Log ("ReceiveCallback mRecvTail is " + mRecvTail);
72 | mIsRecving = false;
73 | } else {
74 | Debug.Log ("Network Shutdown");
75 | mHolder.closeAgent (this);
76 | }
77 | } catch (Exception e) {
78 | Debug.LogError (e.Message);
79 | }
80 | }
81 |
82 | public void Update ()
83 | {
84 | UpdateRecv ();
85 | }
86 |
87 | void UpdateRecv ()
88 | {
89 | if (IsConnected () && !mIsRecving) {
90 | if (mHolder.Reader != null) {
91 | mRecvHead = mHolder.Reader.DidReadData (m_RecBuffer, mRecvHead, mRecvTail, mHolder.Adapter.HandleMsg, mSessionId);
92 | }
93 | Receive ();
94 | }
95 | }
96 |
97 | public bool IsConnected ()
98 | {
99 | return mSocket != null ? mSocket.Connected : false;
100 | }
101 |
102 | public bool SendMessage (int msgID, MemoryStream data)
103 | {
104 | if (mHolder.Writer != null) {
105 | byte[] stream = mHolder.Writer.MakeStream (msgID, data);
106 | lock (m_SendQueue) {
107 | if (m_SendQueue.Count == 0) {
108 | return Send (stream);
109 | } else {
110 | m_SendQueue.Enqueue (stream);
111 | return true;
112 | }
113 | }
114 | }
115 | return false;
116 | }
117 |
118 | private bool Send (byte[] byteData)
119 | {
120 | try {
121 | m_ar_Send = mSocket.BeginSend (byteData, 0, byteData.Length, 0, new AsyncCallback (SendCallback), 0);
122 | return true;
123 | } catch (Exception e) {
124 | Debug.LogError (e.Message);
125 | }
126 | return false;
127 | }
128 |
129 | private void SendCallback (IAsyncResult ar)
130 | {
131 | try {
132 | ar.AsyncWaitHandle.Close ();
133 | m_ar_Send = null;
134 | Socket client = mSocket;
135 | client.EndSend (ar);
136 | lock (m_SendQueue) {
137 | if (m_SendQueue.Count > 0) {
138 | Send (m_SendQueue.Dequeue ());
139 | }
140 | }
141 | } catch (Exception e) {
142 | Debug.LogError (e.Message);
143 | }
144 | }
145 |
146 | public void Release ()
147 | {
148 | if (m_ar_Recv != null)
149 | m_ar_Recv.AsyncWaitHandle.Close ();
150 | if (m_ar_Send != null)
151 | m_ar_Send.AsyncWaitHandle.Close ();
152 |
153 | if (mSocket != null) {
154 | try {
155 | mSocket.Shutdown (SocketShutdown.Both);
156 | } catch (Exception e) {
157 | Debug.LogError (e.Message);
158 | } finally {
159 | mSocket.Close ();
160 | mSocket = null;
161 | }
162 | }
163 | }
164 | }
165 | }
166 |
--------------------------------------------------------------------------------
/java/java.ipr:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
99 |
100 |
101 | 1.6
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
--------------------------------------------------------------------------------
/c#/Example/Assets/demo.unity:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!29 &1
4 | SceneSettings:
5 | m_ObjectHideFlags: 0
6 | m_PVSData:
7 | m_QueryMode: 1
8 | m_PVSObjectsArray: []
9 | m_PVSPortalsArray: []
10 | m_OcclusionBakeSettings:
11 | viewCellSize: 1
12 | bakeMode: 2
13 | memoryUsage: 10485760
14 | --- !u!104 &2
15 | RenderSettings:
16 | m_Fog: 0
17 | m_FogColor: {r: .5, g: .5, b: .5, a: 1}
18 | m_FogMode: 3
19 | m_FogDensity: .00999999978
20 | m_LinearFogStart: 0
21 | m_LinearFogEnd: 300
22 | m_AmbientLight: {r: .200000003, g: .200000003, b: .200000003, a: 1}
23 | m_SkyboxMaterial: {fileID: 0}
24 | m_HaloStrength: .5
25 | m_FlareStrength: 1
26 | m_HaloTexture: {fileID: 0}
27 | m_SpotCookie: {fileID: 0}
28 | m_ObjectHideFlags: 0
29 | --- !u!127 &3
30 | LevelGameManager:
31 | m_ObjectHideFlags: 0
32 | --- !u!157 &4
33 | LightmapSettings:
34 | m_ObjectHideFlags: 0
35 | m_LightProbes: {fileID: 0}
36 | m_Lightmaps: []
37 | m_LightmapsMode: 1
38 | m_BakedColorSpace: 0
39 | m_UseDualLightmapsInForward: 0
40 | m_LightmapEditorSettings:
41 | m_Resolution: 50
42 | m_LastUsedResolution: 0
43 | m_TextureWidth: 1024
44 | m_TextureHeight: 1024
45 | m_BounceBoost: 1
46 | m_BounceIntensity: 1
47 | m_SkyLightColor: {r: .860000014, g: .930000007, b: 1, a: 1}
48 | m_SkyLightIntensity: 0
49 | m_Quality: 0
50 | m_Bounces: 1
51 | m_FinalGatherRays: 1000
52 | m_FinalGatherContrastThreshold: .0500000007
53 | m_FinalGatherGradientThreshold: 0
54 | m_FinalGatherInterpolationPoints: 15
55 | m_AOAmount: 0
56 | m_AOMaxDistance: .100000001
57 | m_AOContrast: 1
58 | m_LODSurfaceMappingDistance: 1
59 | m_Padding: 0
60 | m_TextureCompression: 0
61 | m_LockAtlas: 0
62 | --- !u!196 &5
63 | NavMeshSettings:
64 | m_ObjectHideFlags: 0
65 | m_BuildSettings:
66 | agentRadius: .5
67 | agentHeight: 2
68 | agentSlope: 45
69 | agentClimb: .400000006
70 | ledgeDropHeight: 0
71 | maxJumpAcrossDistance: 0
72 | accuratePlacement: 0
73 | minRegionArea: 2
74 | widthInaccuracy: 16.666666
75 | heightInaccuracy: 10
76 | m_NavMesh: {fileID: 0}
77 | --- !u!1 &364590599
78 | GameObject:
79 | m_ObjectHideFlags: 0
80 | m_PrefabParentObject: {fileID: 0}
81 | m_PrefabInternal: {fileID: 0}
82 | serializedVersion: 4
83 | m_Component:
84 | - 4: {fileID: 364590604}
85 | - 20: {fileID: 364590603}
86 | - 92: {fileID: 364590602}
87 | - 124: {fileID: 364590601}
88 | - 81: {fileID: 364590600}
89 | m_Layer: 0
90 | m_Name: Main Camera
91 | m_TagString: MainCamera
92 | m_Icon: {fileID: 0}
93 | m_NavMeshLayer: 0
94 | m_StaticEditorFlags: 0
95 | m_IsActive: 1
96 | --- !u!81 &364590600
97 | AudioListener:
98 | m_ObjectHideFlags: 0
99 | m_PrefabParentObject: {fileID: 0}
100 | m_PrefabInternal: {fileID: 0}
101 | m_GameObject: {fileID: 364590599}
102 | m_Enabled: 1
103 | --- !u!124 &364590601
104 | Behaviour:
105 | m_ObjectHideFlags: 0
106 | m_PrefabParentObject: {fileID: 0}
107 | m_PrefabInternal: {fileID: 0}
108 | m_GameObject: {fileID: 364590599}
109 | m_Enabled: 1
110 | --- !u!92 &364590602
111 | Behaviour:
112 | m_ObjectHideFlags: 0
113 | m_PrefabParentObject: {fileID: 0}
114 | m_PrefabInternal: {fileID: 0}
115 | m_GameObject: {fileID: 364590599}
116 | m_Enabled: 1
117 | --- !u!20 &364590603
118 | Camera:
119 | m_ObjectHideFlags: 0
120 | m_PrefabParentObject: {fileID: 0}
121 | m_PrefabInternal: {fileID: 0}
122 | m_GameObject: {fileID: 364590599}
123 | m_Enabled: 1
124 | serializedVersion: 2
125 | m_ClearFlags: 1
126 | m_BackGroundColor: {r: .192156866, g: .301960796, b: .474509805, a: .0196078438}
127 | m_NormalizedViewPortRect:
128 | serializedVersion: 2
129 | x: 0
130 | y: 0
131 | width: 1
132 | height: 1
133 | near clip plane: .300000012
134 | far clip plane: 1000
135 | field of view: 60
136 | orthographic: 0
137 | orthographic size: 100
138 | m_Depth: -1
139 | m_CullingMask:
140 | serializedVersion: 2
141 | m_Bits: 4294967295
142 | m_RenderingPath: -1
143 | m_TargetTexture: {fileID: 0}
144 | m_HDR: 0
145 | --- !u!4 &364590604
146 | Transform:
147 | m_ObjectHideFlags: 0
148 | m_PrefabParentObject: {fileID: 0}
149 | m_PrefabInternal: {fileID: 0}
150 | m_GameObject: {fileID: 364590599}
151 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
152 | m_LocalPosition: {x: 0, y: 1, z: -10}
153 | m_LocalScale: {x: 1, y: 1, z: 1}
154 | m_Children: []
155 | m_Father: {fileID: 0}
156 | --- !u!1 &1226962178
157 | GameObject:
158 | m_ObjectHideFlags: 0
159 | m_PrefabParentObject: {fileID: 0}
160 | m_PrefabInternal: {fileID: 0}
161 | serializedVersion: 4
162 | m_Component:
163 | - 4: {fileID: 1226962179}
164 | - 114: {fileID: 1226962181}
165 | m_Layer: 0
166 | m_Name: Start
167 | m_TagString: Untagged
168 | m_Icon: {fileID: 0}
169 | m_NavMeshLayer: 0
170 | m_StaticEditorFlags: 0
171 | m_IsActive: 1
172 | --- !u!4 &1226962179
173 | Transform:
174 | m_ObjectHideFlags: 0
175 | m_PrefabParentObject: {fileID: 0}
176 | m_PrefabInternal: {fileID: 0}
177 | m_GameObject: {fileID: 1226962178}
178 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
179 | m_LocalPosition: {x: -25.784626, y: -2.39078283, z: -82.5601044}
180 | m_LocalScale: {x: 1, y: 1, z: 1}
181 | m_Children: []
182 | m_Father: {fileID: 0}
183 | --- !u!114 &1226962181
184 | MonoBehaviour:
185 | m_ObjectHideFlags: 0
186 | m_PrefabParentObject: {fileID: 0}
187 | m_PrefabInternal: {fileID: 0}
188 | m_GameObject: {fileID: 1226962178}
189 | m_Enabled: 1
190 | m_EditorHideFlags: 0
191 | m_Script: {fileID: 11500000, guid: 09d6a8b5ec4c249ddb6016eb4292cdc7, type: 3}
192 | m_Name:
193 | m_EditorClassIdentifier:
194 |
--------------------------------------------------------------------------------
/py/KVCommand_pb2.py:
--------------------------------------------------------------------------------
1 | # Generated by the protocol buffer compiler. DO NOT EDIT!
2 | # source: KVCommand.proto
3 |
4 | from google.protobuf import descriptor as _descriptor
5 | from google.protobuf import message as _message
6 | from google.protobuf import reflection as _reflection
7 | from google.protobuf import descriptor_pb2
8 | # @@protoc_insertion_point(imports)
9 |
10 |
11 |
12 |
13 | DESCRIPTOR = _descriptor.FileDescriptor(
14 | name='KVCommand.proto',
15 | package='',
16 | serialized_pb='\n\x0fKVCommand.proto\"`\n\tKVMessage\x12\n\n\x02id\x18\x01 \x02(\r\x12\x0b\n\x03len\x18\x02 \x02(\r\x12\x1b\n\x07request\x18\x03 \x01(\x0b\x32\n.KVRequest\x12\x1d\n\x08response\x18\x04 \x01(\x0b\x32\x0b.KVResponse\"-\n\nKVResponse\x12\x0e\n\x06status\x18\x01 \x02(\r\x12\x0f\n\x07message\x18\x02 \x01(\t\"\x8b\x01\n\tKVRequest\x12*\n\x04type\x18\x01 \x02(\x0e\x32\x16.KVRequest.RequestType:\x04ITEM\x12\x15\n\x04item\x18\x02 \x01(\x0b\x32\x07.KVItem\x12\x17\n\x05login\x18\x03 \x01(\x0b\x32\x08.KVLogin\"\"\n\x0bRequestType\x12\x08\n\x04ITEM\x10\x00\x12\t\n\x05LOGIN\x10\x01\"\x19\n\x06KVItem\x12\x0f\n\x07\x63ommand\x18\x01 \x02(\t\"-\n\x07KVLogin\x12\x10\n\x08username\x18\x01 \x02(\t\x12\x10\n\x08password\x18\x02 \x02(\tB\x1b\n\x0enet.demo.protoB\tKVCommand')
17 |
18 |
19 |
20 | _KVREQUEST_REQUESTTYPE = _descriptor.EnumDescriptor(
21 | name='RequestType',
22 | full_name='KVRequest.RequestType',
23 | filename=None,
24 | file=DESCRIPTOR,
25 | values=[
26 | _descriptor.EnumValueDescriptor(
27 | name='ITEM', index=0, number=0,
28 | options=None,
29 | type=None),
30 | _descriptor.EnumValueDescriptor(
31 | name='LOGIN', index=1, number=1,
32 | options=None,
33 | type=None),
34 | ],
35 | containing_type=None,
36 | options=None,
37 | serialized_start=270,
38 | serialized_end=304,
39 | )
40 |
41 |
42 | _KVMESSAGE = _descriptor.Descriptor(
43 | name='KVMessage',
44 | full_name='KVMessage',
45 | filename=None,
46 | file=DESCRIPTOR,
47 | containing_type=None,
48 | fields=[
49 | _descriptor.FieldDescriptor(
50 | name='id', full_name='KVMessage.id', index=0,
51 | number=1, type=13, cpp_type=3, label=2,
52 | has_default_value=False, default_value=0,
53 | message_type=None, enum_type=None, containing_type=None,
54 | is_extension=False, extension_scope=None,
55 | options=None),
56 | _descriptor.FieldDescriptor(
57 | name='len', full_name='KVMessage.len', index=1,
58 | number=2, type=13, cpp_type=3, label=2,
59 | has_default_value=False, default_value=0,
60 | message_type=None, enum_type=None, containing_type=None,
61 | is_extension=False, extension_scope=None,
62 | options=None),
63 | _descriptor.FieldDescriptor(
64 | name='request', full_name='KVMessage.request', index=2,
65 | number=3, type=11, cpp_type=10, label=1,
66 | has_default_value=False, default_value=None,
67 | message_type=None, enum_type=None, containing_type=None,
68 | is_extension=False, extension_scope=None,
69 | options=None),
70 | _descriptor.FieldDescriptor(
71 | name='response', full_name='KVMessage.response', index=3,
72 | number=4, type=11, cpp_type=10, label=1,
73 | has_default_value=False, default_value=None,
74 | message_type=None, enum_type=None, containing_type=None,
75 | is_extension=False, extension_scope=None,
76 | options=None),
77 | ],
78 | extensions=[
79 | ],
80 | nested_types=[],
81 | enum_types=[
82 | ],
83 | options=None,
84 | is_extendable=False,
85 | extension_ranges=[],
86 | serialized_start=19,
87 | serialized_end=115,
88 | )
89 |
90 |
91 | _KVRESPONSE = _descriptor.Descriptor(
92 | name='KVResponse',
93 | full_name='KVResponse',
94 | filename=None,
95 | file=DESCRIPTOR,
96 | containing_type=None,
97 | fields=[
98 | _descriptor.FieldDescriptor(
99 | name='status', full_name='KVResponse.status', index=0,
100 | number=1, type=13, cpp_type=3, label=2,
101 | has_default_value=False, default_value=0,
102 | message_type=None, enum_type=None, containing_type=None,
103 | is_extension=False, extension_scope=None,
104 | options=None),
105 | _descriptor.FieldDescriptor(
106 | name='message', full_name='KVResponse.message', index=1,
107 | number=2, type=9, cpp_type=9, label=1,
108 | has_default_value=False, default_value=unicode("", "utf-8"),
109 | message_type=None, enum_type=None, containing_type=None,
110 | is_extension=False, extension_scope=None,
111 | options=None),
112 | ],
113 | extensions=[
114 | ],
115 | nested_types=[],
116 | enum_types=[
117 | ],
118 | options=None,
119 | is_extendable=False,
120 | extension_ranges=[],
121 | serialized_start=117,
122 | serialized_end=162,
123 | )
124 |
125 |
126 | _KVREQUEST = _descriptor.Descriptor(
127 | name='KVRequest',
128 | full_name='KVRequest',
129 | filename=None,
130 | file=DESCRIPTOR,
131 | containing_type=None,
132 | fields=[
133 | _descriptor.FieldDescriptor(
134 | name='type', full_name='KVRequest.type', index=0,
135 | number=1, type=14, cpp_type=8, label=2,
136 | has_default_value=True, default_value=0,
137 | message_type=None, enum_type=None, containing_type=None,
138 | is_extension=False, extension_scope=None,
139 | options=None),
140 | _descriptor.FieldDescriptor(
141 | name='item', full_name='KVRequest.item', index=1,
142 | number=2, type=11, cpp_type=10, label=1,
143 | has_default_value=False, default_value=None,
144 | message_type=None, enum_type=None, containing_type=None,
145 | is_extension=False, extension_scope=None,
146 | options=None),
147 | _descriptor.FieldDescriptor(
148 | name='login', full_name='KVRequest.login', index=2,
149 | number=3, type=11, cpp_type=10, label=1,
150 | has_default_value=False, default_value=None,
151 | message_type=None, enum_type=None, containing_type=None,
152 | is_extension=False, extension_scope=None,
153 | options=None),
154 | ],
155 | extensions=[
156 | ],
157 | nested_types=[],
158 | enum_types=[
159 | _KVREQUEST_REQUESTTYPE,
160 | ],
161 | options=None,
162 | is_extendable=False,
163 | extension_ranges=[],
164 | serialized_start=165,
165 | serialized_end=304,
166 | )
167 |
168 |
169 | _KVITEM = _descriptor.Descriptor(
170 | name='KVItem',
171 | full_name='KVItem',
172 | filename=None,
173 | file=DESCRIPTOR,
174 | containing_type=None,
175 | fields=[
176 | _descriptor.FieldDescriptor(
177 | name='command', full_name='KVItem.command', index=0,
178 | number=1, type=9, cpp_type=9, label=2,
179 | has_default_value=False, default_value=unicode("", "utf-8"),
180 | message_type=None, enum_type=None, containing_type=None,
181 | is_extension=False, extension_scope=None,
182 | options=None),
183 | ],
184 | extensions=[
185 | ],
186 | nested_types=[],
187 | enum_types=[
188 | ],
189 | options=None,
190 | is_extendable=False,
191 | extension_ranges=[],
192 | serialized_start=306,
193 | serialized_end=331,
194 | )
195 |
196 |
197 | _KVLOGIN = _descriptor.Descriptor(
198 | name='KVLogin',
199 | full_name='KVLogin',
200 | filename=None,
201 | file=DESCRIPTOR,
202 | containing_type=None,
203 | fields=[
204 | _descriptor.FieldDescriptor(
205 | name='username', full_name='KVLogin.username', index=0,
206 | number=1, type=9, cpp_type=9, label=2,
207 | has_default_value=False, default_value=unicode("", "utf-8"),
208 | message_type=None, enum_type=None, containing_type=None,
209 | is_extension=False, extension_scope=None,
210 | options=None),
211 | _descriptor.FieldDescriptor(
212 | name='password', full_name='KVLogin.password', index=1,
213 | number=2, type=9, cpp_type=9, label=2,
214 | has_default_value=False, default_value=unicode("", "utf-8"),
215 | message_type=None, enum_type=None, containing_type=None,
216 | is_extension=False, extension_scope=None,
217 | options=None),
218 | ],
219 | extensions=[
220 | ],
221 | nested_types=[],
222 | enum_types=[
223 | ],
224 | options=None,
225 | is_extendable=False,
226 | extension_ranges=[],
227 | serialized_start=333,
228 | serialized_end=378,
229 | )
230 |
231 | _KVMESSAGE.fields_by_name['request'].message_type = _KVREQUEST
232 | _KVMESSAGE.fields_by_name['response'].message_type = _KVRESPONSE
233 | _KVREQUEST.fields_by_name['type'].enum_type = _KVREQUEST_REQUESTTYPE
234 | _KVREQUEST.fields_by_name['item'].message_type = _KVITEM
235 | _KVREQUEST.fields_by_name['login'].message_type = _KVLOGIN
236 | _KVREQUEST_REQUESTTYPE.containing_type = _KVREQUEST;
237 | DESCRIPTOR.message_types_by_name['KVMessage'] = _KVMESSAGE
238 | DESCRIPTOR.message_types_by_name['KVResponse'] = _KVRESPONSE
239 | DESCRIPTOR.message_types_by_name['KVRequest'] = _KVREQUEST
240 | DESCRIPTOR.message_types_by_name['KVItem'] = _KVITEM
241 | DESCRIPTOR.message_types_by_name['KVLogin'] = _KVLOGIN
242 |
243 | class KVMessage(_message.Message):
244 | __metaclass__ = _reflection.GeneratedProtocolMessageType
245 | DESCRIPTOR = _KVMESSAGE
246 |
247 | # @@protoc_insertion_point(class_scope:KVMessage)
248 |
249 | class KVResponse(_message.Message):
250 | __metaclass__ = _reflection.GeneratedProtocolMessageType
251 | DESCRIPTOR = _KVRESPONSE
252 |
253 | # @@protoc_insertion_point(class_scope:KVResponse)
254 |
255 | class KVRequest(_message.Message):
256 | __metaclass__ = _reflection.GeneratedProtocolMessageType
257 | DESCRIPTOR = _KVREQUEST
258 |
259 | # @@protoc_insertion_point(class_scope:KVRequest)
260 |
261 | class KVItem(_message.Message):
262 | __metaclass__ = _reflection.GeneratedProtocolMessageType
263 | DESCRIPTOR = _KVITEM
264 |
265 | # @@protoc_insertion_point(class_scope:KVItem)
266 |
267 | class KVLogin(_message.Message):
268 | __metaclass__ = _reflection.GeneratedProtocolMessageType
269 | DESCRIPTOR = _KVLOGIN
270 |
271 | # @@protoc_insertion_point(class_scope:KVLogin)
272 |
273 |
274 | DESCRIPTOR.has_options = True
275 | DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), '\n\016net.demo.protoB\tKVCommand')
276 | # @@protoc_insertion_point(module_scope)
277 |
--------------------------------------------------------------------------------
/java/proto/src/main/java/net/demo/proto/KVCommand.java:
--------------------------------------------------------------------------------
1 | // Generated by the protocol buffer compiler. DO NOT EDIT!
2 | // source: KVCommand.proto
3 |
4 | package net.demo.proto;
5 |
6 | public final class KVCommand {
7 | private KVCommand() {}
8 | public static void registerAllExtensions(
9 | com.google.protobuf.ExtensionRegistry registry) {
10 | }
11 | public interface KVItemOrBuilder
12 | extends com.google.protobuf.MessageOrBuilder {
13 |
14 | // required string command = 1;
15 | /**
16 | * required string command = 1;
17 | */
18 | boolean hasCommand();
19 | /**
20 | * required string command = 1;
21 | */
22 | java.lang.String getCommand();
23 | /**
24 | * required string command = 1;
25 | */
26 | com.google.protobuf.ByteString
27 | getCommandBytes();
28 | }
29 | /**
30 | * Protobuf type {@code KVItem}
31 | */
32 | public static final class KVItem extends
33 | com.google.protobuf.GeneratedMessage
34 | implements KVItemOrBuilder {
35 | // Use KVItem.newBuilder() to construct.
36 | private KVItem(com.google.protobuf.GeneratedMessage.Builder> builder) {
37 | super(builder);
38 | this.unknownFields = builder.getUnknownFields();
39 | }
40 | private KVItem(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); }
41 |
42 | private static final KVItem defaultInstance;
43 | public static KVItem getDefaultInstance() {
44 | return defaultInstance;
45 | }
46 |
47 | public KVItem getDefaultInstanceForType() {
48 | return defaultInstance;
49 | }
50 |
51 | private final com.google.protobuf.UnknownFieldSet unknownFields;
52 | @java.lang.Override
53 | public final com.google.protobuf.UnknownFieldSet
54 | getUnknownFields() {
55 | return this.unknownFields;
56 | }
57 | private KVItem(
58 | com.google.protobuf.CodedInputStream input,
59 | com.google.protobuf.ExtensionRegistryLite extensionRegistry)
60 | throws com.google.protobuf.InvalidProtocolBufferException {
61 | initFields();
62 | int mutable_bitField0_ = 0;
63 | com.google.protobuf.UnknownFieldSet.Builder unknownFields =
64 | com.google.protobuf.UnknownFieldSet.newBuilder();
65 | try {
66 | boolean done = false;
67 | while (!done) {
68 | int tag = input.readTag();
69 | switch (tag) {
70 | case 0:
71 | done = true;
72 | break;
73 | default: {
74 | if (!parseUnknownField(input, unknownFields,
75 | extensionRegistry, tag)) {
76 | done = true;
77 | }
78 | break;
79 | }
80 | case 10: {
81 | bitField0_ |= 0x00000001;
82 | command_ = input.readBytes();
83 | break;
84 | }
85 | }
86 | }
87 | } catch (com.google.protobuf.InvalidProtocolBufferException e) {
88 | throw e.setUnfinishedMessage(this);
89 | } catch (java.io.IOException e) {
90 | throw new com.google.protobuf.InvalidProtocolBufferException(
91 | e.getMessage()).setUnfinishedMessage(this);
92 | } finally {
93 | this.unknownFields = unknownFields.build();
94 | makeExtensionsImmutable();
95 | }
96 | }
97 | public static final com.google.protobuf.Descriptors.Descriptor
98 | getDescriptor() {
99 | return net.demo.proto.KVCommand.internal_static_KVItem_descriptor;
100 | }
101 |
102 | protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
103 | internalGetFieldAccessorTable() {
104 | return net.demo.proto.KVCommand.internal_static_KVItem_fieldAccessorTable
105 | .ensureFieldAccessorsInitialized(
106 | net.demo.proto.KVCommand.KVItem.class, net.demo.proto.KVCommand.KVItem.Builder.class);
107 | }
108 |
109 | public static com.google.protobuf.Parser PARSER =
110 | new com.google.protobuf.AbstractParser() {
111 | public KVItem parsePartialFrom(
112 | com.google.protobuf.CodedInputStream input,
113 | com.google.protobuf.ExtensionRegistryLite extensionRegistry)
114 | throws com.google.protobuf.InvalidProtocolBufferException {
115 | return new KVItem(input, extensionRegistry);
116 | }
117 | };
118 |
119 | @java.lang.Override
120 | public com.google.protobuf.Parser getParserForType() {
121 | return PARSER;
122 | }
123 |
124 | private int bitField0_;
125 | // required string command = 1;
126 | public static final int COMMAND_FIELD_NUMBER = 1;
127 | private java.lang.Object command_;
128 | /**
129 | * required string command = 1;
130 | */
131 | public boolean hasCommand() {
132 | return ((bitField0_ & 0x00000001) == 0x00000001);
133 | }
134 | /**
135 | * required string command = 1;
136 | */
137 | public java.lang.String getCommand() {
138 | java.lang.Object ref = command_;
139 | if (ref instanceof java.lang.String) {
140 | return (java.lang.String) ref;
141 | } else {
142 | com.google.protobuf.ByteString bs =
143 | (com.google.protobuf.ByteString) ref;
144 | java.lang.String s = bs.toStringUtf8();
145 | if (bs.isValidUtf8()) {
146 | command_ = s;
147 | }
148 | return s;
149 | }
150 | }
151 | /**
152 | * required string command = 1;
153 | */
154 | public com.google.protobuf.ByteString
155 | getCommandBytes() {
156 | java.lang.Object ref = command_;
157 | if (ref instanceof java.lang.String) {
158 | com.google.protobuf.ByteString b =
159 | com.google.protobuf.ByteString.copyFromUtf8(
160 | (java.lang.String) ref);
161 | command_ = b;
162 | return b;
163 | } else {
164 | return (com.google.protobuf.ByteString) ref;
165 | }
166 | }
167 |
168 | private void initFields() {
169 | command_ = "";
170 | }
171 | private byte memoizedIsInitialized = -1;
172 | public final boolean isInitialized() {
173 | byte isInitialized = memoizedIsInitialized;
174 | if (isInitialized != -1) return isInitialized == 1;
175 |
176 | if (!hasCommand()) {
177 | memoizedIsInitialized = 0;
178 | return false;
179 | }
180 | memoizedIsInitialized = 1;
181 | return true;
182 | }
183 |
184 | public void writeTo(com.google.protobuf.CodedOutputStream output)
185 | throws java.io.IOException {
186 | getSerializedSize();
187 | if (((bitField0_ & 0x00000001) == 0x00000001)) {
188 | output.writeBytes(1, getCommandBytes());
189 | }
190 | getUnknownFields().writeTo(output);
191 | }
192 |
193 | private int memoizedSerializedSize = -1;
194 | public int getSerializedSize() {
195 | int size = memoizedSerializedSize;
196 | if (size != -1) return size;
197 |
198 | size = 0;
199 | if (((bitField0_ & 0x00000001) == 0x00000001)) {
200 | size += com.google.protobuf.CodedOutputStream
201 | .computeBytesSize(1, getCommandBytes());
202 | }
203 | size += getUnknownFields().getSerializedSize();
204 | memoizedSerializedSize = size;
205 | return size;
206 | }
207 |
208 | private static final long serialVersionUID = 0L;
209 | @java.lang.Override
210 | protected java.lang.Object writeReplace()
211 | throws java.io.ObjectStreamException {
212 | return super.writeReplace();
213 | }
214 |
215 | public static net.demo.proto.KVCommand.KVItem parseFrom(
216 | com.google.protobuf.ByteString data)
217 | throws com.google.protobuf.InvalidProtocolBufferException {
218 | return PARSER.parseFrom(data);
219 | }
220 | public static net.demo.proto.KVCommand.KVItem parseFrom(
221 | com.google.protobuf.ByteString data,
222 | com.google.protobuf.ExtensionRegistryLite extensionRegistry)
223 | throws com.google.protobuf.InvalidProtocolBufferException {
224 | return PARSER.parseFrom(data, extensionRegistry);
225 | }
226 | public static net.demo.proto.KVCommand.KVItem parseFrom(byte[] data)
227 | throws com.google.protobuf.InvalidProtocolBufferException {
228 | return PARSER.parseFrom(data);
229 | }
230 | public static net.demo.proto.KVCommand.KVItem parseFrom(
231 | byte[] data,
232 | com.google.protobuf.ExtensionRegistryLite extensionRegistry)
233 | throws com.google.protobuf.InvalidProtocolBufferException {
234 | return PARSER.parseFrom(data, extensionRegistry);
235 | }
236 | public static net.demo.proto.KVCommand.KVItem parseFrom(java.io.InputStream input)
237 | throws java.io.IOException {
238 | return PARSER.parseFrom(input);
239 | }
240 | public static net.demo.proto.KVCommand.KVItem parseFrom(
241 | java.io.InputStream input,
242 | com.google.protobuf.ExtensionRegistryLite extensionRegistry)
243 | throws java.io.IOException {
244 | return PARSER.parseFrom(input, extensionRegistry);
245 | }
246 | public static net.demo.proto.KVCommand.KVItem parseDelimitedFrom(java.io.InputStream input)
247 | throws java.io.IOException {
248 | return PARSER.parseDelimitedFrom(input);
249 | }
250 | public static net.demo.proto.KVCommand.KVItem parseDelimitedFrom(
251 | java.io.InputStream input,
252 | com.google.protobuf.ExtensionRegistryLite extensionRegistry)
253 | throws java.io.IOException {
254 | return PARSER.parseDelimitedFrom(input, extensionRegistry);
255 | }
256 | public static net.demo.proto.KVCommand.KVItem parseFrom(
257 | com.google.protobuf.CodedInputStream input)
258 | throws java.io.IOException {
259 | return PARSER.parseFrom(input);
260 | }
261 | public static net.demo.proto.KVCommand.KVItem parseFrom(
262 | com.google.protobuf.CodedInputStream input,
263 | com.google.protobuf.ExtensionRegistryLite extensionRegistry)
264 | throws java.io.IOException {
265 | return PARSER.parseFrom(input, extensionRegistry);
266 | }
267 |
268 | public static Builder newBuilder() { return Builder.create(); }
269 | public Builder newBuilderForType() { return newBuilder(); }
270 | public static Builder newBuilder(net.demo.proto.KVCommand.KVItem prototype) {
271 | return newBuilder().mergeFrom(prototype);
272 | }
273 | public Builder toBuilder() { return newBuilder(this); }
274 |
275 | @java.lang.Override
276 | protected Builder newBuilderForType(
277 | com.google.protobuf.GeneratedMessage.BuilderParent parent) {
278 | Builder builder = new Builder(parent);
279 | return builder;
280 | }
281 | /**
282 | * Protobuf type {@code KVItem}
283 | */
284 | public static final class Builder extends
285 | com.google.protobuf.GeneratedMessage.Builder
286 | implements net.demo.proto.KVCommand.KVItemOrBuilder {
287 | public static final com.google.protobuf.Descriptors.Descriptor
288 | getDescriptor() {
289 | return net.demo.proto.KVCommand.internal_static_KVItem_descriptor;
290 | }
291 |
292 | protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
293 | internalGetFieldAccessorTable() {
294 | return net.demo.proto.KVCommand.internal_static_KVItem_fieldAccessorTable
295 | .ensureFieldAccessorsInitialized(
296 | net.demo.proto.KVCommand.KVItem.class, net.demo.proto.KVCommand.KVItem.Builder.class);
297 | }
298 |
299 | // Construct using net.demo.proto.KVCommand.KVItem.newBuilder()
300 | private Builder() {
301 | maybeForceBuilderInitialization();
302 | }
303 |
304 | private Builder(
305 | com.google.protobuf.GeneratedMessage.BuilderParent parent) {
306 | super(parent);
307 | maybeForceBuilderInitialization();
308 | }
309 | private void maybeForceBuilderInitialization() {
310 | if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
311 | }
312 | }
313 | private static Builder create() {
314 | return new Builder();
315 | }
316 |
317 | public Builder clear() {
318 | super.clear();
319 | command_ = "";
320 | bitField0_ = (bitField0_ & ~0x00000001);
321 | return this;
322 | }
323 |
324 | public Builder clone() {
325 | return create().mergeFrom(buildPartial());
326 | }
327 |
328 | public com.google.protobuf.Descriptors.Descriptor
329 | getDescriptorForType() {
330 | return net.demo.proto.KVCommand.internal_static_KVItem_descriptor;
331 | }
332 |
333 | public net.demo.proto.KVCommand.KVItem getDefaultInstanceForType() {
334 | return net.demo.proto.KVCommand.KVItem.getDefaultInstance();
335 | }
336 |
337 | public net.demo.proto.KVCommand.KVItem build() {
338 | net.demo.proto.KVCommand.KVItem result = buildPartial();
339 | if (!result.isInitialized()) {
340 | throw newUninitializedMessageException(result);
341 | }
342 | return result;
343 | }
344 |
345 | public net.demo.proto.KVCommand.KVItem buildPartial() {
346 | net.demo.proto.KVCommand.KVItem result = new net.demo.proto.KVCommand.KVItem(this);
347 | int from_bitField0_ = bitField0_;
348 | int to_bitField0_ = 0;
349 | if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
350 | to_bitField0_ |= 0x00000001;
351 | }
352 | result.command_ = command_;
353 | result.bitField0_ = to_bitField0_;
354 | onBuilt();
355 | return result;
356 | }
357 |
358 | public Builder mergeFrom(com.google.protobuf.Message other) {
359 | if (other instanceof net.demo.proto.KVCommand.KVItem) {
360 | return mergeFrom((net.demo.proto.KVCommand.KVItem)other);
361 | } else {
362 | super.mergeFrom(other);
363 | return this;
364 | }
365 | }
366 |
367 | public Builder mergeFrom(net.demo.proto.KVCommand.KVItem other) {
368 | if (other == net.demo.proto.KVCommand.KVItem.getDefaultInstance()) return this;
369 | if (other.hasCommand()) {
370 | bitField0_ |= 0x00000001;
371 | command_ = other.command_;
372 | onChanged();
373 | }
374 | this.mergeUnknownFields(other.getUnknownFields());
375 | return this;
376 | }
377 |
378 | public final boolean isInitialized() {
379 | if (!hasCommand()) {
380 |
381 | return false;
382 | }
383 | return true;
384 | }
385 |
386 | public Builder mergeFrom(
387 | com.google.protobuf.CodedInputStream input,
388 | com.google.protobuf.ExtensionRegistryLite extensionRegistry)
389 | throws java.io.IOException {
390 | net.demo.proto.KVCommand.KVItem parsedMessage = null;
391 | try {
392 | parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
393 | } catch (com.google.protobuf.InvalidProtocolBufferException e) {
394 | parsedMessage = (net.demo.proto.KVCommand.KVItem) e.getUnfinishedMessage();
395 | throw e;
396 | } finally {
397 | if (parsedMessage != null) {
398 | mergeFrom(parsedMessage);
399 | }
400 | }
401 | return this;
402 | }
403 | private int bitField0_;
404 |
405 | // required string command = 1;
406 | private java.lang.Object command_ = "";
407 | /**
408 | * required string command = 1;
409 | */
410 | public boolean hasCommand() {
411 | return ((bitField0_ & 0x00000001) == 0x00000001);
412 | }
413 | /**
414 | * required string command = 1;
415 | */
416 | public java.lang.String getCommand() {
417 | java.lang.Object ref = command_;
418 | if (!(ref instanceof java.lang.String)) {
419 | java.lang.String s = ((com.google.protobuf.ByteString) ref)
420 | .toStringUtf8();
421 | command_ = s;
422 | return s;
423 | } else {
424 | return (java.lang.String) ref;
425 | }
426 | }
427 | /**
428 | * required string command = 1;
429 | */
430 | public com.google.protobuf.ByteString
431 | getCommandBytes() {
432 | java.lang.Object ref = command_;
433 | if (ref instanceof String) {
434 | com.google.protobuf.ByteString b =
435 | com.google.protobuf.ByteString.copyFromUtf8(
436 | (java.lang.String) ref);
437 | command_ = b;
438 | return b;
439 | } else {
440 | return (com.google.protobuf.ByteString) ref;
441 | }
442 | }
443 | /**
444 | * required string command = 1;
445 | */
446 | public Builder setCommand(
447 | java.lang.String value) {
448 | if (value == null) {
449 | throw new NullPointerException();
450 | }
451 | bitField0_ |= 0x00000001;
452 | command_ = value;
453 | onChanged();
454 | return this;
455 | }
456 | /**
457 | * required string command = 1;
458 | */
459 | public Builder clearCommand() {
460 | bitField0_ = (bitField0_ & ~0x00000001);
461 | command_ = getDefaultInstance().getCommand();
462 | onChanged();
463 | return this;
464 | }
465 | /**
466 | * required string command = 1;
467 | */
468 | public Builder setCommandBytes(
469 | com.google.protobuf.ByteString value) {
470 | if (value == null) {
471 | throw new NullPointerException();
472 | }
473 | bitField0_ |= 0x00000001;
474 | command_ = value;
475 | onChanged();
476 | return this;
477 | }
478 |
479 | // @@protoc_insertion_point(builder_scope:KVItem)
480 | }
481 |
482 | static {
483 | defaultInstance = new KVItem(true);
484 | defaultInstance.initFields();
485 | }
486 |
487 | // @@protoc_insertion_point(class_scope:KVItem)
488 | }
489 |
490 | private static com.google.protobuf.Descriptors.Descriptor
491 | internal_static_KVItem_descriptor;
492 | private static
493 | com.google.protobuf.GeneratedMessage.FieldAccessorTable
494 | internal_static_KVItem_fieldAccessorTable;
495 |
496 | public static com.google.protobuf.Descriptors.FileDescriptor
497 | getDescriptor() {
498 | return descriptor;
499 | }
500 | private static com.google.protobuf.Descriptors.FileDescriptor
501 | descriptor;
502 | static {
503 | java.lang.String[] descriptorData = {
504 | "\n\017KVCommand.proto\"\031\n\006KVItem\022\017\n\007command\030\001" +
505 | " \002(\tB\033\n\016net.demo.protoB\tKVCommand"
506 | };
507 | com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
508 | new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
509 | public com.google.protobuf.ExtensionRegistry assignDescriptors(
510 | com.google.protobuf.Descriptors.FileDescriptor root) {
511 | descriptor = root;
512 | internal_static_KVItem_descriptor =
513 | getDescriptor().getMessageTypes().get(0);
514 | internal_static_KVItem_fieldAccessorTable = new
515 | com.google.protobuf.GeneratedMessage.FieldAccessorTable(
516 | internal_static_KVItem_descriptor,
517 | new java.lang.String[] { "Command", });
518 | return null;
519 | }
520 | };
521 | com.google.protobuf.Descriptors.FileDescriptor
522 | .internalBuildGeneratedFileFrom(descriptorData,
523 | new com.google.protobuf.Descriptors.FileDescriptor[] {
524 | }, assigner);
525 | }
526 |
527 | // @@protoc_insertion_point(outer_class_scope)
528 | }
529 |
--------------------------------------------------------------------------------
/c#/Example/Assets/Plugins/Message/ProtocolParser.cs:
--------------------------------------------------------------------------------
1 | #region ProtocolParser
2 | using System;
3 | using System.IO;
4 | using System.Text;
5 |
6 | //
7 | // Read/Write string and byte arrays
8 | //
9 | namespace SilentOrbit.ProtocolBuffers
10 | {
11 | public static partial class ProtocolParser
12 | {
13 | public static string ReadString(Stream stream)
14 | {
15 | return Encoding.UTF8.GetString(ReadBytes(stream));
16 | }
17 |
18 | ///
19 | /// Reads a length delimited byte array
20 | ///
21 | public static byte[] ReadBytes(Stream stream)
22 | {
23 | //VarInt length
24 | int length = (int)ReadUInt32(stream);
25 |
26 | //Bytes
27 | byte[] buffer = new byte[length];
28 | int read = 0;
29 | while (read < length)
30 | {
31 | int r = stream.Read(buffer, read, length - read);
32 | if (r == 0)
33 | throw new Exception("Expected " + (length - read) + " got " + read);
34 | read += r;
35 | }
36 | return buffer;
37 | }
38 |
39 | ///
40 | /// Skip the next varint length prefixed bytes.
41 | /// Alternative to ReadBytes when the data is not of interest.
42 | ///
43 | public static void SkipBytes(Stream stream)
44 | {
45 | int length = (int)ReadUInt32(stream);
46 | if (stream.CanSeek)
47 | stream.Seek(length, SeekOrigin.Current);
48 | else
49 | ReadBytes(stream);
50 | }
51 |
52 | public static void WriteString(Stream stream, string val)
53 | {
54 | WriteBytes(stream, Encoding.UTF8.GetBytes(val));
55 | }
56 |
57 | ///
58 | /// Writes length delimited byte array
59 | ///
60 | public static void WriteBytes(Stream stream, byte[] val)
61 | {
62 | WriteUInt32(stream, (uint)val.Length);
63 | stream.Write(val, 0, val.Length);
64 | }
65 | }
66 |
67 | ///
68 | /// Wrapper for streams that does not support the Position property
69 | ///
70 | public class StreamRead : Stream
71 | {
72 | Stream stream;
73 |
74 | ///
75 | /// Bytes left to read
76 | ///
77 | public int BytesRead { get; private set; }
78 |
79 | ///
80 | /// Define how many bytes are allowed to read
81 | ///
82 | ///
83 | /// Base stream.
84 | ///
85 | ///
86 | /// Max length allowed to read from the stream.
87 | ///
88 | public StreamRead(Stream baseStream)
89 | {
90 | this.stream = baseStream;
91 | }
92 |
93 | public override void Flush()
94 | {
95 | throw new Exception();
96 | }
97 |
98 | public override int Read(byte[] buffer, int offset, int count)
99 | {
100 | int read = stream.Read(buffer, offset, count);
101 | BytesRead += read;
102 | return read;
103 | }
104 |
105 | public override int ReadByte()
106 | {
107 | int b = stream.ReadByte();
108 | BytesRead += 1;
109 | return b;
110 | }
111 |
112 | public override long Seek(long offset, SeekOrigin origin)
113 | {
114 | throw new Exception();
115 | }
116 |
117 | public override void SetLength(long value)
118 | {
119 | throw new Exception();
120 | }
121 |
122 | public override void Write(byte[] buffer, int offset, int count)
123 | {
124 | throw new Exception();
125 | }
126 |
127 | public override bool CanRead
128 | {
129 | get
130 | {
131 | return true;
132 | }
133 | }
134 |
135 | public override bool CanSeek
136 | {
137 | get
138 | {
139 | return false;
140 | }
141 | }
142 |
143 | public override bool CanWrite
144 | {
145 | get
146 | {
147 | return false;
148 | }
149 | }
150 |
151 | public override long Length
152 | {
153 | get
154 | {
155 | return stream.Length;
156 | }
157 | }
158 |
159 | public override long Position
160 | {
161 | get
162 | {
163 | return this.BytesRead;
164 | }
165 | set
166 | {
167 | throw new Exception();
168 | }
169 | }
170 | }
171 | }
172 |
173 | #endregion
174 | #region ProtocolParserFixed
175 | //
176 | // This file contain references on how to write and read
177 | // fixed integers and float/double.
178 | //
179 |
180 | namespace SilentOrbit.ProtocolBuffers
181 | {
182 | public static partial class ProtocolParser
183 | {
184 | #region Fixed Int, Only for reference
185 | ///
186 | /// Only for reference
187 | ///
188 | [Obsolete("Only for reference")]
189 | public static ulong ReadFixed64(BinaryReader reader)
190 | {
191 | return reader.ReadUInt64();
192 | }
193 |
194 | ///
195 | /// Only for reference
196 | ///
197 | [Obsolete("Only for reference")]
198 | public static long ReadSFixed64(BinaryReader reader)
199 | {
200 | return reader.ReadInt64();
201 | }
202 |
203 | ///
204 | /// Only for reference
205 | ///
206 | [Obsolete("Only for reference")]
207 | public static uint ReadFixed32(BinaryReader reader)
208 | {
209 | return reader.ReadUInt32();
210 | }
211 |
212 | ///
213 | /// Only for reference
214 | ///
215 | [Obsolete("Only for reference")]
216 | public static int ReadSFixed32(BinaryReader reader)
217 | {
218 | return reader.ReadInt32();
219 | }
220 |
221 | ///
222 | /// Only for reference
223 | ///
224 | [Obsolete("Only for reference")]
225 | public static void WriteFixed64(BinaryWriter writer, ulong val)
226 | {
227 | writer.Write(val);
228 | }
229 |
230 | ///
231 | /// Only for reference
232 | ///
233 | [Obsolete("Only for reference")]
234 | public static void WriteSFixed64(BinaryWriter writer, long val)
235 | {
236 | writer.Write(val);
237 | }
238 |
239 | ///
240 | /// Only for reference
241 | ///
242 | [Obsolete("Only for reference")]
243 | public static void WriteFixed32(BinaryWriter writer, uint val)
244 | {
245 | writer.Write(val);
246 | }
247 |
248 | ///
249 | /// Only for reference
250 | ///
251 | [Obsolete("Only for reference")]
252 | public static void WriteSFixed32(BinaryWriter writer, int val)
253 | {
254 | writer.Write(val);
255 | }
256 | #endregion
257 | #region Fixed: float, double. Only for reference
258 | ///
259 | /// Only for reference
260 | ///
261 | [Obsolete("Only for reference")]
262 | public static float ReadFloat(BinaryReader reader)
263 | {
264 | return reader.ReadSingle();
265 | }
266 |
267 | ///
268 | /// Only for reference
269 | ///
270 | [Obsolete("Only for reference")]
271 | public static double ReadDouble(BinaryReader reader)
272 | {
273 | return reader.ReadDouble();
274 | }
275 |
276 | ///
277 | /// Only for reference
278 | ///
279 | [Obsolete("Only for reference")]
280 | public static void WriteFloat(BinaryWriter writer, float val)
281 | {
282 | writer.Write(val);
283 | }
284 |
285 | ///
286 | /// Only for reference
287 | ///
288 | [Obsolete("Only for reference")]
289 | public static void WriteDouble(BinaryWriter writer, double val)
290 | {
291 | writer.Write(val);
292 | }
293 | #endregion
294 | }
295 | }
296 |
297 | #endregion
298 | #region ProtocolParserKey
299 | //
300 | // Reader/Writer for field key
301 | //
302 |
303 | namespace SilentOrbit.ProtocolBuffers
304 | {
305 | public enum Wire
306 | {
307 | Varint = 0,
308 | //int32, int64, UInt32, UInt64, SInt32, SInt64, bool, enum
309 | Fixed64 = 1,
310 | //fixed64, sfixed64, double
311 | LengthDelimited = 2,
312 | //string, bytes, embedded messages, packed repeated fields
313 | //Start = 3, // groups (deprecated)
314 | //End = 4, // groups (deprecated)
315 | Fixed32 = 5,
316 | //32-bit fixed32, SFixed32, float
317 | }
318 |
319 | public class Key
320 | {
321 | public uint Field { get; set; }
322 |
323 | public Wire WireType { get; set; }
324 |
325 | public Key(uint field, Wire wireType)
326 | {
327 | this.Field = field;
328 | this.WireType = wireType;
329 | }
330 |
331 | public override string ToString()
332 | {
333 | return string.Format("[Key: {0}, {1}]", Field, WireType);
334 | }
335 | }
336 |
337 | ///
338 | /// Storage of unknown fields
339 | ///
340 | public class KeyValue
341 | {
342 | public Key Key { get; set; }
343 |
344 | public byte[] Value { get; set; }
345 |
346 | public KeyValue(Key key, byte[] value)
347 | {
348 | this.Key = key;
349 | this.Value = value;
350 | }
351 |
352 | public override string ToString()
353 | {
354 | return string.Format("[KeyValue: {0}, {1}, {2} bytes]", Key.Field, Key.WireType, Value.Length);
355 | }
356 | }
357 |
358 | public static partial class ProtocolParser
359 | {
360 |
361 | public static Key ReadKey(Stream stream)
362 | {
363 | uint n = ReadUInt32(stream);
364 | return new Key(n >> 3, (Wire)(n & 0x07));
365 | }
366 |
367 | public static Key ReadKey(byte firstByte, Stream stream)
368 | {
369 | if (firstByte < 128)
370 | return new Key((uint)(firstByte >> 3), (Wire)(firstByte & 0x07));
371 | uint fieldID = ((uint)ReadUInt32(stream) << 4) | ((uint)(firstByte >> 3) & 0x0F);
372 | return new Key(fieldID, (Wire)(firstByte & 0x07));
373 | }
374 |
375 | public static void WriteKey(Stream stream, Key key)
376 | {
377 | uint n = (key.Field << 3) | ((uint)key.WireType);
378 | WriteUInt32(stream, n);
379 | }
380 |
381 | ///
382 | /// Seek past the value for the previously read key.
383 | ///
384 | public static void SkipKey(Stream stream, Key key)
385 | {
386 | switch (key.WireType)
387 | {
388 | case Wire.Fixed32:
389 | stream.Seek(4, SeekOrigin.Current);
390 | return;
391 | case Wire.Fixed64:
392 | stream.Seek(8, SeekOrigin.Current);
393 | return;
394 | case Wire.LengthDelimited:
395 | stream.Seek(ProtocolParser.ReadUInt32(stream), SeekOrigin.Current);
396 | return;
397 | case Wire.Varint:
398 | ProtocolParser.ReadSkipVarInt(stream);
399 | return;
400 | default:
401 | throw new Exception("Unknown wire type: " + key.WireType);
402 | }
403 | }
404 |
405 | ///
406 | /// Read the value for an unknown key as bytes.
407 | /// Used to preserve unknown keys during deserialization.
408 | /// Requires the message option preserveunknown=true.
409 | ///
410 | public static byte[] ReadValueBytes(Stream stream, Key key)
411 | {
412 | byte[] b;
413 | int offset = 0;
414 |
415 | switch (key.WireType)
416 | {
417 | case Wire.Fixed32:
418 | b = new byte[4];
419 | while (offset < 4)
420 | offset += stream.Read(b, offset, 4 - offset);
421 | return b;
422 | case Wire.Fixed64:
423 | b = new byte[8];
424 | while (offset < 8)
425 | offset += stream.Read(b, offset, 8 - offset);
426 | return b;
427 | case Wire.LengthDelimited:
428 | //Read and include length in value buffer
429 | uint length = ProtocolParser.ReadUInt32(stream);
430 | using (var ms = new MemoryStream ())
431 | {
432 | //TODO: pass b directly to MemoryStream constructor or skip usage of it completely
433 | ProtocolParser.WriteUInt32(ms, length);
434 | b = new byte[length + ms.Length];
435 | ms.ToArray().CopyTo(b, 0);
436 | offset = (int)ms.Length;
437 | }
438 |
439 | //Read data into buffer
440 | while (offset < b.Length)
441 | offset += stream.Read(b, offset, b.Length - offset);
442 | return b;
443 | case Wire.Varint:
444 | return ProtocolParser.ReadVarIntBytes(stream);
445 | default:
446 | throw new Exception("Unknown wire type: " + key.WireType);
447 | }
448 | }
449 | }
450 | }
451 |
452 | #endregion
453 | #region ProtocolParserVarInt
454 |
455 | namespace SilentOrbit.ProtocolBuffers
456 | {
457 | public static partial class ProtocolParser
458 | {
459 | ///
460 | /// Reads past a varint for an unknown field.
461 | ///
462 | public static void ReadSkipVarInt(Stream stream)
463 | {
464 | while (true)
465 | {
466 | int b = stream.ReadByte();
467 | if (b < 0)
468 | throw new IOException("Stream ended too early");
469 |
470 | if ((b & 0x80) == 0)
471 | return; //end of varint
472 | }
473 | }
474 |
475 | public static byte[] ReadVarIntBytes(Stream stream)
476 | {
477 | byte[] buffer = new byte[10];
478 | int offset = 0;
479 | while (true)
480 | {
481 | int b = stream.ReadByte();
482 | if (b < 0)
483 | throw new IOException("Stream ended too early");
484 | buffer[offset] = (byte)b;
485 | offset += 1;
486 | if ((b & 0x80) == 0)
487 | break; //end of varint
488 | if (offset >= buffer.Length)
489 | throw new Exception("VarInt too long, more than 10 bytes");
490 | }
491 | byte[] ret = new byte[offset];
492 | Array.Copy(buffer, ret, ret.Length);
493 | return ret;
494 | }
495 | #region VarInt: int32, uint32, sint32
496 | [Obsolete("Use (int)ReadUInt64(stream); //yes 64")]
497 | ///
498 | /// Since the int32 format is inefficient for negative numbers we have avoided to implement it.
499 | /// The same functionality can be achieved using: (int)ReadUInt64(stream);
500 | ///
501 | public static int ReadInt32(Stream stream)
502 | {
503 | return (int)ReadUInt64(stream);
504 | }
505 |
506 | [Obsolete("Use WriteUInt64(stream, (ulong)val); //yes 64, negative numbers are encoded that way")]
507 | ///
508 | /// Since the int32 format is inefficient for negative numbers we have avoided to imlplement.
509 | /// The same functionality can be achieved using: WriteUInt64(stream, (uint)val);
510 | /// Note that 64 must always be used for int32 to generate the ten byte wire format.
511 | ///
512 | public static void WriteInt32(Stream stream, int val)
513 | {
514 | //signed varint is always encoded as 64 but values!
515 | WriteUInt64(stream, (ulong)val);
516 | }
517 |
518 | ///
519 | /// Zig-zag signed VarInt format
520 | ///
521 | public static int ReadZInt32(Stream stream)
522 | {
523 | uint val = ReadUInt32(stream);
524 | return (int)(val >> 1) ^ ((int)(val << 31) >> 31);
525 | }
526 |
527 | ///
528 | /// Zig-zag signed VarInt format
529 | ///
530 | public static void WriteZInt32(Stream stream, int val)
531 | {
532 | WriteUInt32(stream, (uint)((val << 1) ^ (val >> 31)));
533 | }
534 |
535 | ///
536 | /// Unsigned VarInt format
537 | /// Do not use to read int32, use ReadUint64 for that.
538 | ///
539 | public static uint ReadUInt32(Stream stream)
540 | {
541 | int b;
542 | uint val = 0;
543 |
544 | for (int n = 0; n < 5; n++)
545 | {
546 | b = stream.ReadByte();
547 | if (b < 0)
548 | throw new IOException("Stream ended too early");
549 |
550 | //Check that it fits in 32 bits
551 | if ((n == 4) && (b & 0xF0) != 0)
552 | throw new Exception("Got larger VarInt than 32bit unsigned");
553 | //End of check
554 |
555 | if ((b & 0x80) == 0)
556 | return val | (uint)b << (7 * n);
557 |
558 | val |= (uint)(b & 0x7F) << (7 * n);
559 | }
560 |
561 | throw new Exception("Got larger VarInt than 32bit unsigned");
562 | }
563 |
564 | ///
565 | /// Unsigned VarInt format
566 | ///
567 | public static void WriteUInt32(Stream stream, uint val)
568 | {
569 | byte[] buffer = new byte[5];
570 | int count = 0;
571 |
572 | while (true)
573 | {
574 | buffer[count] = (byte)(val & 0x7F);
575 | val = val >> 7;
576 | if (val == 0)
577 | break;
578 |
579 | buffer[count] |= 0x80;
580 |
581 | count += 1;
582 | }
583 |
584 | stream.Write(buffer, 0, count + 1);
585 | }
586 | #endregion
587 | #region VarInt: int64, UInt64, SInt64
588 | [Obsolete("Use (long)ReadUInt64(stream); instead")]
589 | ///
590 | /// Since the int64 format is inefficient for negative numbers we have avoided to implement it.
591 | /// The same functionality can be achieved using: (long)ReadUInt64(stream);
592 | ///
593 | public static int ReadInt64(Stream stream)
594 | {
595 | return (int)ReadUInt64(stream);
596 | }
597 |
598 | [Obsolete("Use WriteUInt64 (stream, (ulong)val); instead")]
599 | ///
600 | /// Since the int64 format is inefficient for negative numbers we have avoided to implement.
601 | /// The same functionality can be achieved using: WriteUInt64 (stream, (ulong)val);
602 | ///
603 | public static void WriteInt64(Stream stream, int val)
604 | {
605 | WriteUInt64(stream, (ulong)val);
606 | }
607 |
608 | ///
609 | /// Zig-zag signed VarInt format
610 | ///
611 | public static long ReadZInt64(Stream stream)
612 | {
613 | ulong val = ReadUInt64(stream);
614 | return (long)(val >> 1) ^ ((long)(val << 63) >> 63);
615 | }
616 |
617 | ///
618 | /// Zig-zag signed VarInt format
619 | ///
620 | public static void WriteZInt64(Stream stream, long val)
621 | {
622 | WriteUInt64(stream, (ulong)((val << 1) ^ (val >> 63)));
623 | }
624 |
625 | ///
626 | /// Unsigned VarInt format
627 | ///
628 | public static ulong ReadUInt64(Stream stream)
629 | {
630 | int b;
631 | ulong val = 0;
632 |
633 | for (int n = 0; n < 10; n++)
634 | {
635 | b = stream.ReadByte();
636 | if (b < 0)
637 | throw new IOException("Stream ended too early");
638 |
639 | //Check that it fits in 64 bits
640 | if ((n == 9) && (b & 0xFE) != 0)
641 | throw new Exception("Got larger VarInt than 64 bit unsigned");
642 | //End of check
643 |
644 | if ((b & 0x80) == 0)
645 | return val | (ulong)b << (7 * n);
646 |
647 | val |= (ulong)(b & 0x7F) << (7 * n);
648 | }
649 |
650 | throw new Exception("Got larger VarInt than 64 bit unsigned");
651 | }
652 |
653 | ///
654 | /// Unsigned VarInt format
655 | ///
656 | public static void WriteUInt64(Stream stream, ulong val)
657 | {
658 | byte[] buffer = new byte[10];
659 | int count = 0;
660 |
661 | while (true)
662 | {
663 | buffer[count] = (byte)(val & 0x7F);
664 | val = val >> 7;
665 | if (val == 0)
666 | break;
667 |
668 | buffer[count] |= 0x80;
669 |
670 | count += 1;
671 | }
672 |
673 | stream.Write(buffer, 0, count + 1);
674 | }
675 | #endregion
676 | #region Varint: bool
677 | public static bool ReadBool(Stream stream)
678 | {
679 | int b = stream.ReadByte();
680 | if (b < 0)
681 | throw new IOException("Stream ended too early");
682 | if (b == 1)
683 | return true;
684 | if (b == 0)
685 | return false;
686 | throw new Exception("Invalid boolean value");
687 | }
688 |
689 | public static void WriteBool(Stream stream, bool val)
690 | {
691 | stream.WriteByte(val ? (byte)1 : (byte)0);
692 | }
693 | #endregion
694 | }
695 | }
696 | #endregion
697 |
--------------------------------------------------------------------------------
/java/.idea/workspace.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 | localhost
291 | 5050
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
363 |
364 |
365 |
366 |
367 |
368 |
369 |
370 |
371 |
372 |
373 |
374 |
375 |
376 |
377 |
378 |
379 |
380 |
381 |
382 |
383 |
384 |
385 |
386 |
387 |
388 |
389 |
390 |
391 |
392 |
393 |
394 |
395 |
396 |
397 |
398 |
399 |
400 |
401 | No facets are configured
402 |
403 |
404 |
405 |
406 |
407 |
408 |
409 |
410 |
411 |
412 |
413 |
414 |
415 |
416 |
417 |
418 |
419 |
420 |
421 |
422 |
423 |
424 | 1.6
425 |
426 |
427 |
428 |
429 |
430 |
431 |
432 |
433 |
434 |
435 |
436 | test
437 |
438 |
439 |
440 |
441 |
442 |
443 |
444 |
445 |
446 |
447 |
448 | 1.6
449 |
450 |
451 |
452 |
453 |
454 |
455 |
456 |
457 |
458 |
459 |
460 |
461 |
462 |
463 |
464 |
465 |
466 |
467 |
468 |
469 |
470 |
471 |
472 |
473 |
--------------------------------------------------------------------------------
/java/java.iws:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
363 |
364 |
365 |
366 |
367 |
368 |
369 |
370 |
371 |
372 |
373 |
374 |
375 |
376 |
377 |
378 |
379 |
380 |
381 |
382 |
383 |
384 |
385 |
386 |
387 | localhost
388 | 5050
389 |
390 |
391 |
392 |
393 |
394 |
395 |
396 |
397 |
398 |
399 |
400 |
401 |
402 |
403 |
404 | false
405 |
406 |
407 |
408 |
409 |
410 |
411 |
412 |
413 |
414 |
415 |
416 |
417 |
418 |
419 |
420 |
421 |
422 |
423 |
424 |
425 |
426 |
427 |
428 |
429 |
430 |
431 |
432 |
433 |
434 |
435 |
436 |
437 |
438 |
439 |
440 |
441 |
442 |
443 |
444 |
445 |
446 |
447 |
448 |
449 |
450 |
451 |
452 |
453 |
454 |
455 |
456 |
457 |
458 |
459 |
460 |
461 |
462 |
463 |
464 |
465 |
466 |
467 |
468 |
469 |
470 |
471 |
472 |
473 |
474 |
475 |
476 |
477 |
478 |
479 |
480 |
481 |
482 |
483 |
484 |
485 |
486 |
487 |
488 |
489 |
490 |
491 |
492 |
493 |
494 |
495 |
496 |
497 |
498 |
499 |
500 |
501 |
502 |
503 |
504 |
505 |
506 |
507 |
508 |
509 |
510 |
511 |
512 |
513 |
514 |
515 |
516 |
517 |
518 |
519 |
520 |
521 |
522 |
523 |
524 |
525 |
526 |
527 |
528 |
529 |
530 |
531 |
532 |
533 |
534 |
535 |
536 |
537 |
538 |
539 |
540 |
541 |
542 |
543 |
544 |
545 |
546 |
547 |
548 |
549 |
550 |
551 |
552 |
553 |
554 |
555 |
556 |
557 |
558 |
559 |
560 |
561 |
562 |
563 |
564 |
565 |
566 |
567 |
568 |
569 |
570 |
571 |
572 |
573 |
574 |
575 |
576 |
577 |
578 |
579 |
580 |
581 |
582 |
583 |
584 |
585 |
586 |
587 |
588 |
589 |
590 |
591 |
592 |
593 |
594 |
595 |
596 |
597 |
598 |
599 |
600 |
601 |
--------------------------------------------------------------------------------