├── .gitattributes ├── .gitignore ├── LICENSE.txt ├── README.md ├── history ├── 0.1.2 │ ├── tatala-client-csharp │ │ ├── cfg │ │ │ └── controller.xml │ │ ├── src │ │ │ ├── Example │ │ │ │ └── Tatala │ │ │ │ │ ├── client │ │ │ │ │ ├── ChatRoomClient.cs │ │ │ │ │ └── TestClient.cs │ │ │ │ │ ├── model │ │ │ │ │ ├── AllTypeBean.cs │ │ │ │ │ └── TestAccount.cs │ │ │ │ │ └── proxy │ │ │ │ │ ├── ChatRoomClientDefaultProxy.cs │ │ │ │ │ ├── ChatRoomClientProxy.cs │ │ │ │ │ ├── TestClientProxy.cs │ │ │ │ │ └── wrapper │ │ │ │ │ ├── AllTypeBeanWrapper.cs │ │ │ │ │ └── TestAccountWrapper.cs │ │ │ └── QiLeYuan │ │ │ │ ├── Tatala │ │ │ │ ├── executor │ │ │ │ │ ├── LocalTarget.cs │ │ │ │ │ ├── ServerExecutor.cs │ │ │ │ │ ├── ServerTarget.cs │ │ │ │ │ └── SocketServerTarget.cs │ │ │ │ ├── proxy │ │ │ │ │ └── DefaultProxy.cs │ │ │ │ ├── socket │ │ │ │ │ ├── client │ │ │ │ │ │ ├── Future.cs │ │ │ │ │ │ ├── LongClientSession.cs │ │ │ │ │ │ ├── ShortClientSession.cs │ │ │ │ │ │ ├── SocketConnection.cs │ │ │ │ │ │ └── SocketController.cs │ │ │ │ │ ├── io │ │ │ │ │ │ ├── TransferInputStream.cs │ │ │ │ │ │ └── TransferOutputStream.cs │ │ │ │ │ ├── to │ │ │ │ │ │ ├── NewTransferObject.cs │ │ │ │ │ │ ├── StandardTransferObject.cs │ │ │ │ │ │ ├── TransferObject.cs │ │ │ │ │ │ ├── TransferObjectFactory.cs │ │ │ │ │ │ ├── TransferObjectWrapper.cs │ │ │ │ │ │ └── helper │ │ │ │ │ │ │ ├── BooleanMapHelper.cs │ │ │ │ │ │ │ ├── ByteArrayMapHelper.cs │ │ │ │ │ │ │ ├── ByteMapHelper.cs │ │ │ │ │ │ │ ├── CharMapHelper.cs │ │ │ │ │ │ │ ├── DateMapHelper.cs │ │ │ │ │ │ │ ├── DoubleArrayMapHelper.cs │ │ │ │ │ │ │ ├── DoubleMapHelper.cs │ │ │ │ │ │ │ ├── FloatArrayMapHelper.cs │ │ │ │ │ │ │ ├── FloatMapHelper.cs │ │ │ │ │ │ │ ├── IntArrayMapHelper.cs │ │ │ │ │ │ │ ├── IntMapHelper.cs │ │ │ │ │ │ │ ├── LongArrayMapHelper.cs │ │ │ │ │ │ │ ├── LongMapHelper.cs │ │ │ │ │ │ │ ├── ShortMapHelper.cs │ │ │ │ │ │ │ ├── StringArrayMapHelper.cs │ │ │ │ │ │ │ ├── StringMapHelper.cs │ │ │ │ │ │ │ └── WrapperMapHelper.cs │ │ │ │ │ └── util │ │ │ │ │ │ └── TransferUtil.cs │ │ │ │ └── util │ │ │ │ │ └── BlockingQueue.cs │ │ │ │ └── Tools │ │ │ │ ├── ICSharpCode │ │ │ │ └── SharpZipLib │ │ │ │ │ ├── Checksums │ │ │ │ │ ├── Adler32.cs │ │ │ │ │ ├── CRC32.cs │ │ │ │ │ ├── IChecksum.cs │ │ │ │ │ └── StrangeCRC.cs │ │ │ │ │ ├── Encryption │ │ │ │ │ ├── PkzipClassic.cs │ │ │ │ │ ├── ZipAESStream.cs │ │ │ │ │ └── ZipAESTransform.cs │ │ │ │ │ ├── Main.cs │ │ │ │ │ ├── SharpZipBaseException.cs │ │ │ │ │ └── Zip │ │ │ │ │ ├── Compression │ │ │ │ │ ├── Deflater.cs │ │ │ │ │ ├── DeflaterConstants.cs │ │ │ │ │ ├── DeflaterEngine.cs │ │ │ │ │ ├── DeflaterHuffman.cs │ │ │ │ │ ├── DeflaterPending.cs │ │ │ │ │ ├── Inflater.cs │ │ │ │ │ ├── InflaterDynHeader.cs │ │ │ │ │ ├── InflaterHuffmanTree.cs │ │ │ │ │ ├── PendingBuffer.cs │ │ │ │ │ └── Streams │ │ │ │ │ │ ├── DeflaterOutputStream.cs │ │ │ │ │ │ ├── InflaterInputStream.cs │ │ │ │ │ │ ├── OutputWindow.cs │ │ │ │ │ │ └── StreamManipulator.cs │ │ │ │ │ ├── ZipConstants.cs │ │ │ │ │ ├── ZipEntry.cs │ │ │ │ │ ├── ZipException.cs │ │ │ │ │ ├── ZipExtraData.cs │ │ │ │ │ └── ZipHelperStream.cs │ │ │ │ └── Xstream │ │ │ │ └── Core │ │ │ │ ├── ConditionalConverter.cs │ │ │ │ ├── ConversionException.cs │ │ │ │ ├── Converters │ │ │ │ ├── ArrayConverter.cs │ │ │ │ ├── BooleanConverter.cs │ │ │ │ ├── ByteConverter.cs │ │ │ │ ├── CDataConverter.cs │ │ │ │ ├── CharConverter.cs │ │ │ │ ├── Complex │ │ │ │ │ └── StringBuilderConverter.cs │ │ │ │ ├── DateTimeConverter.cs │ │ │ │ ├── DecimalConverter.cs │ │ │ │ ├── DoubleConverter.cs │ │ │ │ ├── EnumConverter.cs │ │ │ │ ├── FloatConverter.cs │ │ │ │ ├── GenericListConverter.cs │ │ │ │ ├── GuidConverter.cs │ │ │ │ ├── IntConverter.cs │ │ │ │ ├── LongConverter.cs │ │ │ │ ├── MethodInfoConverter.cs │ │ │ │ ├── NoopConverter.cs │ │ │ │ ├── NullConverter.cs │ │ │ │ ├── ObjectConverter.cs │ │ │ │ ├── PointerConverter.cs │ │ │ │ ├── ShortConverter.cs │ │ │ │ ├── StringConverter.cs │ │ │ │ ├── TargetForceLoader.cs │ │ │ │ ├── TimeSpanConverter.cs │ │ │ │ └── TypeConverter.cs │ │ │ │ ├── DynamicInstanceBuilder.cs │ │ │ │ ├── FileXStream.cs │ │ │ │ ├── IConverter.cs │ │ │ │ ├── IMarshalContext.cs │ │ │ │ ├── IXStream.cs │ │ │ │ ├── IdFields.cs │ │ │ │ ├── MarshalContext.cs │ │ │ │ ├── NullType.cs │ │ │ │ ├── ReferenceComparer.cs │ │ │ │ ├── XStream.cs │ │ │ │ ├── XStreamBase.cs │ │ │ │ └── XStreamMarshaller.cs │ │ └── tatala-client-csharp.csproj │ ├── tatala-java-example │ │ ├── build.xml │ │ ├── cfg │ │ │ ├── controller.xml │ │ │ ├── log4j.xml │ │ │ └── tatala.properties │ │ ├── chatroom.bat │ │ ├── chatroomserver.bat │ │ ├── client.bat │ │ ├── client2.bat │ │ ├── dist │ │ │ └── tatala-java-example.jar │ │ ├── easyclient.bat │ │ ├── lib │ │ │ ├── log4j-1.2.13.jar │ │ │ ├── tatala.jar │ │ │ ├── xpp3_min-1.1.4c.jar │ │ │ └── xstream-1.3.1.jar │ │ ├── server.bat │ │ └── src │ │ │ └── com │ │ │ └── qileyuan │ │ │ └── tatala │ │ │ └── example │ │ │ ├── client │ │ │ ├── ChatRoomClient.java │ │ │ ├── EasyClient.java │ │ │ ├── NewToClient.java │ │ │ ├── TestClient.java │ │ │ └── TestClient2.java │ │ │ ├── model │ │ │ ├── AllTypeBean.java │ │ │ └── TestAccount.java │ │ │ ├── proxy │ │ │ ├── ChatRoomClientDefaultProxy.java │ │ │ ├── ChatRoomClientProxy.java │ │ │ ├── ChatRoomServerProxy.java │ │ │ ├── NewToClientProxy.java │ │ │ ├── NewToServerProxy.java │ │ │ ├── TestClientProxy.java │ │ │ ├── TestDefaultProxy.java │ │ │ ├── TestServerProxy.java │ │ │ └── wrapper │ │ │ │ ├── AllTypeBeanWrapper.java │ │ │ │ ├── TestAccountListWrapper.java │ │ │ │ ├── TestAccountMapWrapper.java │ │ │ │ └── TestAccountWrapper.java │ │ │ └── service │ │ │ ├── ChatRoomServer.java │ │ │ ├── ChatRoomServerLogic.java │ │ │ ├── TestManager.java │ │ │ ├── TestManagerImpl.java │ │ │ ├── TestReturnException.java │ │ │ └── TestServer.java │ └── tatala-java │ │ ├── build.xml │ │ ├── dist │ │ └── tatala.jar │ │ ├── lib │ │ ├── log4j-1.2.13.jar │ │ ├── xpp3_min-1.1.4c.jar │ │ └── xstream-1.3.1.jar │ │ └── src │ │ └── com │ │ └── qileyuan │ │ └── tatala │ │ ├── executor │ │ ├── LocalTarget.java │ │ ├── ServerExecutor.java │ │ ├── ServerTarget.java │ │ └── SocketServerTarget.java │ │ ├── proxy │ │ ├── ClientProxy.java │ │ ├── ClientProxyFactory.java │ │ ├── DefaultProxy.java │ │ └── ServerProxy.java │ │ ├── socket │ │ ├── SocketExecuteException.java │ │ ├── TatalaReturnException.java │ │ ├── client │ │ │ ├── AioClientReceiveHandler.java │ │ │ ├── LongClientSession.java │ │ │ ├── ShortClientSession.java │ │ │ ├── SocketConnection.java │ │ │ └── SocketController.java │ │ ├── io │ │ │ ├── TransferInputStream.java │ │ │ └── TransferOutputStream.java │ │ ├── server │ │ │ ├── AioReceiveHandler.java │ │ │ ├── AioSocketHandler.java │ │ │ ├── AioSocketServer.java │ │ │ ├── ServerSession.java │ │ │ └── SessionFilter.java │ │ ├── to │ │ │ ├── NewTransferObject.java │ │ │ ├── StandardTransferObject.java │ │ │ ├── TransferObject.java │ │ │ ├── TransferObjectFactory.java │ │ │ ├── TransferObjectWrapper.java │ │ │ └── helper │ │ │ │ ├── BooleanMapHelper.java │ │ │ │ ├── ByteArrayMapHelper.java │ │ │ │ ├── ByteMapHelper.java │ │ │ │ ├── CharMapHelper.java │ │ │ │ ├── DateMapHelper.java │ │ │ │ ├── DoubleArrayMapHelper.java │ │ │ │ ├── DoubleMapHelper.java │ │ │ │ ├── FloatArrayMapHelper.java │ │ │ │ ├── FloatMapHelper.java │ │ │ │ ├── IntArrayMapHelper.java │ │ │ │ ├── IntMapHelper.java │ │ │ │ ├── LongArrayMapHelper.java │ │ │ │ ├── LongMapHelper.java │ │ │ │ ├── SerializableMapHelper.java │ │ │ │ ├── ShortMapHelper.java │ │ │ │ ├── StringArrayMapHelper.java │ │ │ │ ├── StringMapHelper.java │ │ │ │ └── WrapperMapHelper.java │ │ └── util │ │ │ ├── NetworkUtil.java │ │ │ └── TransferUtil.java │ │ └── util │ │ └── Configuration.java └── 0.2.0 │ ├── tatala-client-csharp │ ├── cfg │ │ └── controller.xml │ ├── src │ │ ├── Example │ │ │ └── Tatala │ │ │ │ ├── client │ │ │ │ ├── ChatRoomClient.cs │ │ │ │ └── TestClient.cs │ │ │ │ ├── model │ │ │ │ ├── AllTypeBean.cs │ │ │ │ └── TestAccount.cs │ │ │ │ └── proxy │ │ │ │ ├── ChatRoomClientDefaultProxy.cs │ │ │ │ ├── ChatRoomClientProxy.cs │ │ │ │ ├── TestClientProxy.cs │ │ │ │ └── wrapper │ │ │ │ ├── AllTypeBeanWrapper.cs │ │ │ │ └── TestAccountWrapper.cs │ │ └── QiLeYuan │ │ │ ├── Tatala │ │ │ ├── executor │ │ │ │ ├── LocalTarget.cs │ │ │ │ ├── ServerExecutor.cs │ │ │ │ ├── ServerTarget.cs │ │ │ │ └── SocketServerTarget.cs │ │ │ ├── proxy │ │ │ │ └── DefaultProxy.cs │ │ │ ├── socket │ │ │ │ ├── client │ │ │ │ │ ├── Future.cs │ │ │ │ │ ├── LongClientSession.cs │ │ │ │ │ ├── ShortClientSession.cs │ │ │ │ │ ├── SocketConnection.cs │ │ │ │ │ └── SocketController.cs │ │ │ │ ├── io │ │ │ │ │ ├── TransferInputStream.cs │ │ │ │ │ └── TransferOutputStream.cs │ │ │ │ ├── to │ │ │ │ │ ├── NewTransferObject.cs │ │ │ │ │ ├── StandardTransferObject.cs │ │ │ │ │ ├── TransferObject.cs │ │ │ │ │ ├── TransferObjectFactory.cs │ │ │ │ │ ├── TransferObjectWrapper.cs │ │ │ │ │ └── helper │ │ │ │ │ │ ├── BooleanMapHelper.cs │ │ │ │ │ │ ├── ByteArrayMapHelper.cs │ │ │ │ │ │ ├── ByteMapHelper.cs │ │ │ │ │ │ ├── CharMapHelper.cs │ │ │ │ │ │ ├── DateMapHelper.cs │ │ │ │ │ │ ├── DoubleArrayMapHelper.cs │ │ │ │ │ │ ├── DoubleMapHelper.cs │ │ │ │ │ │ ├── FloatArrayMapHelper.cs │ │ │ │ │ │ ├── FloatMapHelper.cs │ │ │ │ │ │ ├── IntArrayMapHelper.cs │ │ │ │ │ │ ├── IntMapHelper.cs │ │ │ │ │ │ ├── LongArrayMapHelper.cs │ │ │ │ │ │ ├── LongMapHelper.cs │ │ │ │ │ │ ├── ShortMapHelper.cs │ │ │ │ │ │ ├── StringArrayMapHelper.cs │ │ │ │ │ │ ├── StringMapHelper.cs │ │ │ │ │ │ └── WrapperMapHelper.cs │ │ │ │ └── util │ │ │ │ │ └── TransferUtil.cs │ │ │ └── util │ │ │ │ └── BlockingQueue.cs │ │ │ └── Tools │ │ │ ├── ICSharpCode │ │ │ └── SharpZipLib │ │ │ │ ├── Checksums │ │ │ │ ├── Adler32.cs │ │ │ │ ├── CRC32.cs │ │ │ │ ├── IChecksum.cs │ │ │ │ └── StrangeCRC.cs │ │ │ │ ├── Encryption │ │ │ │ ├── PkzipClassic.cs │ │ │ │ ├── ZipAESStream.cs │ │ │ │ └── ZipAESTransform.cs │ │ │ │ ├── Main.cs │ │ │ │ ├── SharpZipBaseException.cs │ │ │ │ └── Zip │ │ │ │ ├── Compression │ │ │ │ ├── Deflater.cs │ │ │ │ ├── DeflaterConstants.cs │ │ │ │ ├── DeflaterEngine.cs │ │ │ │ ├── DeflaterHuffman.cs │ │ │ │ ├── DeflaterPending.cs │ │ │ │ ├── Inflater.cs │ │ │ │ ├── InflaterDynHeader.cs │ │ │ │ ├── InflaterHuffmanTree.cs │ │ │ │ ├── PendingBuffer.cs │ │ │ │ └── Streams │ │ │ │ │ ├── DeflaterOutputStream.cs │ │ │ │ │ ├── InflaterInputStream.cs │ │ │ │ │ ├── OutputWindow.cs │ │ │ │ │ └── StreamManipulator.cs │ │ │ │ ├── ZipConstants.cs │ │ │ │ ├── ZipEntry.cs │ │ │ │ ├── ZipException.cs │ │ │ │ ├── ZipExtraData.cs │ │ │ │ └── ZipHelperStream.cs │ │ │ └── Xstream │ │ │ └── Core │ │ │ ├── ConditionalConverter.cs │ │ │ ├── ConversionException.cs │ │ │ ├── Converters │ │ │ ├── ArrayConverter.cs │ │ │ ├── BooleanConverter.cs │ │ │ ├── ByteConverter.cs │ │ │ ├── CDataConverter.cs │ │ │ ├── CharConverter.cs │ │ │ ├── Complex │ │ │ │ └── StringBuilderConverter.cs │ │ │ ├── DateTimeConverter.cs │ │ │ ├── DecimalConverter.cs │ │ │ ├── DoubleConverter.cs │ │ │ ├── EnumConverter.cs │ │ │ ├── FloatConverter.cs │ │ │ ├── GenericListConverter.cs │ │ │ ├── GuidConverter.cs │ │ │ ├── IntConverter.cs │ │ │ ├── LongConverter.cs │ │ │ ├── MethodInfoConverter.cs │ │ │ ├── NoopConverter.cs │ │ │ ├── NullConverter.cs │ │ │ ├── ObjectConverter.cs │ │ │ ├── PointerConverter.cs │ │ │ ├── ShortConverter.cs │ │ │ ├── StringConverter.cs │ │ │ ├── TargetForceLoader.cs │ │ │ ├── TimeSpanConverter.cs │ │ │ └── TypeConverter.cs │ │ │ ├── DynamicInstanceBuilder.cs │ │ │ ├── FileXStream.cs │ │ │ ├── IConverter.cs │ │ │ ├── IMarshalContext.cs │ │ │ ├── IXStream.cs │ │ │ ├── IdFields.cs │ │ │ ├── MarshalContext.cs │ │ │ ├── NullType.cs │ │ │ ├── ReferenceComparer.cs │ │ │ ├── XStream.cs │ │ │ ├── XStreamBase.cs │ │ │ └── XStreamMarshaller.cs │ └── tatala-client-csharp.csproj │ ├── tatala-java-example │ ├── build.xml │ ├── cfg │ │ └── log4j.xml │ ├── chatroom.bat │ ├── chatroomserver.bat │ ├── client.bat │ ├── dist │ │ └── tatala-java-example.jar │ ├── easyclient.bat │ ├── lib │ │ ├── log4j-1.2.13.jar │ │ ├── protobuf-java-2.6.1.jar │ │ └── tatala.jar │ ├── server.bat │ └── src │ │ └── com │ │ └── qileyuan │ │ └── tatala │ │ └── example │ │ ├── client │ │ ├── ChatRoomClient.java │ │ ├── EasyClient.java │ │ ├── ExampleClient.java │ │ └── PerformanceTestClient.java │ │ ├── proxy │ │ ├── ChatRoomClientDefaultProxy.java │ │ ├── ChatRoomClientProxy.java │ │ ├── ChatRoomServerProxy.java │ │ ├── ExampleClientProxy.java │ │ ├── ExampleDefaultProxy.java │ │ └── ExampleServerProxy.java │ │ ├── server │ │ ├── ChatRoomServer.java │ │ └── ExampleServer.java │ │ └── service │ │ ├── ChatRoomServerLogic.java │ │ ├── ExampleManager.java │ │ ├── ExampleManagerImpl.java │ │ ├── ExampleReturnException.java │ │ └── model │ │ ├── Account.java │ │ ├── AllTypeBean.java │ │ ├── proto │ │ ├── AccountProto.java │ │ └── account.proto │ │ └── wrapper │ │ ├── AccountListWrapper.java │ │ ├── AccountMapWrapper.java │ │ ├── AccountWrapper.java │ │ └── AllTypeBeanWrapper.java │ └── tatala-java │ ├── build.xml │ ├── dist │ └── tatala.jar │ ├── lib │ └── log4j-1.2.13.jar │ └── src │ └── com │ └── qileyuan │ └── tatala │ ├── executor │ └── ServerExecutor.java │ ├── proxy │ ├── ClientProxy.java │ ├── ClientProxyFactory.java │ ├── DefaultProxy.java │ └── ServerProxy.java │ └── socket │ ├── client │ ├── AioClientReceiveHandler.java │ ├── LongClientSession.java │ ├── SocketConnection.java │ └── SocketController.java │ ├── exception │ ├── SocketExecuteException.java │ └── TatalaRollbackException.java │ ├── io │ ├── TransferInputStream.java │ └── TransferOutputStream.java │ ├── server │ ├── AioReceiveHandler.java │ ├── AioSocketHandler.java │ ├── AioSocketServer.java │ ├── ServerSession.java │ └── SessionFilter.java │ ├── to │ ├── OrderedTransferObject.java │ ├── TransferObject.java │ ├── TransferObjectFactory.java │ └── TransferObjectWrapper.java │ └── util │ ├── NetworkUtil.java │ └── TransferUtil.java ├── tatala-client-csharp ├── cfg │ └── controller.xml ├── src │ ├── Example │ │ └── Tatala │ │ │ ├── client │ │ │ ├── ChatRoomClient.cs │ │ │ └── TestClient.cs │ │ │ ├── model │ │ │ ├── AllTypeBean.cs │ │ │ └── TestAccount.cs │ │ │ └── proxy │ │ │ ├── ChatRoomClientDefaultProxy.cs │ │ │ ├── ChatRoomClientProxy.cs │ │ │ ├── TestClientProxy.cs │ │ │ └── wrapper │ │ │ ├── AllTypeBeanWrapper.cs │ │ │ └── TestAccountWrapper.cs │ └── QiLeYuan │ │ ├── Tatala │ │ ├── executor │ │ │ ├── LocalTarget.cs │ │ │ ├── ServerExecutor.cs │ │ │ ├── ServerTarget.cs │ │ │ └── SocketServerTarget.cs │ │ ├── proxy │ │ │ └── DefaultProxy.cs │ │ ├── socket │ │ │ ├── client │ │ │ │ ├── Future.cs │ │ │ │ ├── LongClientSession.cs │ │ │ │ ├── ShortClientSession.cs │ │ │ │ ├── SocketConnection.cs │ │ │ │ └── SocketController.cs │ │ │ ├── io │ │ │ │ ├── TransferInputStream.cs │ │ │ │ └── TransferOutputStream.cs │ │ │ ├── to │ │ │ │ ├── NewTransferObject.cs │ │ │ │ ├── StandardTransferObject.cs │ │ │ │ ├── TransferObject.cs │ │ │ │ ├── TransferObjectFactory.cs │ │ │ │ ├── TransferObjectWrapper.cs │ │ │ │ └── helper │ │ │ │ │ ├── BooleanMapHelper.cs │ │ │ │ │ ├── ByteArrayMapHelper.cs │ │ │ │ │ ├── ByteMapHelper.cs │ │ │ │ │ ├── CharMapHelper.cs │ │ │ │ │ ├── DateMapHelper.cs │ │ │ │ │ ├── DoubleArrayMapHelper.cs │ │ │ │ │ ├── DoubleMapHelper.cs │ │ │ │ │ ├── FloatArrayMapHelper.cs │ │ │ │ │ ├── FloatMapHelper.cs │ │ │ │ │ ├── IntArrayMapHelper.cs │ │ │ │ │ ├── IntMapHelper.cs │ │ │ │ │ ├── LongArrayMapHelper.cs │ │ │ │ │ ├── LongMapHelper.cs │ │ │ │ │ ├── ShortMapHelper.cs │ │ │ │ │ ├── StringArrayMapHelper.cs │ │ │ │ │ ├── StringMapHelper.cs │ │ │ │ │ └── WrapperMapHelper.cs │ │ │ └── util │ │ │ │ └── TransferUtil.cs │ │ └── util │ │ │ └── BlockingQueue.cs │ │ └── Tools │ │ ├── ICSharpCode │ │ └── SharpZipLib │ │ │ ├── Checksums │ │ │ ├── Adler32.cs │ │ │ ├── CRC32.cs │ │ │ ├── IChecksum.cs │ │ │ └── StrangeCRC.cs │ │ │ ├── Encryption │ │ │ ├── PkzipClassic.cs │ │ │ ├── ZipAESStream.cs │ │ │ └── ZipAESTransform.cs │ │ │ ├── Main.cs │ │ │ ├── SharpZipBaseException.cs │ │ │ └── Zip │ │ │ ├── Compression │ │ │ ├── Deflater.cs │ │ │ ├── DeflaterConstants.cs │ │ │ ├── DeflaterEngine.cs │ │ │ ├── DeflaterHuffman.cs │ │ │ ├── DeflaterPending.cs │ │ │ ├── Inflater.cs │ │ │ ├── InflaterDynHeader.cs │ │ │ ├── InflaterHuffmanTree.cs │ │ │ ├── PendingBuffer.cs │ │ │ └── Streams │ │ │ │ ├── DeflaterOutputStream.cs │ │ │ │ ├── InflaterInputStream.cs │ │ │ │ ├── OutputWindow.cs │ │ │ │ └── StreamManipulator.cs │ │ │ ├── ZipConstants.cs │ │ │ ├── ZipEntry.cs │ │ │ ├── ZipException.cs │ │ │ ├── ZipExtraData.cs │ │ │ └── ZipHelperStream.cs │ │ └── Xstream │ │ └── Core │ │ ├── ConditionalConverter.cs │ │ ├── ConversionException.cs │ │ ├── Converters │ │ ├── ArrayConverter.cs │ │ ├── BooleanConverter.cs │ │ ├── ByteConverter.cs │ │ ├── CDataConverter.cs │ │ ├── CharConverter.cs │ │ ├── Complex │ │ │ └── StringBuilderConverter.cs │ │ ├── DateTimeConverter.cs │ │ ├── DecimalConverter.cs │ │ ├── DoubleConverter.cs │ │ ├── EnumConverter.cs │ │ ├── FloatConverter.cs │ │ ├── GenericListConverter.cs │ │ ├── GuidConverter.cs │ │ ├── IntConverter.cs │ │ ├── LongConverter.cs │ │ ├── MethodInfoConverter.cs │ │ ├── NoopConverter.cs │ │ ├── NullConverter.cs │ │ ├── ObjectConverter.cs │ │ ├── PointerConverter.cs │ │ ├── ShortConverter.cs │ │ ├── StringConverter.cs │ │ ├── TargetForceLoader.cs │ │ ├── TimeSpanConverter.cs │ │ └── TypeConverter.cs │ │ ├── DynamicInstanceBuilder.cs │ │ ├── FileXStream.cs │ │ ├── IConverter.cs │ │ ├── IMarshalContext.cs │ │ ├── IXStream.cs │ │ ├── IdFields.cs │ │ ├── MarshalContext.cs │ │ ├── NullType.cs │ │ ├── ReferenceComparer.cs │ │ ├── XStream.cs │ │ ├── XStreamBase.cs │ │ └── XStreamMarshaller.cs └── tatala-client-csharp.csproj ├── tatala-java-example ├── build.xml ├── chatroom.bat ├── chatroomserver.bat ├── client.bat ├── clusterserver1.bat ├── clusterserver2.bat ├── easyclient.bat ├── lib │ ├── log4j-1.2.17.jar │ ├── protobuf-java-2.6.1.jar │ └── tatala-0.3.0.jar ├── pom.xml ├── server.bat ├── src │ └── main │ │ ├── java │ │ └── com │ │ │ └── qileyuan │ │ │ └── tatala │ │ │ └── example │ │ │ ├── client │ │ │ ├── ChatRoomClient.java │ │ │ ├── ClusterClient.java │ │ │ ├── EasyClient.java │ │ │ ├── ExampleClient.java │ │ │ └── PerformanceTestClient.java │ │ │ ├── proxy │ │ │ ├── ChatRoomClientDefaultProxy.java │ │ │ ├── ChatRoomClientProxy.java │ │ │ ├── ChatRoomServerProxy.java │ │ │ ├── ExampleClientProxy.java │ │ │ ├── ExampleDefaultProxy.java │ │ │ └── ExampleServerProxy.java │ │ │ ├── server │ │ │ ├── ChatRoomServer.java │ │ │ ├── ClusterServer.java │ │ │ └── ExampleServer.java │ │ │ └── service │ │ │ ├── ChatRoomServerLogic.java │ │ │ ├── ExampleManager.java │ │ │ ├── ExampleManagerImpl.java │ │ │ ├── ExampleReturnException.java │ │ │ └── model │ │ │ ├── Account.java │ │ │ ├── AllTypeBean.java │ │ │ ├── proto │ │ │ ├── AccountProto.java │ │ │ └── account.proto │ │ │ └── wrapper │ │ │ ├── AccountListWrapper.java │ │ │ ├── AccountMapWrapper.java │ │ │ ├── AccountWrapper.java │ │ │ └── AllTypeBeanWrapper.java │ │ └── resources │ │ └── log4j.xml └── target │ └── tatala-java-example-0.3.0.jar └── tatala-java ├── build.xml ├── lib ├── log4j-1.2.17.jar └── zookeeper-3.5.0-alpha.jar ├── pom.xml └── src └── main └── java └── com └── qileyuan └── tatala ├── executor └── ServerExecutor.java ├── proxy ├── ClientProxy.java ├── ClientProxyFactory.java ├── DefaultProxy.java └── ServerProxy.java ├── socket ├── client │ ├── AioClientReceiveHandler.java │ ├── LongClientSession.java │ ├── SocketConnection.java │ └── SocketController.java ├── exception │ ├── SocketExecuteException.java │ └── TatalaRollbackException.java ├── io │ ├── TransferInputStream.java │ └── TransferOutputStream.java ├── server │ ├── AioReceiveHandler.java │ ├── AioSocketHandler.java │ ├── AioSocketServer.java │ ├── ServerSession.java │ └── SessionFilter.java ├── to │ ├── OrderedTransferObject.java │ ├── TransferObject.java │ ├── TransferObjectFactory.java │ └── TransferObjectWrapper.java └── util │ ├── NetworkUtil.java │ └── TransferUtil.java └── zookeeper ├── ServiceDiscovery.java └── ServiceRegistry.java /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | 24 | *.cs linguist-language=Java -------------------------------------------------------------------------------- /history/0.1.2/tatala-client-csharp/cfg/controller.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 127.0.0.1 4 | 10001 5 | 5000 6 | 3 7 | test1 8 | 9 | 10 | 127.0.0.1 11 | 10002 12 | 5000 13 | 3 14 | test2 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-client-csharp/src/Example/Tatala/model/TestAccount.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | /** 4 | * This class is a customization object. 5 | * @author JimT 6 | * 7 | */ 8 | namespace Example.tatala.model { 9 | 10 | public class TestAccount { 11 | 12 | private int id; 13 | private String name; 14 | private String address; 15 | 16 | public int getId() { 17 | return id; 18 | } 19 | public void setId(int id) { 20 | this.id = id; 21 | } 22 | public String getName() { 23 | return name; 24 | } 25 | public void setName(String name) { 26 | this.name = name; 27 | } 28 | public String getAddress() { 29 | return address; 30 | } 31 | public void setAddress(String address) { 32 | this.address = address; 33 | } 34 | 35 | public override String ToString() { 36 | return "[id: " + id + "][name: " + name + "][address: " + address + "]"; 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-client-csharp/src/Example/Tatala/proxy/ChatRoomClientDefaultProxy.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Example.tatala.client; 3 | using QiLeYuan.Tatala.proxy; 4 | using QiLeYuan.Tatala.socket.to; 5 | 6 | namespace Example.tatala.proxy { 7 | public class ChatRoomClientDefaultProxy : DefaultProxy { 8 | 9 | public override Object execute(TransferObject baseto) { 10 | StandardTransferObject to = (StandardTransferObject)baseto; 11 | String calleeMethod = to.getCalleeMethod(); 12 | if (calleeMethod.Equals("receiveMessage")) { 13 | String message = to.getString("message"); 14 | ChatRoomClient.getInstance().receiveMessage(message); 15 | } 16 | 17 | return null; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-client-csharp/src/QiLeYuan/Tatala/executor/LocalTarget.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using QiLeYuan.Tatala.socket.to; 4 | using QiLeYuan.Tools.debug; 5 | 6 | /** 7 | * This class is local target, simply provider local-method-call. 8 | * 9 | * @author JimT 10 | * 11 | */ 12 | namespace QiLeYuan.Tatala.executor { 13 | 14 | public class LocalTarget : ServerTarget { 15 | public Object execute(TransferObject to) { 16 | 17 | String calleeClass = to.getCalleeClass(); 18 | String calleeMethod = to.getCalleeMethod(); 19 | 20 | Object retobj = null; 21 | try { 22 | Type type = Type.GetType(calleeClass); 23 | Object instance = Activator.CreateInstance(type); 24 | MethodInfo method = type.GetMethod(calleeMethod); 25 | retobj = method.Invoke(instance, new object[] { to }); 26 | } catch (Exception e) { 27 | Logging.LogError(e.ToString()); 28 | } 29 | 30 | return retobj; 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /history/0.1.2/tatala-client-csharp/src/QiLeYuan/Tatala/executor/ServerExecutor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using QiLeYuan.Tatala.util; 3 | using QiLeYuan.Tatala.socket.to; 4 | 5 | /** 6 | * This class is the distribution-method-call executor, which dispatches request to different target. 7 | * For now, it only supports local and socket distribution. 8 | * 9 | * @author JimT 10 | * 11 | */ 12 | namespace QiLeYuan.Tatala.executor { 13 | 14 | public class ServerExecutor { 15 | private static ServerTarget target; 16 | public static Object execute(TransferObject to) { 17 | Object retObj = null; 18 | //for csharp client, server target is Socket. 19 | target = new SocketServerTarget(); 20 | retObj = target.execute(to); 21 | return retObj; 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /history/0.1.2/tatala-client-csharp/src/QiLeYuan/Tatala/executor/ServerTarget.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using QiLeYuan.Tatala.socket.to; 3 | 4 | namespace QiLeYuan.Tatala.executor { 5 | 6 | public interface ServerTarget { 7 | Object execute(TransferObject to); 8 | } 9 | } -------------------------------------------------------------------------------- /history/0.1.2/tatala-client-csharp/src/QiLeYuan/Tatala/executor/SocketServerTarget.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using QiLeYuan.Tatala.socket.client; 3 | using QiLeYuan.Tatala.socket.to; 4 | 5 | /** 6 | * This class is socket server target, provider socket distribution-method-call. 7 | * @author JimT 8 | * 9 | */ 10 | namespace QiLeYuan.Tatala.executor { 11 | 12 | public class SocketServerTarget : ServerTarget { 13 | 14 | public Object execute(TransferObject to) { 15 | Object resultObject = null; 16 | 17 | resultObject = SocketController.execute(to); 18 | 19 | return resultObject; 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /history/0.1.2/tatala-client-csharp/src/QiLeYuan/Tatala/proxy/DefaultProxy.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using QiLeYuan.Tatala.socket.to; 3 | using QiLeYuan.Tools.debug; 4 | 5 | namespace QiLeYuan.Tatala.proxy { 6 | public class DefaultProxy { 7 | public virtual Object execute(TransferObject to) { 8 | Logging.LogError("This is DefaultProxy. You need extend it by specific proxy."); 9 | return null; 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-client-csharp/src/QiLeYuan/Tatala/socket/client/Future.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using QiLeYuan.Tatala.socket.client; 3 | 4 | namespace QiLeYuan.Tatala.socket.client { 5 | public class Future { 6 | private SocketController.ExecuteDelegate executeDelegate; 7 | private IAsyncResult asyncResult; 8 | 9 | public Future(SocketController.ExecuteDelegate executeDelegate, IAsyncResult asyncResult) { 10 | this.executeDelegate = executeDelegate; 11 | this.asyncResult = asyncResult; 12 | } 13 | 14 | public Object Get() { 15 | return executeDelegate.EndInvoke(asyncResult); 16 | } 17 | 18 | public bool IsDone() { 19 | return asyncResult.IsCompleted; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-client-csharp/src/QiLeYuan/Tatala/socket/to/TransferObjectWrapper.cs: -------------------------------------------------------------------------------- 1 | using QiLeYuan.Tatala.socket.io; 2 | 3 | /** 4 | * This is customization object wrapper interface. 5 | * 6 | * @author JimT 7 | * 8 | */ 9 | namespace QiLeYuan.Tatala.socket.to { 10 | public interface TransferObjectWrapper { 11 | int getLength(); 12 | void getByteArray(TransferOutputStream touts); 13 | TransferObjectWrapper getObjectWrapper(TransferInputStream tins); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-client-csharp/src/QiLeYuan/Tatala/socket/to/helper/BooleanMapHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using QiLeYuan.Tatala.socket.io; 4 | using QiLeYuan.Tatala.socket.util; 5 | 6 | namespace QiLeYuan.Tatala.socket.to.helper { 7 | 8 | public class BooleanMapHelper { 9 | public static int getByteArrayLength(Dictionary booleanMap) { 10 | int blength = 0; 11 | foreach (KeyValuePair item in booleanMap) { 12 | // type 13 | blength += TransferUtil.getLengthOfByte(); 14 | // key 15 | String key = item.Key; 16 | blength += TransferUtil.getLengthOfString(key); 17 | // value 18 | blength += TransferUtil.getLengthOfBoolean(); 19 | } 20 | return blength; 21 | } 22 | 23 | public static void getByteArray(Dictionary booleanMap, TransferOutputStream touts) { 24 | 25 | foreach (KeyValuePair item in booleanMap) { 26 | // type 27 | touts.writeByte(TransferObject.DATATYPE_BOOLEAN); 28 | // key 29 | String key = item.Key; 30 | touts.writeString(key); 31 | // value 32 | bool value = item.Value; 33 | touts.writeBoolean(value); 34 | } 35 | } 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /history/0.1.2/tatala-client-csharp/src/QiLeYuan/Tatala/socket/to/helper/ByteArrayMapHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using QiLeYuan.Tatala.socket.util; 4 | using QiLeYuan.Tatala.socket.io; 5 | 6 | namespace QiLeYuan.Tatala.socket.to.helper { 7 | public class ByteArrayMapHelper { 8 | public static int getByteArrayLength(Dictionary byteArrayMap) { 9 | int blength = 0; 10 | foreach (KeyValuePair item in byteArrayMap) { 11 | // type 12 | blength += TransferUtil.getLengthOfByte(); 13 | // key 14 | String key = item.Key; 15 | blength += TransferUtil.getLengthOfString(key); 16 | // value 17 | byte[] values = item.Value; 18 | blength += TransferUtil.getLengthOfByteArray(values); 19 | } 20 | return blength; 21 | } 22 | 23 | public static void getByteArray(Dictionary byteArrayMap, TransferOutputStream touts) { 24 | foreach (KeyValuePair item in byteArrayMap) { 25 | // type 26 | touts.writeByte(TransferObject.DATATYPE_BYTEARRAY); 27 | // key 28 | String key = item.Key; 29 | touts.writeString(key); 30 | // value 31 | byte[] values = item.Value; 32 | touts.writeByteArray(values); 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-client-csharp/src/QiLeYuan/Tatala/socket/to/helper/ByteMapHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using QiLeYuan.Tatala.socket.io; 4 | using QiLeYuan.Tatala.socket.util; 5 | 6 | namespace QiLeYuan.Tatala.socket.to.helper { 7 | 8 | public class ByteMapHelper { 9 | public static int getByteArrayLength(Dictionary byteMap) { 10 | int blength = 0; 11 | foreach (KeyValuePair item in byteMap) { 12 | // type 13 | blength += TransferUtil.getLengthOfByte(); 14 | // key 15 | String key = item.Key; 16 | blength += TransferUtil.getLengthOfString(key); 17 | // value 18 | blength += TransferUtil.getLengthOfByte(); 19 | } 20 | return blength; 21 | } 22 | 23 | public static void getByteArray(Dictionary byteMap, TransferOutputStream touts) { 24 | foreach (KeyValuePair item in byteMap) { 25 | // type 26 | touts.writeByte(TransferObject.DATATYPE_BYTE); 27 | // key 28 | String key = item.Key; 29 | touts.writeString(key); 30 | // value 31 | byte value = item.Value; 32 | touts.writeByte(value); 33 | } 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /history/0.1.2/tatala-client-csharp/src/QiLeYuan/Tatala/socket/to/helper/CharMapHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using QiLeYuan.Tatala.socket.io; 4 | using QiLeYuan.Tatala.socket.util; 5 | 6 | namespace QiLeYuan.Tatala.socket.to.helper { 7 | 8 | public class CharMapHelper { 9 | public static int getByteArrayLength(Dictionary charMap) { 10 | int blength = 0; 11 | foreach (KeyValuePair item in charMap) { 12 | // type 13 | blength += TransferUtil.getLengthOfByte(); 14 | // key 15 | String key = item.Key; 16 | blength += TransferUtil.getLengthOfString(key); 17 | // value 18 | blength += TransferUtil.getLengthOfChar(); 19 | } 20 | return blength; 21 | } 22 | 23 | public static void getByteArray(Dictionary charMap, TransferOutputStream touts) { 24 | foreach (KeyValuePair item in charMap) { 25 | // type 26 | touts.writeByte(TransferObject.DATATYPE_CHAR); 27 | // key 28 | String key = item.Key; 29 | touts.writeString(key); 30 | // value 31 | char value = item.Value; 32 | touts.writeChar(value); 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-client-csharp/src/QiLeYuan/Tatala/socket/to/helper/DateMapHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using QiLeYuan.Tatala.socket.io; 4 | using QiLeYuan.Tatala.socket.util; 5 | 6 | namespace QiLeYuan.Tatala.socket.to.helper { 7 | 8 | public class DateMapHelper { 9 | public static int getByteArrayLength(Dictionary dateMap) { 10 | int blength = 0; 11 | foreach (KeyValuePair item in dateMap) { 12 | // type 13 | blength += TransferUtil.getLengthOfByte(); 14 | // key 15 | String key = item.Key; 16 | blength += TransferUtil.getLengthOfString(key); 17 | // value 18 | blength += TransferUtil.getLengthOfDate(); 19 | } 20 | return blength; 21 | } 22 | 23 | public static void getByteArray(Dictionary dateMap, TransferOutputStream touts) { 24 | foreach (KeyValuePair item in dateMap) { 25 | // type 26 | touts.writeByte(TransferObject.DATATYPE_DATE); 27 | // key 28 | String key = item.Key; 29 | touts.writeString(key); 30 | // value 31 | DateTime value = item.Value; 32 | touts.writeDate(value); 33 | } 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /history/0.1.2/tatala-client-csharp/src/QiLeYuan/Tatala/socket/to/helper/DoubleMapHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using QiLeYuan.Tatala.socket.util; 4 | using QiLeYuan.Tatala.socket.io; 5 | 6 | namespace QiLeYuan.Tatala.socket.to.helper { 7 | 8 | public class DoubleMapHelper { 9 | public static int getByteArrayLength(Dictionary doubleMap) { 10 | int blength = 0; 11 | foreach (KeyValuePair item in doubleMap) { 12 | // type 13 | blength += TransferUtil.getLengthOfByte(); 14 | // key 15 | String key = item.Key; 16 | blength += TransferUtil.getLengthOfString(key); 17 | // value 18 | blength += TransferUtil.getLengthOfDouble(); 19 | } 20 | return blength; 21 | } 22 | 23 | public static void getByteArray(Dictionary doubleMap, TransferOutputStream touts) { 24 | foreach (KeyValuePair item in doubleMap) { 25 | // type 26 | touts.writeByte(TransferObject.DATATYPE_DOUBLE); 27 | // key 28 | String key = item.Key; 29 | touts.writeString(key); 30 | // value 31 | double value = item.Value; 32 | touts.writeDouble(value); 33 | } 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /history/0.1.2/tatala-client-csharp/src/QiLeYuan/Tatala/socket/to/helper/FloatMapHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using QiLeYuan.Tatala.socket.io; 4 | using QiLeYuan.Tatala.socket.util; 5 | 6 | namespace QiLeYuan.Tatala.socket.to.helper { 7 | 8 | public class FloatMapHelper { 9 | public static int getByteArrayLength(Dictionary floatMap) { 10 | int blength = 0; 11 | foreach (KeyValuePair item in floatMap) { 12 | // type 13 | blength += TransferUtil.getLengthOfByte(); 14 | // key 15 | String key = item.Key; 16 | blength += TransferUtil.getLengthOfString(key); 17 | // value 18 | blength += TransferUtil.getLengthOfFloat(); 19 | } 20 | return blength; 21 | } 22 | 23 | public static void getByteArray(Dictionary floatMap, TransferOutputStream touts) { 24 | foreach (KeyValuePair item in floatMap) { 25 | // type 26 | touts.writeByte(TransferObject.DATATYPE_FLOAT); 27 | // key 28 | String key = item.Key; 29 | touts.writeString(key); 30 | // value 31 | float value = item.Value; 32 | touts.writeFloat(value); 33 | } 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /history/0.1.2/tatala-client-csharp/src/QiLeYuan/Tatala/socket/to/helper/IntArrayMapHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using QiLeYuan.Tatala.socket.io; 4 | using QiLeYuan.Tatala.socket.util; 5 | 6 | namespace QiLeYuan.Tatala.socket.to.helper { 7 | 8 | public class IntArrayMapHelper { 9 | public static int getByteArrayLength(Dictionary intArrayMap) { 10 | int blength = 0; 11 | foreach (KeyValuePair item in intArrayMap) { 12 | // type 13 | blength += TransferUtil.getLengthOfByte(); 14 | // key 15 | String key = item.Key; 16 | blength += TransferUtil.getLengthOfString(key); 17 | // value 18 | int[] values = item.Value; 19 | blength += TransferUtil.getLengthOfIntArray(values); 20 | } 21 | return blength; 22 | } 23 | 24 | public static void getByteArray(Dictionary intArrayMap, TransferOutputStream touts) { 25 | foreach (KeyValuePair item in intArrayMap) { 26 | // type 27 | touts.writeByte(TransferObject.DATATYPE_INTARRAY); 28 | // key 29 | String key = item.Key; 30 | touts.writeString(key); 31 | // value 32 | int[] values = item.Value; 33 | touts.writeIntArray(values); 34 | } 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /history/0.1.2/tatala-client-csharp/src/QiLeYuan/Tatala/socket/to/helper/IntMapHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using QiLeYuan.Tatala.socket.io; 4 | using QiLeYuan.Tatala.socket.util; 5 | 6 | namespace QiLeYuan.Tatala.socket.to.helper { 7 | 8 | public class IntMapHelper { 9 | public static int getByteArrayLength(Dictionary intMap) { 10 | int blength = 0; 11 | foreach (KeyValuePair item in intMap) { 12 | // type 13 | blength += TransferUtil.getLengthOfByte(); 14 | // key 15 | String key = item.Key; 16 | blength += TransferUtil.getLengthOfString(key); 17 | // value 18 | blength += TransferUtil.getLengthOfInt(); 19 | } 20 | return blength; 21 | } 22 | 23 | public static void getByteArray(Dictionary intMap, TransferOutputStream touts) { 24 | foreach (KeyValuePair item in intMap) { 25 | // type 26 | touts.writeByte(TransferObject.DATATYPE_INT); 27 | // key 28 | String key = item.Key; 29 | touts.writeString(key); 30 | // value 31 | int value = item.Value; 32 | touts.writeInt(value); 33 | } 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /history/0.1.2/tatala-client-csharp/src/QiLeYuan/Tatala/socket/to/helper/LongArrayMapHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using QiLeYuan.Tatala.socket.io; 4 | using QiLeYuan.Tatala.socket.util; 5 | 6 | namespace QiLeYuan.Tatala.socket.to.helper { 7 | 8 | public class LongArrayMapHelper { 9 | public static int getByteArrayLength(Dictionary longArrayMap) { 10 | int blength = 0; 11 | foreach (KeyValuePair item in longArrayMap) { 12 | // type 13 | blength += TransferUtil.getLengthOfByte(); 14 | // key 15 | String key = item.Key; 16 | blength += TransferUtil.getLengthOfString(key); 17 | // value 18 | long[] values = item.Value; 19 | blength += TransferUtil.getLengthOfLongArray(values); 20 | } 21 | return blength; 22 | } 23 | 24 | public static void getByteArray(Dictionary longArrayMap, TransferOutputStream touts) { 25 | foreach (KeyValuePair item in longArrayMap) { 26 | // type 27 | touts.writeByte(TransferObject.DATATYPE_LONGARRAY); 28 | // key 29 | String key = item.Key; 30 | touts.writeString(key); 31 | // value 32 | long[] values = item.Value; 33 | touts.writeLongArray(values); 34 | } 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /history/0.1.2/tatala-client-csharp/src/QiLeYuan/Tatala/socket/to/helper/LongMapHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using QiLeYuan.Tatala.socket.io; 4 | using QiLeYuan.Tatala.socket.util; 5 | 6 | namespace QiLeYuan.Tatala.socket.to.helper { 7 | 8 | public class LongMapHelper { 9 | public static int getByteArrayLength(Dictionary longMap) { 10 | int blength = 0; 11 | foreach (KeyValuePair item in longMap) { 12 | // type 13 | blength += TransferUtil.getLengthOfByte(); 14 | // key 15 | String key = item.Key; 16 | blength += TransferUtil.getLengthOfString(key); 17 | // value 18 | blength += TransferUtil.getLengthOfLong(); 19 | } 20 | return blength; 21 | } 22 | 23 | public static void getByteArray(Dictionary longMap, TransferOutputStream touts) { 24 | foreach (KeyValuePair item in longMap) { 25 | // type 26 | touts.writeByte(TransferObject.DATATYPE_LONG); 27 | // key 28 | String key = item.Key; 29 | touts.writeString(key); 30 | // value 31 | long value = item.Value; 32 | touts.writeLong(value); 33 | } 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /history/0.1.2/tatala-client-csharp/src/QiLeYuan/Tatala/socket/to/helper/ShortMapHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using QiLeYuan.Tatala.socket.io; 4 | using QiLeYuan.Tatala.socket.util; 5 | 6 | namespace QiLeYuan.Tatala.socket.to.helper { 7 | 8 | public class ShortMapHelper { 9 | public static int getByteArrayLength(Dictionary shortMap) { 10 | int blength = 0; 11 | foreach (KeyValuePair item in shortMap) { 12 | // type 13 | blength += TransferUtil.getLengthOfByte(); 14 | // key 15 | String key = item.Key; 16 | blength += TransferUtil.getLengthOfString(key); 17 | // value 18 | blength += TransferUtil.getLengthOfShort(); 19 | } 20 | return blength; 21 | } 22 | 23 | public static void getByteArray(Dictionary shortMap, TransferOutputStream touts) { 24 | foreach (KeyValuePair item in shortMap) { 25 | // type 26 | touts.writeByte(TransferObject.DATATYPE_SHORT); 27 | // key 28 | String key = item.Key; 29 | touts.writeString(key); 30 | // value 31 | short value = item.Value; 32 | touts.writeShort(value); 33 | } 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /history/0.1.2/tatala-client-csharp/src/QiLeYuan/Tatala/socket/to/helper/StringMapHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using QiLeYuan.Tatala.socket.io; 4 | using QiLeYuan.Tatala.socket.util; 5 | 6 | namespace QiLeYuan.Tatala.socket.to.helper { 7 | 8 | public class StringMapHelper { 9 | public static int getByteArrayLength(Dictionary stringMap) { 10 | int blength = 0; 11 | foreach (KeyValuePair item in stringMap) { 12 | // type 13 | blength += TransferUtil.getLengthOfByte(); 14 | // key 15 | String key = item.Key; 16 | blength += TransferUtil.getLengthOfString(key); 17 | // value 18 | String value = item.Value; 19 | blength += TransferUtil.getLengthOfString(value); 20 | } 21 | return blength; 22 | } 23 | 24 | public static void getByteArray(Dictionary stringMap, TransferOutputStream touts) { 25 | foreach (KeyValuePair item in stringMap) { 26 | // type 27 | touts.writeByte(TransferObject.DATATYPE_STRING); 28 | // key 29 | String key = item.Key; 30 | touts.writeString(key); 31 | // value 32 | String value = item.Value; 33 | touts.writeString(value); 34 | } 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /history/0.1.2/tatala-client-csharp/src/QiLeYuan/Tools/Xstream/Core/ConditionalConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Xstream.Core 4 | { 5 | public interface ConditionalConverter : IConverter 6 | { 7 | bool Match(Type type); 8 | } 9 | } -------------------------------------------------------------------------------- /history/0.1.2/tatala-client-csharp/src/QiLeYuan/Tools/Xstream/Core/ConversionException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Xstream.Core 5 | { 6 | /// 7 | /// Exception that occurs then (de)serialization of an object fails. 8 | /// 9 | [Serializable] 10 | public class ConversionException : Exception 11 | { 12 | internal ConversionException(SerializationInfo info, StreamingContext context) : base(info, context) {} 13 | internal ConversionException(string message) : base(message) {} 14 | internal ConversionException(string message, Exception innerException) : base(message, innerException) {} 15 | } 16 | } -------------------------------------------------------------------------------- /history/0.1.2/tatala-client-csharp/src/QiLeYuan/Tools/Xstream/Core/Converters/NoopConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Xml; 4 | 5 | namespace Xstream.Core.Converters 6 | { 7 | public class NoopConverter : IConverter 8 | { 9 | private static NoopConverter instance = new NoopConverter(); 10 | private NoopConverter() {} 11 | 12 | public static IConverter Instance 13 | { 14 | get { return instance; } 15 | } 16 | 17 | public void Register(IMarshalContext context) 18 | { 19 | } 20 | 21 | public void ToXml(object value, FieldInfo field, XmlTextWriter xml, IMarshalContext context) 22 | { 23 | } 24 | 25 | public object FromXml(object parent, FieldInfo field, Type type, XmlNode xml, IMarshalContext context) 26 | { 27 | throw new NotImplementedException(); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /history/0.1.2/tatala-client-csharp/src/QiLeYuan/Tools/Xstream/Core/Converters/NullConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Xml; 4 | 5 | namespace Xstream.Core.Converters 6 | { 7 | /// 8 | /// Special converter to convert null values. 9 | /// 10 | internal class NullConverter : IConverter 11 | { 12 | private static readonly Type __type = typeof( NullType ); 13 | 14 | /// 15 | /// Register is called by a MarshalContext to allow the 16 | /// converter instance to register itself in the context 17 | /// with all appropriate value types and interfaces. 18 | /// 19 | public void Register(IMarshalContext context) 20 | { 21 | context.RegisterConverter( __type, this ); 22 | context.Alias( "null", __type ); 23 | } 24 | 25 | /// 26 | /// Converts the object passed in to its XML representation. 27 | /// The XML string is written on the XmlTextWriter. 28 | /// 29 | public void ToXml(object value, FieldInfo field, XmlTextWriter xml, IMarshalContext context) 30 | { 31 | xml.WriteElementString( "null", string.Empty ); 32 | } 33 | 34 | /// 35 | /// Converts the XmlNode data passed in back to an actual 36 | /// .NET instance object. 37 | /// 38 | /// Object created from the XML. 39 | public object FromXml(object parent, FieldInfo field, Type type, XmlNode xml, IMarshalContext context) 40 | { 41 | return null; 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-client-csharp/src/QiLeYuan/Tools/Xstream/Core/Converters/PointerConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Xml; 4 | 5 | namespace Xstream.Core.Converters 6 | { 7 | /// 8 | /// Converts a pointer (System.Reflection.Pointer) to xml and back. 9 | /// 10 | /// 11 | /// Not implemented to convert pointer types. 12 | /// 13 | internal class PointerConverter : IConverter 14 | { 15 | private static readonly Type __type = typeof( Pointer ); 16 | 17 | /// 18 | /// Register is called by a MarshalContext to allow the 19 | /// converter instance to register itself in the context 20 | /// with all appropriate value types and interfaces. 21 | /// 22 | public void Register(IMarshalContext context) 23 | { 24 | context.RegisterConverter( __type, this ); 25 | } 26 | 27 | /// 28 | /// Converts the object passed in to its XML representation. 29 | /// The XML string is written on the XmlTextWriter. 30 | /// 31 | public void ToXml(object value, FieldInfo field, XmlTextWriter xml, IMarshalContext context) 32 | { 33 | } 34 | 35 | /// 36 | /// Converts the XmlNode data passed in, back to an actual 37 | /// .NET instance object. 38 | /// 39 | /// Object created from the XML. 40 | public object FromXml(object parent, FieldInfo field, Type type, XmlNode xml, IMarshalContext context) 41 | { 42 | return null; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-client-csharp/src/QiLeYuan/Tools/Xstream/Core/Converters/TargetForceLoader.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | namespace Xstream.Core.Converters 4 | { 5 | internal class TargetForceLoader 6 | { 7 | public static object GetTargetValue(object value) 8 | { 9 | if (value == null) return value; 10 | ForceLoadTheEntityBecauseItIsLazy(value); 11 | 12 | FieldInfo interceptorField = value.GetType().GetField("__interceptor"); 13 | if (interceptorField == null) return value; 14 | 15 | object interceptorValue = interceptorField.GetValue(value); 16 | FieldInfo targetField = interceptorValue.GetType().BaseType.GetField("_target", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); 17 | return targetField.GetValue(interceptorValue); 18 | } 19 | 20 | private static void ForceLoadTheEntityBecauseItIsLazy(object value) 21 | { 22 | try 23 | { 24 | value.GetType().GetMethod("get_Version", BindingFlags.Public | BindingFlags.Instance).Invoke(value, new object[] {}); 25 | } 26 | catch (TargetInvocationException e) 27 | { 28 | throw e.InnerException.InnerException; 29 | } 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /history/0.1.2/tatala-client-csharp/src/QiLeYuan/Tools/Xstream/Core/FileXStream.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | 4 | namespace Xstream.Core 5 | { 6 | public class FileXStream : IXStream 7 | { 8 | // Fields 9 | private readonly string fileName; 10 | private readonly XStream xStream; 11 | 12 | // Methods 13 | public FileXStream(string fileName) 14 | { 15 | this.fileName = fileName; 16 | xStream = new XStream(); 17 | } 18 | 19 | public void AddConverter(IConverter converter) 20 | { 21 | xStream.AddConverter(converter); 22 | } 23 | 24 | public void AddIgnoreAttribute(Type ignoredAttributeType) 25 | { 26 | xStream.AddIgnoreAttribute(ignoredAttributeType); 27 | } 28 | 29 | public object FromFile() 30 | { 31 | return xStream.FromXml(File.ReadAllText(fileName)); 32 | } 33 | 34 | public object FromXml(string xml) 35 | { 36 | return xStream.FromXml(xml); 37 | } 38 | 39 | public string ToXml(object value) 40 | { 41 | string xml = xStream.ToXml(value); 42 | File.WriteAllText(fileName, xml); 43 | return xml; 44 | } 45 | 46 | public XStream XStream 47 | { 48 | get { return xStream; } 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /history/0.1.2/tatala-client-csharp/src/QiLeYuan/Tools/Xstream/Core/IConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Xml; 4 | 5 | namespace Xstream.Core 6 | { 7 | /// 8 | /// IConverter is the interface that all type converter instances 9 | /// should implement to get used with a MarshalContext. 10 | /// 11 | public interface IConverter 12 | { 13 | /// 14 | /// Register is called by a MarshalContext to allow the 15 | /// converter instance to register itself in the context 16 | /// with all appropriate value types and interfaces. 17 | /// 18 | void Register(IMarshalContext context); 19 | 20 | /// 21 | /// Converts the object passed in to its XML representation. 22 | /// The XML string is written on the XmlTextWriter. 23 | /// 24 | void ToXml(object value, FieldInfo field, XmlTextWriter xml, IMarshalContext context); 25 | 26 | /// 27 | /// Converts the XmlNode data passed in back to an actual 28 | /// .NET instance object. 29 | /// 30 | /// Object created from the XML. 31 | object FromXml(object parent, FieldInfo field, Type type, XmlNode xml, IMarshalContext context); 32 | } 33 | 34 | public interface AssignableConverter : IConverter 35 | { 36 | Type ConverteeType { get; } 37 | } 38 | } -------------------------------------------------------------------------------- /history/0.1.2/tatala-client-csharp/src/QiLeYuan/Tools/Xstream/Core/IMarshalContext.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Xml; 4 | 5 | namespace Xstream.Core 6 | { 7 | public interface IMarshalContext 8 | { 9 | bool ContainsType(object o); 10 | object GetOfType(object matchingObj); 11 | void WriteStartTag(Type type, FieldInfo field, XmlTextWriter textWriter); 12 | int GetStackIndex(object value); 13 | void Stack(object value, Type type); 14 | void WriteEndTag(Type type, FieldInfo field, XmlTextWriter xml); 15 | object GetStackObject(int stackIx); 16 | void Stack(object value, Type type, XmlNode xmlNode); 17 | IConverter GetConverter(XmlNode child, ref Type type); 18 | void RegisterConverter(Type type, IConverter converter); 19 | Type IgnoredAttributeType { get; } 20 | bool CaseSensitive { get; set; } 21 | IConverter GetConverter(Type type); 22 | void ClearStack(); 23 | void Alias(string s, Type type); 24 | void Stack(object o); 25 | void AddIgnoreAttribute(Type type); 26 | string GetTypeName(Type type); 27 | void AddConverter(IConverter converter); 28 | bool IsCData(Type type, string fieldName); 29 | IConverter GetCDataConverter(); 30 | void AddCdata(Type type, string name); 31 | } 32 | } -------------------------------------------------------------------------------- /history/0.1.2/tatala-client-csharp/src/QiLeYuan/Tools/Xstream/Core/IXStream.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Xstream.Core 4 | { 5 | public interface IXStream 6 | { 7 | void AddConverter(IConverter converter); 8 | void AddIgnoreAttribute(Type ignoredAttributeType); 9 | object FromXml(string xml); 10 | string ToXml(object value); 11 | } 12 | } -------------------------------------------------------------------------------- /history/0.1.2/tatala-client-csharp/src/QiLeYuan/Tools/Xstream/Core/NullType.cs: -------------------------------------------------------------------------------- 1 | namespace Xstream.Core 2 | { 3 | /// 4 | /// Dummy class, representing null value. 5 | /// 6 | internal class NullType {} 7 | } -------------------------------------------------------------------------------- /history/0.1.2/tatala-client-csharp/src/QiLeYuan/Tools/Xstream/Core/ReferenceComparer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | 3 | namespace Xstream.Core 4 | { 5 | internal class ReferenceComparer : IEqualityComparer 6 | { 7 | bool IEqualityComparer.Equals(object x, object y) 8 | { 9 | return ReferenceEquals(x, y); 10 | } 11 | 12 | int IEqualityComparer.GetHashCode(object obj) 13 | { 14 | return obj.GetHashCode(); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /history/0.1.2/tatala-java-example/build.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 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-java-example/cfg/controller.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 127.0.0.1 5 | 10001 6 | 5000 7 | 3 8 | test1 9 | 10 | 11 | 127.0.0.1 12 | 10002 13 | 5000 14 | 3 15 | test2 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-java-example/cfg/tatala.properties: -------------------------------------------------------------------------------- 1 | ####### Server ####### 2 | Server.Socket.listenPort=10001 3 | Server.Socket.poolSize=10 4 | 5 | ####### Client ####### 6 | #Client.ServerTarget=Local 7 | Client.ServerTarget=Socket 8 | Client.Socket.poolSize=10 -------------------------------------------------------------------------------- /history/0.1.2/tatala-java-example/chatroom.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | set classpath=. 3 | set classpath=%classpath%;lib\log4j-1.2.13.jar 4 | set classpath=%classpath%;lib\xpp3_min-1.1.4c.jar 5 | set classpath=%classpath%;lib\xstream-1.3.1.jar 6 | set classpath=%classpath%;lib\tatala.jar 7 | set classpath=%classpath%;dist\tatala-java-example.jar 8 | set classpath=%classpath%;cfg 9 | 10 | java com.qileyuan.tatala.example.client.ChatRoomClient -------------------------------------------------------------------------------- /history/0.1.2/tatala-java-example/chatroomserver.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | set classpath=. 3 | set classpath=%classpath%;lib\log4j-1.2.13.jar 4 | set classpath=%classpath%;lib\xpp3_min-1.1.4c.jar 5 | set classpath=%classpath%;lib\xstream-1.3.1.jar 6 | set classpath=%classpath%;lib\tatala.jar 7 | set classpath=%classpath%;dist\tatala-java-example.jar 8 | set classpath=%classpath%;cfg 9 | 10 | java com.qileyuan.tatala.example.service.ChatRoomServer 11 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-java-example/client.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | set classpath=. 3 | set classpath=%classpath%;lib\log4j-1.2.13.jar 4 | set classpath=%classpath%;lib\xpp3_min-1.1.4c.jar 5 | set classpath=%classpath%;lib\xstream-1.3.1.jar 6 | set classpath=%classpath%;lib\tatala.jar 7 | set classpath=%classpath%;dist\tatala-java-example.jar 8 | set classpath=%classpath%;cfg 9 | 10 | java com.qileyuan.tatala.example.client.TestClient -------------------------------------------------------------------------------- /history/0.1.2/tatala-java-example/client2.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | set classpath=. 3 | set classpath=%classpath%;lib\log4j-1.2.13.jar 4 | set classpath=%classpath%;lib\xpp3_min-1.1.4c.jar 5 | set classpath=%classpath%;lib\xstream-1.3.1.jar 6 | set classpath=%classpath%;lib\tatala.jar 7 | set classpath=%classpath%;dist\tatala-java-example.jar 8 | set classpath=%classpath%;cfg 9 | 10 | java com.qileyuan.tatala.example.client.TestClient2 -------------------------------------------------------------------------------- /history/0.1.2/tatala-java-example/dist/tatala-java-example.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zijan/Tatala-RPC/b975e54a314b38d41f3f85fe93c2346972966cee/history/0.1.2/tatala-java-example/dist/tatala-java-example.jar -------------------------------------------------------------------------------- /history/0.1.2/tatala-java-example/easyclient.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | set classpath=. 3 | set classpath=%classpath%;lib\log4j-1.2.13.jar 4 | set classpath=%classpath%;lib\xpp3_min-1.1.4c.jar 5 | set classpath=%classpath%;lib\xstream-1.3.1.jar 6 | set classpath=%classpath%;lib\tatala.jar 7 | set classpath=%classpath%;dist\tatala-java-example.jar 8 | set classpath=%classpath%;cfg 9 | 10 | java com.qileyuan.tatala.example.client.EasyClient -------------------------------------------------------------------------------- /history/0.1.2/tatala-java-example/lib/log4j-1.2.13.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zijan/Tatala-RPC/b975e54a314b38d41f3f85fe93c2346972966cee/history/0.1.2/tatala-java-example/lib/log4j-1.2.13.jar -------------------------------------------------------------------------------- /history/0.1.2/tatala-java-example/lib/tatala.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zijan/Tatala-RPC/b975e54a314b38d41f3f85fe93c2346972966cee/history/0.1.2/tatala-java-example/lib/tatala.jar -------------------------------------------------------------------------------- /history/0.1.2/tatala-java-example/lib/xpp3_min-1.1.4c.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zijan/Tatala-RPC/b975e54a314b38d41f3f85fe93c2346972966cee/history/0.1.2/tatala-java-example/lib/xpp3_min-1.1.4c.jar -------------------------------------------------------------------------------- /history/0.1.2/tatala-java-example/lib/xstream-1.3.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zijan/Tatala-RPC/b975e54a314b38d41f3f85fe93c2346972966cee/history/0.1.2/tatala-java-example/lib/xstream-1.3.1.jar -------------------------------------------------------------------------------- /history/0.1.2/tatala-java-example/server.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | set classpath=. 3 | set classpath=%classpath%;lib\log4j-1.2.13.jar 4 | set classpath=%classpath%;lib\xpp3_min-1.1.4c.jar 5 | set classpath=%classpath%;lib\xstream-1.3.1.jar 6 | set classpath=%classpath%;lib\tatala.jar 7 | set classpath=%classpath%;dist\tatala-java-example.jar 8 | set classpath=%classpath%;cfg 9 | 10 | java com.qileyuan.tatala.example.service.TestServer 11 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-java-example/src/com/qileyuan/tatala/example/client/ChatRoomClient.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zijan/Tatala-RPC/b975e54a314b38d41f3f85fe93c2346972966cee/history/0.1.2/tatala-java-example/src/com/qileyuan/tatala/example/client/ChatRoomClient.java -------------------------------------------------------------------------------- /history/0.1.2/tatala-java-example/src/com/qileyuan/tatala/example/model/TestAccount.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.example.model; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * This class is a customization object. 7 | * @author JimT 8 | * 9 | */ 10 | public class TestAccount implements Serializable{ 11 | private static final long serialVersionUID = 1L; 12 | private int id; 13 | private String name; 14 | private String address; 15 | 16 | public int getId() { 17 | return id; 18 | } 19 | public void setId(int id) { 20 | this.id = id; 21 | } 22 | public String getName() { 23 | return name; 24 | } 25 | public void setName(String name) { 26 | this.name = name; 27 | } 28 | public String getAddress() { 29 | return address; 30 | } 31 | public void setAddress(String address) { 32 | this.address = address; 33 | } 34 | 35 | public String toString(){ 36 | return "[id: "+id+"][name: "+name+"][address: "+address+"]"; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-java-example/src/com/qileyuan/tatala/example/proxy/ChatRoomClientDefaultProxy.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.example.proxy; 2 | 3 | import com.qileyuan.tatala.example.client.ChatRoomClient; 4 | import com.qileyuan.tatala.proxy.DefaultProxy; 5 | import com.qileyuan.tatala.socket.to.StandardTransferObject; 6 | import com.qileyuan.tatala.socket.to.TransferObject; 7 | 8 | public class ChatRoomClientDefaultProxy extends DefaultProxy { 9 | 10 | public Object execute(TransferObject abstractto){ 11 | StandardTransferObject to = (StandardTransferObject)abstractto; 12 | String calleeMethod = to.getCalleeMethod(); 13 | if(calleeMethod.equals("receiveMessage")){ 14 | String message = to.getString("message"); 15 | ChatRoomClient.getInstance().receiveMessage(message); 16 | } 17 | return null; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-java-example/src/com/qileyuan/tatala/example/proxy/ChatRoomServerProxy.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.example.proxy; 2 | 3 | import com.qileyuan.tatala.example.service.ChatRoomServerLogic; 4 | import com.qileyuan.tatala.socket.server.ServerSession; 5 | import com.qileyuan.tatala.socket.to.StandardTransferObject; 6 | import com.qileyuan.tatala.socket.to.TransferObject; 7 | 8 | public class ChatRoomServerProxy { 9 | 10 | private ChatRoomServerLogic serverLogic = ChatRoomServerLogic.getInstance(); 11 | 12 | public void login(TransferObject baseto){ 13 | StandardTransferObject to = (StandardTransferObject)baseto; 14 | String username = to.getString("username"); 15 | serverLogic.login(to.getClientId(), username); 16 | } 17 | 18 | public void receiveMessage(TransferObject baseto){ 19 | StandardTransferObject to = (StandardTransferObject)baseto; 20 | String message = to.getString("message"); 21 | serverLogic.broadcast(to.getClientId(), message); 22 | } 23 | 24 | public static void sendMessage(ServerSession session, String sendMessage){ 25 | StandardTransferObject to = new StandardTransferObject(); 26 | to.setServerCall(true); 27 | //comment out for call client default proxy 28 | //to.setCalleeClass("com.qileyuan.tatala.example.proxy.ChatRoomClientProxy"); 29 | to.setCalleeMethod("receiveMessage"); 30 | to.putString("message", sendMessage); 31 | session.executeServerCall(to); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-java-example/src/com/qileyuan/tatala/example/service/ChatRoomServer.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.example.service; 2 | 3 | import org.apache.log4j.Logger; 4 | 5 | import com.qileyuan.tatala.socket.server.AioSocketServer; 6 | import com.qileyuan.tatala.util.Configuration; 7 | 8 | public class ChatRoomServer { 9 | static Logger log = Logger.getLogger(ChatRoomServer.class); 10 | 11 | public static void initialize(){ 12 | log.info("Chat Room Server initialize..."); 13 | } 14 | 15 | public static void startup(){ 16 | log.info("Chat Room Server starting..."); 17 | 18 | int listenPort = Configuration.getIntProperty("Server.Socket.listenPort"); 19 | int poolSize = Configuration.getIntProperty("Server.Socket.poolSize"); 20 | 21 | AioSocketServer server = new AioSocketServer(listenPort, poolSize); 22 | server.start(); 23 | 24 | ChatRoomServerLogic serverLogic = ChatRoomServerLogic.getInstance(); 25 | serverLogic.setSessionMap(AioSocketServer.getSessionMap()); 26 | 27 | } 28 | 29 | public static void main(String args[]) { 30 | log.info("*** Chat Room Server ***"); 31 | initialize(); 32 | startup(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-java-example/src/com/qileyuan/tatala/example/service/TestManager.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.example.service; 2 | 3 | import java.util.Date; 4 | import java.util.List; 5 | import java.util.Map; 6 | import java.util.Set; 7 | 8 | import com.qileyuan.tatala.example.model.AllTypeBean; 9 | import com.qileyuan.tatala.example.model.TestAccount; 10 | 11 | 12 | /** 13 | * This interface is a sample for the socket server provider. 14 | * @author JimT 15 | * 16 | */ 17 | public interface TestManager { 18 | public String sayHello(int Id, String name); 19 | public void doSomething(); 20 | public void callServer(int Id); 21 | public TestAccount getAccount(TestAccount account); 22 | public TestAccount getAccount2(TestAccount account, TestAccount account2); 23 | public List getAccountList(List accountList); 24 | public Map getAccountMap(Map accountMap); 25 | public Set getAccountSet(Set accountSet); 26 | public AllTypeBean getAllTypeBean(boolean aboolean, byte abyte, short ashort, char achar, int aint, long along, 27 | float afloat, double adouble, Date adate, String astring); 28 | public String[] getArray(byte[] bytearr, String[] strarr); 29 | } 30 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-java-example/src/com/qileyuan/tatala/example/service/TestReturnException.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.example.service; 2 | 3 | import com.qileyuan.tatala.socket.TatalaReturnException; 4 | 5 | public class TestReturnException extends TatalaReturnException{ 6 | private static final long serialVersionUID = 1L; 7 | 8 | public TestReturnException() { 9 | super(); 10 | } 11 | 12 | public TestReturnException(String msg) { 13 | super(msg); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-java-example/src/com/qileyuan/tatala/example/service/TestServer.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.example.service; 2 | 3 | import org.apache.log4j.Logger; 4 | 5 | import com.qileyuan.tatala.example.proxy.TestDefaultProxy; 6 | import com.qileyuan.tatala.proxy.DefaultProxy; 7 | import com.qileyuan.tatala.socket.server.AioSocketServer; 8 | import com.qileyuan.tatala.util.Configuration; 9 | 10 | public class TestServer { 11 | static Logger log = Logger.getLogger(TestServer.class); 12 | 13 | public static void initialize(){ 14 | log.info("Test Socket Server initialize..."); 15 | } 16 | 17 | public static void startup(){ 18 | log.info("Test Socket Server starting..."); 19 | 20 | int listenPort = Configuration.getIntProperty("Server.Socket.listenPort"); 21 | int poolSize = Configuration.getIntProperty("Server.Socket.poolSize"); 22 | AioSocketServer server = new AioSocketServer(listenPort, poolSize); 23 | 24 | try { 25 | DefaultProxy defaultProxy = new TestDefaultProxy(); 26 | server.registerProxy(defaultProxy); 27 | server.start(); 28 | } catch (Exception e) { 29 | e.printStackTrace(); 30 | } 31 | } 32 | 33 | public static void main(String args[]) { 34 | log.info("*** Test Socket Server ***"); 35 | initialize(); 36 | startup(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-java/build.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 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-java/dist/tatala.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zijan/Tatala-RPC/b975e54a314b38d41f3f85fe93c2346972966cee/history/0.1.2/tatala-java/dist/tatala.jar -------------------------------------------------------------------------------- /history/0.1.2/tatala-java/lib/log4j-1.2.13.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zijan/Tatala-RPC/b975e54a314b38d41f3f85fe93c2346972966cee/history/0.1.2/tatala-java/lib/log4j-1.2.13.jar -------------------------------------------------------------------------------- /history/0.1.2/tatala-java/lib/xpp3_min-1.1.4c.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zijan/Tatala-RPC/b975e54a314b38d41f3f85fe93c2346972966cee/history/0.1.2/tatala-java/lib/xpp3_min-1.1.4c.jar -------------------------------------------------------------------------------- /history/0.1.2/tatala-java/lib/xstream-1.3.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zijan/Tatala-RPC/b975e54a314b38d41f3f85fe93c2346972966cee/history/0.1.2/tatala-java/lib/xstream-1.3.1.jar -------------------------------------------------------------------------------- /history/0.1.2/tatala-java/src/com/qileyuan/tatala/executor/LocalTarget.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.executor; 2 | 3 | import java.lang.reflect.Method; 4 | 5 | import com.qileyuan.tatala.socket.to.TransferObject; 6 | 7 | /** 8 | * This class is local target, simply provider local-method-call. 9 | * 10 | * @author JimT 11 | * 12 | */ 13 | public class LocalTarget implements ServerTarget{ 14 | public Object execute(TransferObject to) { 15 | 16 | String calleeClass = to.getCalleeClass(); 17 | String calleeMethod = to.getCalleeMethod(); 18 | 19 | Object retobj = null; 20 | try { 21 | Class cls = Class.forName(calleeClass); 22 | Object instance = cls.newInstance(); 23 | Method meth = cls.getMethod(calleeMethod, TransferObject.class); 24 | retobj = meth.invoke(instance, to); 25 | } catch (Exception e) { 26 | e.printStackTrace(); 27 | } 28 | 29 | return retobj; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-java/src/com/qileyuan/tatala/executor/ServerExecutor.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.executor; 2 | 3 | import com.qileyuan.tatala.socket.to.TransferObject; 4 | import com.qileyuan.tatala.util.Configuration; 5 | 6 | /** 7 | * This class is the distribution-method-call executor, which dispatches request to different target. 8 | * For now, it only supports local and socket distribution. 9 | * 10 | * @author JimT 11 | * 12 | */ 13 | public class ServerExecutor{ 14 | private static ServerTarget target; 15 | public static Object execute(TransferObject to){ 16 | Object retObj = null; 17 | String serverTarget = Configuration.getProperty("Client.ServerTarget"); 18 | if(serverTarget==null || serverTarget.equals("Socket")){ 19 | target = new SocketServerTarget(); 20 | }else if(serverTarget.equals("Local")){ 21 | target = new LocalTarget(); 22 | } 23 | retObj = target.execute(to); 24 | return retObj; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-java/src/com/qileyuan/tatala/executor/ServerTarget.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.executor; 2 | 3 | import com.qileyuan.tatala.socket.to.TransferObject; 4 | 5 | public interface ServerTarget { 6 | public Object execute(TransferObject to); 7 | } 8 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-java/src/com/qileyuan/tatala/executor/SocketServerTarget.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.executor; 2 | 3 | import com.qileyuan.tatala.socket.client.SocketController; 4 | import com.qileyuan.tatala.socket.to.TransferObject; 5 | 6 | /** 7 | * This class is socket server target, provider socket distribution-method-call. 8 | * @author JimT 9 | * 10 | */ 11 | public class SocketServerTarget implements ServerTarget{ 12 | public Object execute(TransferObject to) { 13 | return SocketController.execute(to); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-java/src/com/qileyuan/tatala/proxy/ClientProxyFactory.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.proxy; 2 | 3 | import java.lang.reflect.Proxy; 4 | 5 | import com.qileyuan.tatala.socket.to.TransferObjectFactory; 6 | 7 | public class ClientProxyFactory { 8 | public static Object create(Class clazz, TransferObjectFactory transferObjectFactory) { 9 | return Proxy.newProxyInstance( 10 | ClientProxyFactory.class.getClassLoader(), 11 | new Class[] { clazz }, 12 | new ClientProxy(transferObjectFactory)); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-java/src/com/qileyuan/tatala/proxy/DefaultProxy.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.proxy; 2 | 3 | import org.apache.log4j.Logger; 4 | 5 | import com.qileyuan.tatala.socket.to.TransferObject; 6 | 7 | public class DefaultProxy { 8 | Logger log = Logger.getLogger(DefaultProxy.class); 9 | public Object execute(TransferObject to){ 10 | log.error("This is DefaultProxy. You need extend it by specific proxy."); 11 | return null; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-java/src/com/qileyuan/tatala/socket/SocketExecuteException.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.socket; 2 | 3 | public class SocketExecuteException extends Exception { 4 | 5 | private static final long serialVersionUID = 1L; 6 | 7 | public SocketExecuteException() { 8 | super(); 9 | } 10 | 11 | public SocketExecuteException(String msg) { 12 | super(msg); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-java/src/com/qileyuan/tatala/socket/TatalaReturnException.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.socket; 2 | 3 | public class TatalaReturnException extends RuntimeException{ 4 | 5 | private static final long serialVersionUID = 1L; 6 | 7 | public TatalaReturnException() { 8 | super(); 9 | } 10 | 11 | public TatalaReturnException(String msg) { 12 | super(msg); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-java/src/com/qileyuan/tatala/socket/client/AioClientReceiveHandler.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.socket.client; 2 | 3 | import java.nio.ByteBuffer; 4 | import java.nio.channels.CompletionHandler; 5 | 6 | import org.apache.log4j.Logger; 7 | 8 | public class AioClientReceiveHandler implements CompletionHandler { 9 | Logger log = Logger.getLogger(AioClientReceiveHandler.class); 10 | 11 | @Override 12 | public void completed(Integer receivedCount, LongClientSession session) { 13 | 14 | //server close socket channel or network issue 15 | if(receivedCount < 0){ 16 | session.close(); 17 | return; 18 | } 19 | try { 20 | ByteBuffer byteBuffer = session.getByteBuffer(); 21 | if(receivedCount > 0){ 22 | byteBuffer.flip(); 23 | byte[] receiveData = new byte[byteBuffer.limit()]; 24 | byteBuffer.get(receiveData); 25 | session.write(receiveData); 26 | byteBuffer.compact(); 27 | 28 | //chech whether one receive from server is done 29 | session.checkOneReceiveDone(receivedCount, receiveData); 30 | } 31 | } finally { 32 | session.receive(); 33 | } 34 | } 35 | 36 | @Override 37 | public void failed(Throwable exc, LongClientSession session) { 38 | log.error("Receive error: " + exc.getMessage(), exc); 39 | session.close(); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-java/src/com/qileyuan/tatala/socket/server/AioReceiveHandler.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.socket.server; 2 | 3 | import java.nio.ByteBuffer; 4 | import java.nio.channels.CompletionHandler; 5 | 6 | import org.apache.log4j.Logger; 7 | 8 | public class AioReceiveHandler implements CompletionHandler{ 9 | Logger log = Logger.getLogger(AioReceiveHandler.class); 10 | 11 | @Override 12 | public void completed(Integer receivedCount, ServerSession session) { 13 | if(receivedCount < 0){ 14 | session.close(); 15 | return; 16 | } 17 | try { 18 | ByteBuffer byteBuffer = session.getByteBuffer(); 19 | 20 | if (receivedCount > 0) { 21 | byteBuffer.flip(); 22 | byte[] receiveData = new byte[byteBuffer.limit()]; 23 | byteBuffer.get(receiveData); 24 | session.write(receiveData); 25 | byteBuffer.compact(); 26 | 27 | //chech whether one client request is done 28 | session.checkOneReceiveDone(receivedCount, receiveData); 29 | } 30 | } finally { 31 | session.receive(); 32 | } 33 | } 34 | 35 | @Override 36 | public void failed(Throwable exc, ServerSession session) { 37 | log.error("Receive error: " + exc.getMessage()); 38 | session.close(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-java/src/com/qileyuan/tatala/socket/server/AioSocketHandler.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.socket.server; 2 | 3 | import java.nio.channels.AsynchronousSocketChannel; 4 | import java.nio.channels.CompletionHandler; 5 | 6 | import org.apache.log4j.Logger; 7 | 8 | public class AioSocketHandler implements CompletionHandler { 9 | Logger log = Logger.getLogger(AioSocketHandler.class); 10 | 11 | private ServerSession session; 12 | 13 | public AioSocketHandler(ServerSession session){ 14 | this.session = session; 15 | } 16 | 17 | @Override 18 | public void completed(AsynchronousSocketChannel socketChannel, AioSocketServer aioSocketServer) { 19 | try { 20 | session.setSocketChannel(socketChannel); 21 | session.start(); 22 | } finally{ 23 | aioSocketServer.acceptConnections(); 24 | } 25 | } 26 | 27 | @Override 28 | public void failed(Throwable exc, AioSocketServer aioSocketServer) { 29 | log.error("Accept error", exc); 30 | aioSocketServer.acceptConnections(); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-java/src/com/qileyuan/tatala/socket/server/SessionFilter.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.socket.server; 2 | 3 | public interface SessionFilter { 4 | public void onClose(ServerSession session); 5 | //if return true, ignore execute code 6 | public boolean onReceive(ServerSession session, byte[] receiveData); 7 | } 8 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-java/src/com/qileyuan/tatala/socket/to/TransferObjectWrapper.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.socket.to; 2 | 3 | import com.qileyuan.tatala.socket.io.TransferInputStream; 4 | import com.qileyuan.tatala.socket.io.TransferOutputStream; 5 | 6 | /** 7 | * This is customization object wrapper interface. 8 | * 9 | * @author JimT 10 | * 11 | */ 12 | public interface TransferObjectWrapper { 13 | public int getLength(); 14 | public void getByteArray(TransferOutputStream touts); 15 | public TransferObjectWrapper getObjectWrapper(TransferInputStream tins); 16 | } 17 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-java/src/com/qileyuan/tatala/socket/to/helper/BooleanMapHelper.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.socket.to.helper; 2 | 3 | import java.util.Iterator; 4 | import java.util.Map; 5 | 6 | import com.qileyuan.tatala.socket.io.TransferOutputStream; 7 | import com.qileyuan.tatala.socket.to.TransferObject; 8 | import com.qileyuan.tatala.socket.util.TransferUtil; 9 | 10 | public class BooleanMapHelper { 11 | public static int getByteArrayLength(Map booleanMap){ 12 | int blength = 0; 13 | Iterator keyIt = booleanMap.keySet().iterator(); 14 | while (keyIt.hasNext()) { 15 | // type 16 | blength += TransferUtil.getLengthOfByte(); 17 | // key 18 | String key = (String) keyIt.next(); 19 | blength += TransferUtil.getLengthOfString(key); 20 | // value 21 | blength += TransferUtil.getLengthOfBoolean(); 22 | } 23 | return blength; 24 | } 25 | 26 | public static void getByteArray(Map booleanMap, TransferOutputStream touts) { 27 | Iterator keyIt = booleanMap.keySet().iterator(); 28 | while (keyIt.hasNext()) { 29 | // type 30 | touts.writeByte(TransferObject.DATATYPE_BOOLEAN); 31 | // key 32 | String key = (String) keyIt.next(); 33 | touts.writeString(key); 34 | // value 35 | boolean value = booleanMap.get(key); 36 | touts.writeBoolean(value); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-java/src/com/qileyuan/tatala/socket/to/helper/ByteArrayMapHelper.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.socket.to.helper; 2 | 3 | import java.util.Iterator; 4 | import java.util.Map; 5 | 6 | import com.qileyuan.tatala.socket.io.TransferOutputStream; 7 | import com.qileyuan.tatala.socket.to.TransferObject; 8 | import com.qileyuan.tatala.socket.util.TransferUtil; 9 | 10 | public class ByteArrayMapHelper { 11 | 12 | public static int getByteArrayLength(Map byteArrayMap){ 13 | int blength = 0; 14 | Iterator keyIt = byteArrayMap.keySet().iterator(); 15 | while (keyIt.hasNext()) { 16 | // type 17 | blength += TransferUtil.getLengthOfByte(); 18 | // key 19 | String key = (String) keyIt.next(); 20 | blength += TransferUtil.getLengthOfString(key); 21 | // value 22 | byte[] values = byteArrayMap.get(key); 23 | blength += TransferUtil.getLengthOfByteArray(values); 24 | } 25 | return blength; 26 | } 27 | 28 | public static void getByteArray(Map byteArrayMap, TransferOutputStream touts) { 29 | Iterator keyIt = byteArrayMap.keySet().iterator(); 30 | while (keyIt.hasNext()) { 31 | // type 32 | touts.writeByte(TransferObject.DATATYPE_BYTEARRAY); 33 | // key 34 | String key = (String) keyIt.next(); 35 | touts.writeString(key); 36 | // value 37 | byte[] values = byteArrayMap.get(key); 38 | touts.writeByteArray(values); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-java/src/com/qileyuan/tatala/socket/to/helper/ByteMapHelper.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.socket.to.helper; 2 | 3 | import java.util.Iterator; 4 | import java.util.Map; 5 | 6 | import com.qileyuan.tatala.socket.io.TransferOutputStream; 7 | import com.qileyuan.tatala.socket.to.TransferObject; 8 | import com.qileyuan.tatala.socket.util.TransferUtil; 9 | 10 | public class ByteMapHelper { 11 | public static int getByteArrayLength(Map byteMap){ 12 | int blength = 0; 13 | Iterator keyIt = byteMap.keySet().iterator(); 14 | while (keyIt.hasNext()) { 15 | // type 16 | blength += TransferUtil.getLengthOfByte(); 17 | // key 18 | String key = (String) keyIt.next(); 19 | blength += TransferUtil.getLengthOfString(key); 20 | // value 21 | blength += TransferUtil.getLengthOfByte(); 22 | } 23 | return blength; 24 | } 25 | 26 | public static void getByteArray(Map byteMap, TransferOutputStream touts) { 27 | Iterator keyIt = byteMap.keySet().iterator(); 28 | while (keyIt.hasNext()) { 29 | // type 30 | touts.writeByte(TransferObject.DATATYPE_BYTE); 31 | // key 32 | String key = (String) keyIt.next(); 33 | touts.writeString(key); 34 | // value 35 | byte value = byteMap.get(key); 36 | touts.writeByte(value); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-java/src/com/qileyuan/tatala/socket/to/helper/CharMapHelper.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.socket.to.helper; 2 | 3 | import java.util.Iterator; 4 | import java.util.Map; 5 | 6 | import com.qileyuan.tatala.socket.io.TransferOutputStream; 7 | import com.qileyuan.tatala.socket.to.TransferObject; 8 | import com.qileyuan.tatala.socket.util.TransferUtil; 9 | 10 | public class CharMapHelper { 11 | public static int getByteArrayLength(Map charMap){ 12 | int blength = 0; 13 | Iterator keyIt = charMap.keySet().iterator(); 14 | while (keyIt.hasNext()) { 15 | // type 16 | blength += TransferUtil.getLengthOfByte(); 17 | // key 18 | String key = (String) keyIt.next(); 19 | blength += TransferUtil.getLengthOfString(key); 20 | // value 21 | blength += TransferUtil.getLengthOfChar(); 22 | } 23 | return blength; 24 | } 25 | 26 | public static void getByteArray(Map charMap, TransferOutputStream touts) { 27 | Iterator keyIt = charMap.keySet().iterator(); 28 | while (keyIt.hasNext()) { 29 | // type 30 | touts.writeByte(TransferObject.DATATYPE_CHAR); 31 | // key 32 | String key = (String) keyIt.next(); 33 | touts.writeString(key); 34 | // value 35 | char value = charMap.get(key); 36 | touts.writeChar(value); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-java/src/com/qileyuan/tatala/socket/to/helper/DateMapHelper.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.socket.to.helper; 2 | 3 | import java.util.Date; 4 | import java.util.Iterator; 5 | import java.util.Map; 6 | 7 | import com.qileyuan.tatala.socket.io.TransferOutputStream; 8 | import com.qileyuan.tatala.socket.to.TransferObject; 9 | import com.qileyuan.tatala.socket.util.TransferUtil; 10 | 11 | public class DateMapHelper { 12 | public static int getByteArrayLength(Map dateMap){ 13 | int blength = 0; 14 | Iterator keyIt = dateMap.keySet().iterator(); 15 | while (keyIt.hasNext()) { 16 | // type 17 | blength += TransferUtil.getLengthOfByte(); 18 | // key 19 | String key = (String) keyIt.next(); 20 | blength += TransferUtil.getLengthOfString(key); 21 | // value 22 | blength += TransferUtil.getLengthOfDate(); 23 | } 24 | return blength; 25 | } 26 | 27 | public static void getByteArray(Map dateMap, TransferOutputStream touts) { 28 | Iterator keyIt = dateMap.keySet().iterator(); 29 | while (keyIt.hasNext()) { 30 | // type 31 | touts.writeByte(TransferObject.DATATYPE_DATE); 32 | // key 33 | String key = (String) keyIt.next(); 34 | touts.writeString(key); 35 | // value 36 | Date value = dateMap.get(key); 37 | touts.writeDate(value); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-java/src/com/qileyuan/tatala/socket/to/helper/DoubleArrayMapHelper.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.socket.to.helper; 2 | 3 | import java.util.Iterator; 4 | import java.util.Map; 5 | 6 | import com.qileyuan.tatala.socket.io.TransferOutputStream; 7 | import com.qileyuan.tatala.socket.to.TransferObject; 8 | import com.qileyuan.tatala.socket.util.TransferUtil; 9 | 10 | public class DoubleArrayMapHelper { 11 | 12 | public static int getByteArrayLength(Map doubleArrayMap){ 13 | int blength = 0; 14 | Iterator keyIt = doubleArrayMap.keySet().iterator(); 15 | while (keyIt.hasNext()) { 16 | // type 17 | blength += TransferUtil.getLengthOfByte(); 18 | // key 19 | String key = (String) keyIt.next(); 20 | blength += TransferUtil.getLengthOfString(key); 21 | // value 22 | double[] values = doubleArrayMap.get(key); 23 | blength += TransferUtil.getLengthOfDoubleArray(values); 24 | } 25 | return blength; 26 | } 27 | 28 | public static void getByteArray(Map doubleArrayMap, TransferOutputStream touts) { 29 | Iterator keyIt = doubleArrayMap.keySet().iterator(); 30 | while (keyIt.hasNext()) { 31 | // type 32 | touts.writeByte(TransferObject.DATATYPE_DOUBLEARRAY); 33 | // key 34 | String key = (String) keyIt.next(); 35 | touts.writeString(key); 36 | // value 37 | double[] values = doubleArrayMap.get(key); 38 | touts.writeDoubleArray(values); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-java/src/com/qileyuan/tatala/socket/to/helper/DoubleMapHelper.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.socket.to.helper; 2 | 3 | import java.util.Iterator; 4 | import java.util.Map; 5 | 6 | import com.qileyuan.tatala.socket.io.TransferOutputStream; 7 | import com.qileyuan.tatala.socket.to.TransferObject; 8 | import com.qileyuan.tatala.socket.util.TransferUtil; 9 | 10 | public class DoubleMapHelper { 11 | public static int getByteArrayLength(Map doubleMap){ 12 | int blength = 0; 13 | Iterator keyIt = doubleMap.keySet().iterator(); 14 | while (keyIt.hasNext()) { 15 | // type 16 | blength += TransferUtil.getLengthOfByte(); 17 | // key 18 | String key = (String) keyIt.next(); 19 | blength += TransferUtil.getLengthOfString(key); 20 | // value 21 | blength += TransferUtil.getLengthOfDouble(); 22 | } 23 | return blength; 24 | } 25 | 26 | public static void getByteArray(Map doubleMap, TransferOutputStream touts) { 27 | Iterator keyIt = doubleMap.keySet().iterator(); 28 | while (keyIt.hasNext()) { 29 | // type 30 | touts.writeByte(TransferObject.DATATYPE_DOUBLE); 31 | // key 32 | String key = (String) keyIt.next(); 33 | touts.writeString(key); 34 | // value 35 | double value = doubleMap.get(key); 36 | touts.writeDouble(value); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-java/src/com/qileyuan/tatala/socket/to/helper/FloatArrayMapHelper.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.socket.to.helper; 2 | 3 | import java.util.Iterator; 4 | import java.util.Map; 5 | 6 | import com.qileyuan.tatala.socket.io.TransferOutputStream; 7 | import com.qileyuan.tatala.socket.to.TransferObject; 8 | import com.qileyuan.tatala.socket.util.TransferUtil; 9 | 10 | public class FloatArrayMapHelper { 11 | 12 | public static int getByteArrayLength(Map floatArrayMap){ 13 | int blength = 0; 14 | Iterator keyIt = floatArrayMap.keySet().iterator(); 15 | while (keyIt.hasNext()) { 16 | // type 17 | blength += TransferUtil.getLengthOfByte(); 18 | // key 19 | String key = (String) keyIt.next(); 20 | blength += TransferUtil.getLengthOfString(key); 21 | // value 22 | float[] values = floatArrayMap.get(key); 23 | blength += TransferUtil.getLengthOfFloatArray(values); 24 | } 25 | return blength; 26 | } 27 | 28 | public static void getByteArray(Map floatArrayMap, TransferOutputStream touts) { 29 | Iterator keyIt = floatArrayMap.keySet().iterator(); 30 | while (keyIt.hasNext()) { 31 | // type 32 | touts.writeByte(TransferObject.DATATYPE_FLOATARRAY); 33 | // key 34 | String key = (String) keyIt.next(); 35 | touts.writeString(key); 36 | // value 37 | float[] values = floatArrayMap.get(key); 38 | touts.writeFloatArray(values); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-java/src/com/qileyuan/tatala/socket/to/helper/FloatMapHelper.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.socket.to.helper; 2 | 3 | import java.util.Iterator; 4 | import java.util.Map; 5 | 6 | import com.qileyuan.tatala.socket.io.TransferOutputStream; 7 | import com.qileyuan.tatala.socket.to.TransferObject; 8 | import com.qileyuan.tatala.socket.util.TransferUtil; 9 | 10 | public class FloatMapHelper { 11 | public static int getByteArrayLength(Map floatMap){ 12 | int blength = 0; 13 | Iterator keyIt = floatMap.keySet().iterator(); 14 | while (keyIt.hasNext()) { 15 | // type 16 | blength += TransferUtil.getLengthOfByte(); 17 | // key 18 | String key = (String) keyIt.next(); 19 | blength += TransferUtil.getLengthOfString(key); 20 | // value 21 | blength += TransferUtil.getLengthOfFloat(); 22 | } 23 | return blength; 24 | } 25 | 26 | public static void getByteArray(Map floatMap, TransferOutputStream touts) { 27 | Iterator keyIt = floatMap.keySet().iterator(); 28 | while (keyIt.hasNext()) { 29 | // type 30 | touts.writeByte(TransferObject.DATATYPE_FLOAT); 31 | // key 32 | String key = (String) keyIt.next(); 33 | touts.writeString(key); 34 | // value 35 | float value = floatMap.get(key); 36 | touts.writeFloat(value); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-java/src/com/qileyuan/tatala/socket/to/helper/IntArrayMapHelper.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.socket.to.helper; 2 | 3 | import java.util.Iterator; 4 | import java.util.Map; 5 | 6 | import com.qileyuan.tatala.socket.io.TransferOutputStream; 7 | import com.qileyuan.tatala.socket.to.TransferObject; 8 | import com.qileyuan.tatala.socket.util.TransferUtil; 9 | 10 | public class IntArrayMapHelper { 11 | 12 | public static int getByteArrayLength(Map intArrayMap){ 13 | int blength = 0; 14 | Iterator keyIt = intArrayMap.keySet().iterator(); 15 | while (keyIt.hasNext()) { 16 | // type 17 | blength += TransferUtil.getLengthOfByte(); 18 | // key 19 | String key = (String) keyIt.next(); 20 | blength += TransferUtil.getLengthOfString(key); 21 | // value 22 | int[] values = intArrayMap.get(key); 23 | blength += TransferUtil.getLengthOfIntArray(values); 24 | } 25 | return blength; 26 | } 27 | 28 | public static void getByteArray(Map intArrayMap, TransferOutputStream touts) { 29 | Iterator keyIt = intArrayMap.keySet().iterator(); 30 | while (keyIt.hasNext()) { 31 | // type 32 | touts.writeByte(TransferObject.DATATYPE_INTARRAY); 33 | // key 34 | String key = (String) keyIt.next(); 35 | touts.writeString(key); 36 | // value 37 | int[] values = intArrayMap.get(key); 38 | touts.writeIntArray(values); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-java/src/com/qileyuan/tatala/socket/to/helper/IntMapHelper.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.socket.to.helper; 2 | 3 | import java.util.Iterator; 4 | import java.util.Map; 5 | 6 | import com.qileyuan.tatala.socket.io.TransferOutputStream; 7 | import com.qileyuan.tatala.socket.to.TransferObject; 8 | import com.qileyuan.tatala.socket.util.TransferUtil; 9 | 10 | public class IntMapHelper { 11 | 12 | public static int getByteArrayLength(Map intMap){ 13 | int blength = 0; 14 | Iterator keyIt = intMap.keySet().iterator(); 15 | while (keyIt.hasNext()) { 16 | // type 17 | blength += TransferUtil.getLengthOfByte(); 18 | // key 19 | String key = (String) keyIt.next(); 20 | blength += TransferUtil.getLengthOfString(key); 21 | // value 22 | blength += TransferUtil.getLengthOfInt(); 23 | } 24 | return blength; 25 | } 26 | 27 | public static void getByteArray(Map intMap, TransferOutputStream touts) { 28 | Iterator keyIt = intMap.keySet().iterator(); 29 | while (keyIt.hasNext()) { 30 | // type 31 | touts.writeByte(TransferObject.DATATYPE_INT); 32 | // key 33 | String key = (String) keyIt.next(); 34 | touts.writeString(key); 35 | // value 36 | int value = intMap.get(key); 37 | touts.writeInt(value); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-java/src/com/qileyuan/tatala/socket/to/helper/LongArrayMapHelper.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.socket.to.helper; 2 | 3 | import java.util.Iterator; 4 | import java.util.Map; 5 | 6 | import com.qileyuan.tatala.socket.io.TransferOutputStream; 7 | import com.qileyuan.tatala.socket.to.TransferObject; 8 | import com.qileyuan.tatala.socket.util.TransferUtil; 9 | 10 | public class LongArrayMapHelper { 11 | 12 | public static int getByteArrayLength(Map longArrayMap){ 13 | int blength = 0; 14 | Iterator keyIt = longArrayMap.keySet().iterator(); 15 | while (keyIt.hasNext()) { 16 | // type 17 | blength += TransferUtil.getLengthOfByte(); 18 | // key 19 | String key = (String) keyIt.next(); 20 | blength += TransferUtil.getLengthOfString(key); 21 | // value 22 | long[] values = longArrayMap.get(key); 23 | blength += TransferUtil.getLengthOfLongArray(values); 24 | } 25 | return blength; 26 | } 27 | 28 | public static void getByteArray(Map longArrayMap, TransferOutputStream touts) { 29 | Iterator keyIt = longArrayMap.keySet().iterator(); 30 | while (keyIt.hasNext()) { 31 | // type 32 | touts.writeByte(TransferObject.DATATYPE_LONGARRAY); 33 | // key 34 | String key = (String) keyIt.next(); 35 | touts.writeString(key); 36 | // value 37 | long[] values = longArrayMap.get(key); 38 | touts.writeLongArray(values); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-java/src/com/qileyuan/tatala/socket/to/helper/LongMapHelper.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.socket.to.helper; 2 | 3 | import java.util.Iterator; 4 | import java.util.Map; 5 | 6 | import com.qileyuan.tatala.socket.io.TransferOutputStream; 7 | import com.qileyuan.tatala.socket.to.TransferObject; 8 | import com.qileyuan.tatala.socket.util.TransferUtil; 9 | 10 | public class LongMapHelper { 11 | public static int getByteArrayLength(Map longMap){ 12 | int blength = 0; 13 | Iterator keyIt = longMap.keySet().iterator(); 14 | while (keyIt.hasNext()) { 15 | // type 16 | blength += TransferUtil.getLengthOfByte(); 17 | // key 18 | String key = (String) keyIt.next(); 19 | blength += TransferUtil.getLengthOfString(key); 20 | // value 21 | blength += TransferUtil.getLengthOfLong(); 22 | } 23 | return blength; 24 | } 25 | 26 | public static void getByteArray(Map longMap, TransferOutputStream touts) { 27 | Iterator keyIt = longMap.keySet().iterator(); 28 | while (keyIt.hasNext()) { 29 | // type 30 | touts.writeByte(TransferObject.DATATYPE_LONG); 31 | // key 32 | String key = (String) keyIt.next(); 33 | touts.writeString(key); 34 | // value 35 | long value = longMap.get(key); 36 | touts.writeLong(value); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-java/src/com/qileyuan/tatala/socket/to/helper/ShortMapHelper.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.socket.to.helper; 2 | 3 | import java.util.Iterator; 4 | import java.util.Map; 5 | 6 | import com.qileyuan.tatala.socket.io.TransferOutputStream; 7 | import com.qileyuan.tatala.socket.to.TransferObject; 8 | import com.qileyuan.tatala.socket.util.TransferUtil; 9 | 10 | public class ShortMapHelper { 11 | public static int getByteArrayLength(Map shortMap){ 12 | int blength = 0; 13 | Iterator keyIt = shortMap.keySet().iterator(); 14 | while (keyIt.hasNext()) { 15 | // type 16 | blength += TransferUtil.getLengthOfByte(); 17 | // key 18 | String key = (String) keyIt.next(); 19 | blength += TransferUtil.getLengthOfString(key); 20 | // value 21 | blength += TransferUtil.getLengthOfShort(); 22 | } 23 | return blength; 24 | } 25 | 26 | public static void getByteArray(Map shortMap, TransferOutputStream touts) { 27 | Iterator keyIt = shortMap.keySet().iterator(); 28 | while (keyIt.hasNext()) { 29 | // type 30 | touts.writeByte(TransferObject.DATATYPE_SHORT); 31 | // key 32 | String key = (String) keyIt.next(); 33 | touts.writeString(key); 34 | // value 35 | short value = shortMap.get(key); 36 | touts.writeShort(value); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-java/src/com/qileyuan/tatala/socket/to/helper/StringArrayMapHelper.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.socket.to.helper; 2 | 3 | import java.util.Iterator; 4 | import java.util.Map; 5 | 6 | import com.qileyuan.tatala.socket.io.TransferOutputStream; 7 | import com.qileyuan.tatala.socket.to.TransferObject; 8 | import com.qileyuan.tatala.socket.util.TransferUtil; 9 | 10 | public class StringArrayMapHelper { 11 | 12 | public static int getByteArrayLength(Map stringArrayMap){ 13 | int blength = 0; 14 | Iterator keyIt = stringArrayMap.keySet().iterator(); 15 | while (keyIt.hasNext()) { 16 | // type 17 | blength += TransferUtil.getLengthOfByte(); 18 | // key 19 | String key = (String) keyIt.next(); 20 | blength += TransferUtil.getLengthOfString(key); 21 | // value 22 | String[] values = stringArrayMap.get(key); 23 | blength += TransferUtil.getLengthOfStringArray(values); 24 | } 25 | return blength; 26 | } 27 | 28 | public static void getByteArray(Map stringArrayMap, TransferOutputStream touts) { 29 | Iterator keyIt = stringArrayMap.keySet().iterator(); 30 | while (keyIt.hasNext()) { 31 | // type 32 | touts.writeByte(TransferObject.DATATYPE_STRINGARRAY); 33 | // key 34 | String key = (String) keyIt.next(); 35 | touts.writeString(key); 36 | // value 37 | String[] values = stringArrayMap.get(key); 38 | touts.writeStringArray(values); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-java/src/com/qileyuan/tatala/socket/to/helper/StringMapHelper.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.socket.to.helper; 2 | 3 | import java.util.Iterator; 4 | import java.util.Map; 5 | 6 | import com.qileyuan.tatala.socket.io.TransferOutputStream; 7 | import com.qileyuan.tatala.socket.to.TransferObject; 8 | import com.qileyuan.tatala.socket.util.TransferUtil; 9 | 10 | public class StringMapHelper { 11 | public static int getByteArrayLength(Map stringMap){ 12 | int blength = 0; 13 | Iterator keyIt = stringMap.keySet().iterator(); 14 | while (keyIt.hasNext()) { 15 | // type 16 | blength += TransferUtil.getLengthOfByte(); 17 | // key 18 | String key = (String) keyIt.next(); 19 | blength += TransferUtil.getLengthOfString(key); 20 | // value 21 | String value = stringMap.get(key); 22 | blength += TransferUtil.getLengthOfString(value); 23 | } 24 | return blength; 25 | } 26 | 27 | public static void getByteArray(Map stringMap, TransferOutputStream touts) { 28 | Iterator keyIt = stringMap.keySet().iterator(); 29 | while (keyIt.hasNext()) { 30 | // type 31 | touts.writeByte(TransferObject.DATATYPE_STRING); 32 | // key 33 | String key = (String) keyIt.next(); 34 | touts.writeString(key); 35 | // value 36 | String value = stringMap.get(key); 37 | touts.writeString(value); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-java/src/com/qileyuan/tatala/socket/to/helper/WrapperMapHelper.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.socket.to.helper; 2 | 3 | import java.util.Iterator; 4 | import java.util.Map; 5 | 6 | import com.qileyuan.tatala.socket.io.TransferOutputStream; 7 | import com.qileyuan.tatala.socket.to.TransferObject; 8 | import com.qileyuan.tatala.socket.to.TransferObjectWrapper; 9 | import com.qileyuan.tatala.socket.util.TransferUtil; 10 | 11 | public class WrapperMapHelper { 12 | public static int getByteArrayLength(Map wrapperMap){ 13 | int blength = 0; 14 | Iterator keyIt = wrapperMap.keySet().iterator(); 15 | while (keyIt.hasNext()) { 16 | // type 17 | blength += TransferUtil.getLengthOfByte(); 18 | // key 19 | String key = (String) keyIt.next(); 20 | blength += TransferUtil.getLengthOfString(key); 21 | // value 22 | TransferObjectWrapper value = wrapperMap.get(key); 23 | blength += TransferUtil.getLengthOfWrapper(value); 24 | } 25 | return blength; 26 | } 27 | 28 | public static void getByteArray(Map wrapperMap, TransferOutputStream touts) { 29 | Iterator keyIt = wrapperMap.keySet().iterator(); 30 | while (keyIt.hasNext()) { 31 | // type 32 | touts.writeByte(TransferObject.DATATYPE_WRAPPER); 33 | // key 34 | String key = (String) keyIt.next(); 35 | touts.writeString(key); 36 | // value 37 | TransferObjectWrapper value = wrapperMap.get(key); 38 | touts.writeWrapper(value); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /history/0.1.2/tatala-java/src/com/qileyuan/tatala/socket/util/NetworkUtil.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.socket.util; 2 | 3 | import java.io.IOException; 4 | import java.net.InetSocketAddress; 5 | import java.nio.channels.AsynchronousSocketChannel; 6 | 7 | public class NetworkUtil { 8 | public static long convertIpPortToUniqueId(byte[] quad, int port) { 9 | return (((long)port) << 32 10 | | ((long)(quad[0] & 0xFF)) << 24 11 | | ((long)(quad[1] & 0xFF)) << 16 12 | | ((long)(quad[2] & 0xFF)) << 8 13 | | ((long)(quad[3] & 0xFF))); 14 | } 15 | 16 | public static long getClientIdBySocketChannel(AsynchronousSocketChannel socketChannel) throws IOException{ 17 | InetSocketAddress address = (InetSocketAddress)socketChannel.getRemoteAddress(); 18 | byte[] quad = address.getAddress().getAddress(); 19 | int port = address.getPort(); 20 | long clientId = NetworkUtil.convertIpPortToUniqueId(quad, port); 21 | return clientId; 22 | } 23 | 24 | public static String getIpPortByClientId(long clientId){ 25 | long port = clientId >> 32; 26 | long ip1 = (clientId >> 24) - (port << 8); 27 | long ip2 = (clientId >> 16) - (ip1 << 8) - (port << 16); 28 | long ip3 = (clientId >> 8) - (ip2 << 8) - (ip1 << 16) - (port << 24); 29 | long ip4 = clientId - (ip3 << 8) - (ip2 << 16) - (ip1 << 24) - (port << 32); 30 | return ip1+"."+ip2+"."+ip3+"."+ip4+":"+port; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /history/0.2.0/tatala-client-csharp/cfg/controller.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 127.0.0.1 4 | 10001 5 | 5000 6 | 3 7 | test1 8 | 9 | 10 | 127.0.0.1 11 | 10002 12 | 5000 13 | 3 14 | test2 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /history/0.2.0/tatala-client-csharp/src/Example/Tatala/model/TestAccount.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | /** 4 | * This class is a customization object. 5 | * @author JimT 6 | * 7 | */ 8 | namespace Example.tatala.model { 9 | 10 | public class TestAccount { 11 | 12 | private int id; 13 | private String name; 14 | private String address; 15 | 16 | public int getId() { 17 | return id; 18 | } 19 | public void setId(int id) { 20 | this.id = id; 21 | } 22 | public String getName() { 23 | return name; 24 | } 25 | public void setName(String name) { 26 | this.name = name; 27 | } 28 | public String getAddress() { 29 | return address; 30 | } 31 | public void setAddress(String address) { 32 | this.address = address; 33 | } 34 | 35 | public override String ToString() { 36 | return "[id: " + id + "][name: " + name + "][address: " + address + "]"; 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /history/0.2.0/tatala-client-csharp/src/Example/Tatala/proxy/ChatRoomClientDefaultProxy.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Example.tatala.client; 3 | using QiLeYuan.Tatala.proxy; 4 | using QiLeYuan.Tatala.socket.to; 5 | 6 | namespace Example.tatala.proxy { 7 | public class ChatRoomClientDefaultProxy : DefaultProxy { 8 | 9 | public override Object execute(TransferObject baseto) { 10 | StandardTransferObject to = (StandardTransferObject)baseto; 11 | String calleeMethod = to.getCalleeMethod(); 12 | if (calleeMethod.Equals("receiveMessage")) { 13 | String message = to.getString("message"); 14 | ChatRoomClient.getInstance().receiveMessage(message); 15 | } 16 | 17 | return null; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /history/0.2.0/tatala-client-csharp/src/QiLeYuan/Tatala/executor/LocalTarget.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using QiLeYuan.Tatala.socket.to; 4 | using QiLeYuan.Tools.debug; 5 | 6 | /** 7 | * This class is local target, simply provider local-method-call. 8 | * 9 | * @author JimT 10 | * 11 | */ 12 | namespace QiLeYuan.Tatala.executor { 13 | 14 | public class LocalTarget : ServerTarget { 15 | public Object execute(TransferObject to) { 16 | 17 | String calleeClass = to.getCalleeClass(); 18 | String calleeMethod = to.getCalleeMethod(); 19 | 20 | Object retobj = null; 21 | try { 22 | Type type = Type.GetType(calleeClass); 23 | Object instance = Activator.CreateInstance(type); 24 | MethodInfo method = type.GetMethod(calleeMethod); 25 | retobj = method.Invoke(instance, new object[] { to }); 26 | } catch (Exception e) { 27 | Logging.LogError(e.ToString()); 28 | } 29 | 30 | return retobj; 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /history/0.2.0/tatala-client-csharp/src/QiLeYuan/Tatala/executor/ServerExecutor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using QiLeYuan.Tatala.util; 3 | using QiLeYuan.Tatala.socket.to; 4 | 5 | /** 6 | * This class is the distribution-method-call executor, which dispatches request to different target. 7 | * For now, it only supports local and socket distribution. 8 | * 9 | * @author JimT 10 | * 11 | */ 12 | namespace QiLeYuan.Tatala.executor { 13 | 14 | public class ServerExecutor { 15 | private static ServerTarget target; 16 | public static Object execute(TransferObject to) { 17 | Object retObj = null; 18 | //for csharp client, server target is Socket. 19 | target = new SocketServerTarget(); 20 | retObj = target.execute(to); 21 | return retObj; 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /history/0.2.0/tatala-client-csharp/src/QiLeYuan/Tatala/executor/ServerTarget.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using QiLeYuan.Tatala.socket.to; 3 | 4 | namespace QiLeYuan.Tatala.executor { 5 | 6 | public interface ServerTarget { 7 | Object execute(TransferObject to); 8 | } 9 | } -------------------------------------------------------------------------------- /history/0.2.0/tatala-client-csharp/src/QiLeYuan/Tatala/executor/SocketServerTarget.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using QiLeYuan.Tatala.socket.client; 3 | using QiLeYuan.Tatala.socket.to; 4 | 5 | /** 6 | * This class is socket server target, provider socket distribution-method-call. 7 | * @author JimT 8 | * 9 | */ 10 | namespace QiLeYuan.Tatala.executor { 11 | 12 | public class SocketServerTarget : ServerTarget { 13 | 14 | public Object execute(TransferObject to) { 15 | Object resultObject = null; 16 | 17 | resultObject = SocketController.execute(to); 18 | 19 | return resultObject; 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /history/0.2.0/tatala-client-csharp/src/QiLeYuan/Tatala/proxy/DefaultProxy.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using QiLeYuan.Tatala.socket.to; 3 | using QiLeYuan.Tools.debug; 4 | 5 | namespace QiLeYuan.Tatala.proxy { 6 | public class DefaultProxy { 7 | public virtual Object execute(TransferObject to) { 8 | Logging.LogError("This is DefaultProxy. You need extend it by specific proxy."); 9 | return null; 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /history/0.2.0/tatala-client-csharp/src/QiLeYuan/Tatala/socket/client/Future.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using QiLeYuan.Tatala.socket.client; 3 | 4 | namespace QiLeYuan.Tatala.socket.client { 5 | public class Future { 6 | private SocketController.ExecuteDelegate executeDelegate; 7 | private IAsyncResult asyncResult; 8 | 9 | public Future(SocketController.ExecuteDelegate executeDelegate, IAsyncResult asyncResult) { 10 | this.executeDelegate = executeDelegate; 11 | this.asyncResult = asyncResult; 12 | } 13 | 14 | public Object Get() { 15 | return executeDelegate.EndInvoke(asyncResult); 16 | } 17 | 18 | public bool IsDone() { 19 | return asyncResult.IsCompleted; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /history/0.2.0/tatala-client-csharp/src/QiLeYuan/Tatala/socket/to/TransferObjectWrapper.cs: -------------------------------------------------------------------------------- 1 | using QiLeYuan.Tatala.socket.io; 2 | 3 | /** 4 | * This is customization object wrapper interface. 5 | * 6 | * @author JimT 7 | * 8 | */ 9 | namespace QiLeYuan.Tatala.socket.to { 10 | public interface TransferObjectWrapper { 11 | int getLength(); 12 | void getByteArray(TransferOutputStream touts); 13 | TransferObjectWrapper getObjectWrapper(TransferInputStream tins); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /history/0.2.0/tatala-client-csharp/src/QiLeYuan/Tatala/socket/to/helper/BooleanMapHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using QiLeYuan.Tatala.socket.io; 4 | using QiLeYuan.Tatala.socket.util; 5 | 6 | namespace QiLeYuan.Tatala.socket.to.helper { 7 | 8 | public class BooleanMapHelper { 9 | public static int getByteArrayLength(Dictionary booleanMap) { 10 | int blength = 0; 11 | foreach (KeyValuePair item in booleanMap) { 12 | // type 13 | blength += TransferUtil.getLengthOfByte(); 14 | // key 15 | String key = item.Key; 16 | blength += TransferUtil.getLengthOfString(key); 17 | // value 18 | blength += TransferUtil.getLengthOfBoolean(); 19 | } 20 | return blength; 21 | } 22 | 23 | public static void getByteArray(Dictionary booleanMap, TransferOutputStream touts) { 24 | 25 | foreach (KeyValuePair item in booleanMap) { 26 | // type 27 | touts.writeByte(TransferObject.DATATYPE_BOOLEAN); 28 | // key 29 | String key = item.Key; 30 | touts.writeString(key); 31 | // value 32 | bool value = item.Value; 33 | touts.writeBoolean(value); 34 | } 35 | } 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /history/0.2.0/tatala-client-csharp/src/QiLeYuan/Tatala/socket/to/helper/ByteMapHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using QiLeYuan.Tatala.socket.io; 4 | using QiLeYuan.Tatala.socket.util; 5 | 6 | namespace QiLeYuan.Tatala.socket.to.helper { 7 | 8 | public class ByteMapHelper { 9 | public static int getByteArrayLength(Dictionary byteMap) { 10 | int blength = 0; 11 | foreach (KeyValuePair item in byteMap) { 12 | // type 13 | blength += TransferUtil.getLengthOfByte(); 14 | // key 15 | String key = item.Key; 16 | blength += TransferUtil.getLengthOfString(key); 17 | // value 18 | blength += TransferUtil.getLengthOfByte(); 19 | } 20 | return blength; 21 | } 22 | 23 | public static void getByteArray(Dictionary byteMap, TransferOutputStream touts) { 24 | foreach (KeyValuePair item in byteMap) { 25 | // type 26 | touts.writeByte(TransferObject.DATATYPE_BYTE); 27 | // key 28 | String key = item.Key; 29 | touts.writeString(key); 30 | // value 31 | byte value = item.Value; 32 | touts.writeByte(value); 33 | } 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /history/0.2.0/tatala-client-csharp/src/QiLeYuan/Tatala/socket/to/helper/CharMapHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using QiLeYuan.Tatala.socket.io; 4 | using QiLeYuan.Tatala.socket.util; 5 | 6 | namespace QiLeYuan.Tatala.socket.to.helper { 7 | 8 | public class CharMapHelper { 9 | public static int getByteArrayLength(Dictionary charMap) { 10 | int blength = 0; 11 | foreach (KeyValuePair item in charMap) { 12 | // type 13 | blength += TransferUtil.getLengthOfByte(); 14 | // key 15 | String key = item.Key; 16 | blength += TransferUtil.getLengthOfString(key); 17 | // value 18 | blength += TransferUtil.getLengthOfChar(); 19 | } 20 | return blength; 21 | } 22 | 23 | public static void getByteArray(Dictionary charMap, TransferOutputStream touts) { 24 | foreach (KeyValuePair item in charMap) { 25 | // type 26 | touts.writeByte(TransferObject.DATATYPE_CHAR); 27 | // key 28 | String key = item.Key; 29 | touts.writeString(key); 30 | // value 31 | char value = item.Value; 32 | touts.writeChar(value); 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /history/0.2.0/tatala-client-csharp/src/QiLeYuan/Tatala/socket/to/helper/DateMapHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using QiLeYuan.Tatala.socket.io; 4 | using QiLeYuan.Tatala.socket.util; 5 | 6 | namespace QiLeYuan.Tatala.socket.to.helper { 7 | 8 | public class DateMapHelper { 9 | public static int getByteArrayLength(Dictionary dateMap) { 10 | int blength = 0; 11 | foreach (KeyValuePair item in dateMap) { 12 | // type 13 | blength += TransferUtil.getLengthOfByte(); 14 | // key 15 | String key = item.Key; 16 | blength += TransferUtil.getLengthOfString(key); 17 | // value 18 | blength += TransferUtil.getLengthOfDate(); 19 | } 20 | return blength; 21 | } 22 | 23 | public static void getByteArray(Dictionary dateMap, TransferOutputStream touts) { 24 | foreach (KeyValuePair item in dateMap) { 25 | // type 26 | touts.writeByte(TransferObject.DATATYPE_DATE); 27 | // key 28 | String key = item.Key; 29 | touts.writeString(key); 30 | // value 31 | DateTime value = item.Value; 32 | touts.writeDate(value); 33 | } 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /history/0.2.0/tatala-client-csharp/src/QiLeYuan/Tatala/socket/to/helper/DoubleMapHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using QiLeYuan.Tatala.socket.util; 4 | using QiLeYuan.Tatala.socket.io; 5 | 6 | namespace QiLeYuan.Tatala.socket.to.helper { 7 | 8 | public class DoubleMapHelper { 9 | public static int getByteArrayLength(Dictionary doubleMap) { 10 | int blength = 0; 11 | foreach (KeyValuePair item in doubleMap) { 12 | // type 13 | blength += TransferUtil.getLengthOfByte(); 14 | // key 15 | String key = item.Key; 16 | blength += TransferUtil.getLengthOfString(key); 17 | // value 18 | blength += TransferUtil.getLengthOfDouble(); 19 | } 20 | return blength; 21 | } 22 | 23 | public static void getByteArray(Dictionary doubleMap, TransferOutputStream touts) { 24 | foreach (KeyValuePair item in doubleMap) { 25 | // type 26 | touts.writeByte(TransferObject.DATATYPE_DOUBLE); 27 | // key 28 | String key = item.Key; 29 | touts.writeString(key); 30 | // value 31 | double value = item.Value; 32 | touts.writeDouble(value); 33 | } 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /history/0.2.0/tatala-client-csharp/src/QiLeYuan/Tatala/socket/to/helper/FloatMapHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using QiLeYuan.Tatala.socket.io; 4 | using QiLeYuan.Tatala.socket.util; 5 | 6 | namespace QiLeYuan.Tatala.socket.to.helper { 7 | 8 | public class FloatMapHelper { 9 | public static int getByteArrayLength(Dictionary floatMap) { 10 | int blength = 0; 11 | foreach (KeyValuePair item in floatMap) { 12 | // type 13 | blength += TransferUtil.getLengthOfByte(); 14 | // key 15 | String key = item.Key; 16 | blength += TransferUtil.getLengthOfString(key); 17 | // value 18 | blength += TransferUtil.getLengthOfFloat(); 19 | } 20 | return blength; 21 | } 22 | 23 | public static void getByteArray(Dictionary floatMap, TransferOutputStream touts) { 24 | foreach (KeyValuePair item in floatMap) { 25 | // type 26 | touts.writeByte(TransferObject.DATATYPE_FLOAT); 27 | // key 28 | String key = item.Key; 29 | touts.writeString(key); 30 | // value 31 | float value = item.Value; 32 | touts.writeFloat(value); 33 | } 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /history/0.2.0/tatala-client-csharp/src/QiLeYuan/Tatala/socket/to/helper/IntArrayMapHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using QiLeYuan.Tatala.socket.io; 4 | using QiLeYuan.Tatala.socket.util; 5 | 6 | namespace QiLeYuan.Tatala.socket.to.helper { 7 | 8 | public class IntArrayMapHelper { 9 | public static int getByteArrayLength(Dictionary intArrayMap) { 10 | int blength = 0; 11 | foreach (KeyValuePair item in intArrayMap) { 12 | // type 13 | blength += TransferUtil.getLengthOfByte(); 14 | // key 15 | String key = item.Key; 16 | blength += TransferUtil.getLengthOfString(key); 17 | // value 18 | int[] values = item.Value; 19 | blength += TransferUtil.getLengthOfIntArray(values); 20 | } 21 | return blength; 22 | } 23 | 24 | public static void getByteArray(Dictionary intArrayMap, TransferOutputStream touts) { 25 | foreach (KeyValuePair item in intArrayMap) { 26 | // type 27 | touts.writeByte(TransferObject.DATATYPE_INTARRAY); 28 | // key 29 | String key = item.Key; 30 | touts.writeString(key); 31 | // value 32 | int[] values = item.Value; 33 | touts.writeIntArray(values); 34 | } 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /history/0.2.0/tatala-client-csharp/src/QiLeYuan/Tatala/socket/to/helper/IntMapHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using QiLeYuan.Tatala.socket.io; 4 | using QiLeYuan.Tatala.socket.util; 5 | 6 | namespace QiLeYuan.Tatala.socket.to.helper { 7 | 8 | public class IntMapHelper { 9 | public static int getByteArrayLength(Dictionary intMap) { 10 | int blength = 0; 11 | foreach (KeyValuePair item in intMap) { 12 | // type 13 | blength += TransferUtil.getLengthOfByte(); 14 | // key 15 | String key = item.Key; 16 | blength += TransferUtil.getLengthOfString(key); 17 | // value 18 | blength += TransferUtil.getLengthOfInt(); 19 | } 20 | return blength; 21 | } 22 | 23 | public static void getByteArray(Dictionary intMap, TransferOutputStream touts) { 24 | foreach (KeyValuePair item in intMap) { 25 | // type 26 | touts.writeByte(TransferObject.DATATYPE_INT); 27 | // key 28 | String key = item.Key; 29 | touts.writeString(key); 30 | // value 31 | int value = item.Value; 32 | touts.writeInt(value); 33 | } 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /history/0.2.0/tatala-client-csharp/src/QiLeYuan/Tatala/socket/to/helper/LongMapHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using QiLeYuan.Tatala.socket.io; 4 | using QiLeYuan.Tatala.socket.util; 5 | 6 | namespace QiLeYuan.Tatala.socket.to.helper { 7 | 8 | public class LongMapHelper { 9 | public static int getByteArrayLength(Dictionary longMap) { 10 | int blength = 0; 11 | foreach (KeyValuePair item in longMap) { 12 | // type 13 | blength += TransferUtil.getLengthOfByte(); 14 | // key 15 | String key = item.Key; 16 | blength += TransferUtil.getLengthOfString(key); 17 | // value 18 | blength += TransferUtil.getLengthOfLong(); 19 | } 20 | return blength; 21 | } 22 | 23 | public static void getByteArray(Dictionary longMap, TransferOutputStream touts) { 24 | foreach (KeyValuePair item in longMap) { 25 | // type 26 | touts.writeByte(TransferObject.DATATYPE_LONG); 27 | // key 28 | String key = item.Key; 29 | touts.writeString(key); 30 | // value 31 | long value = item.Value; 32 | touts.writeLong(value); 33 | } 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /history/0.2.0/tatala-client-csharp/src/QiLeYuan/Tatala/socket/to/helper/ShortMapHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using QiLeYuan.Tatala.socket.io; 4 | using QiLeYuan.Tatala.socket.util; 5 | 6 | namespace QiLeYuan.Tatala.socket.to.helper { 7 | 8 | public class ShortMapHelper { 9 | public static int getByteArrayLength(Dictionary shortMap) { 10 | int blength = 0; 11 | foreach (KeyValuePair item in shortMap) { 12 | // type 13 | blength += TransferUtil.getLengthOfByte(); 14 | // key 15 | String key = item.Key; 16 | blength += TransferUtil.getLengthOfString(key); 17 | // value 18 | blength += TransferUtil.getLengthOfShort(); 19 | } 20 | return blength; 21 | } 22 | 23 | public static void getByteArray(Dictionary shortMap, TransferOutputStream touts) { 24 | foreach (KeyValuePair item in shortMap) { 25 | // type 26 | touts.writeByte(TransferObject.DATATYPE_SHORT); 27 | // key 28 | String key = item.Key; 29 | touts.writeString(key); 30 | // value 31 | short value = item.Value; 32 | touts.writeShort(value); 33 | } 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /history/0.2.0/tatala-client-csharp/src/QiLeYuan/Tatala/socket/to/helper/StringMapHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using QiLeYuan.Tatala.socket.io; 4 | using QiLeYuan.Tatala.socket.util; 5 | 6 | namespace QiLeYuan.Tatala.socket.to.helper { 7 | 8 | public class StringMapHelper { 9 | public static int getByteArrayLength(Dictionary stringMap) { 10 | int blength = 0; 11 | foreach (KeyValuePair item in stringMap) { 12 | // type 13 | blength += TransferUtil.getLengthOfByte(); 14 | // key 15 | String key = item.Key; 16 | blength += TransferUtil.getLengthOfString(key); 17 | // value 18 | String value = item.Value; 19 | blength += TransferUtil.getLengthOfString(value); 20 | } 21 | return blength; 22 | } 23 | 24 | public static void getByteArray(Dictionary stringMap, TransferOutputStream touts) { 25 | foreach (KeyValuePair item in stringMap) { 26 | // type 27 | touts.writeByte(TransferObject.DATATYPE_STRING); 28 | // key 29 | String key = item.Key; 30 | touts.writeString(key); 31 | // value 32 | String value = item.Value; 33 | touts.writeString(value); 34 | } 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /history/0.2.0/tatala-client-csharp/src/QiLeYuan/Tools/Xstream/Core/ConditionalConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Xstream.Core 4 | { 5 | public interface ConditionalConverter : IConverter 6 | { 7 | bool Match(Type type); 8 | } 9 | } -------------------------------------------------------------------------------- /history/0.2.0/tatala-client-csharp/src/QiLeYuan/Tools/Xstream/Core/ConversionException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Xstream.Core 5 | { 6 | /// 7 | /// Exception that occurs then (de)serialization of an object fails. 8 | /// 9 | [Serializable] 10 | public class ConversionException : Exception 11 | { 12 | internal ConversionException(SerializationInfo info, StreamingContext context) : base(info, context) {} 13 | internal ConversionException(string message) : base(message) {} 14 | internal ConversionException(string message, Exception innerException) : base(message, innerException) {} 15 | } 16 | } -------------------------------------------------------------------------------- /history/0.2.0/tatala-client-csharp/src/QiLeYuan/Tools/Xstream/Core/Converters/NoopConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Xml; 4 | 5 | namespace Xstream.Core.Converters 6 | { 7 | public class NoopConverter : IConverter 8 | { 9 | private static NoopConverter instance = new NoopConverter(); 10 | private NoopConverter() {} 11 | 12 | public static IConverter Instance 13 | { 14 | get { return instance; } 15 | } 16 | 17 | public void Register(IMarshalContext context) 18 | { 19 | } 20 | 21 | public void ToXml(object value, FieldInfo field, XmlTextWriter xml, IMarshalContext context) 22 | { 23 | } 24 | 25 | public object FromXml(object parent, FieldInfo field, Type type, XmlNode xml, IMarshalContext context) 26 | { 27 | throw new NotImplementedException(); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /history/0.2.0/tatala-client-csharp/src/QiLeYuan/Tools/Xstream/Core/Converters/NullConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Xml; 4 | 5 | namespace Xstream.Core.Converters 6 | { 7 | /// 8 | /// Special converter to convert null values. 9 | /// 10 | internal class NullConverter : IConverter 11 | { 12 | private static readonly Type __type = typeof( NullType ); 13 | 14 | /// 15 | /// Register is called by a MarshalContext to allow the 16 | /// converter instance to register itself in the context 17 | /// with all appropriate value types and interfaces. 18 | /// 19 | public void Register(IMarshalContext context) 20 | { 21 | context.RegisterConverter( __type, this ); 22 | context.Alias( "null", __type ); 23 | } 24 | 25 | /// 26 | /// Converts the object passed in to its XML representation. 27 | /// The XML string is written on the XmlTextWriter. 28 | /// 29 | public void ToXml(object value, FieldInfo field, XmlTextWriter xml, IMarshalContext context) 30 | { 31 | xml.WriteElementString( "null", string.Empty ); 32 | } 33 | 34 | /// 35 | /// Converts the XmlNode data passed in back to an actual 36 | /// .NET instance object. 37 | /// 38 | /// Object created from the XML. 39 | public object FromXml(object parent, FieldInfo field, Type type, XmlNode xml, IMarshalContext context) 40 | { 41 | return null; 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /history/0.2.0/tatala-client-csharp/src/QiLeYuan/Tools/Xstream/Core/Converters/PointerConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Xml; 4 | 5 | namespace Xstream.Core.Converters 6 | { 7 | /// 8 | /// Converts a pointer (System.Reflection.Pointer) to xml and back. 9 | /// 10 | /// 11 | /// Not implemented to convert pointer types. 12 | /// 13 | internal class PointerConverter : IConverter 14 | { 15 | private static readonly Type __type = typeof( Pointer ); 16 | 17 | /// 18 | /// Register is called by a MarshalContext to allow the 19 | /// converter instance to register itself in the context 20 | /// with all appropriate value types and interfaces. 21 | /// 22 | public void Register(IMarshalContext context) 23 | { 24 | context.RegisterConverter( __type, this ); 25 | } 26 | 27 | /// 28 | /// Converts the object passed in to its XML representation. 29 | /// The XML string is written on the XmlTextWriter. 30 | /// 31 | public void ToXml(object value, FieldInfo field, XmlTextWriter xml, IMarshalContext context) 32 | { 33 | } 34 | 35 | /// 36 | /// Converts the XmlNode data passed in, back to an actual 37 | /// .NET instance object. 38 | /// 39 | /// Object created from the XML. 40 | public object FromXml(object parent, FieldInfo field, Type type, XmlNode xml, IMarshalContext context) 41 | { 42 | return null; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /history/0.2.0/tatala-client-csharp/src/QiLeYuan/Tools/Xstream/Core/Converters/TargetForceLoader.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | namespace Xstream.Core.Converters 4 | { 5 | internal class TargetForceLoader 6 | { 7 | public static object GetTargetValue(object value) 8 | { 9 | if (value == null) return value; 10 | ForceLoadTheEntityBecauseItIsLazy(value); 11 | 12 | FieldInfo interceptorField = value.GetType().GetField("__interceptor"); 13 | if (interceptorField == null) return value; 14 | 15 | object interceptorValue = interceptorField.GetValue(value); 16 | FieldInfo targetField = interceptorValue.GetType().BaseType.GetField("_target", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); 17 | return targetField.GetValue(interceptorValue); 18 | } 19 | 20 | private static void ForceLoadTheEntityBecauseItIsLazy(object value) 21 | { 22 | try 23 | { 24 | value.GetType().GetMethod("get_Version", BindingFlags.Public | BindingFlags.Instance).Invoke(value, new object[] {}); 25 | } 26 | catch (TargetInvocationException e) 27 | { 28 | throw e.InnerException.InnerException; 29 | } 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /history/0.2.0/tatala-client-csharp/src/QiLeYuan/Tools/Xstream/Core/FileXStream.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | 4 | namespace Xstream.Core 5 | { 6 | public class FileXStream : IXStream 7 | { 8 | // Fields 9 | private readonly string fileName; 10 | private readonly XStream xStream; 11 | 12 | // Methods 13 | public FileXStream(string fileName) 14 | { 15 | this.fileName = fileName; 16 | xStream = new XStream(); 17 | } 18 | 19 | public void AddConverter(IConverter converter) 20 | { 21 | xStream.AddConverter(converter); 22 | } 23 | 24 | public void AddIgnoreAttribute(Type ignoredAttributeType) 25 | { 26 | xStream.AddIgnoreAttribute(ignoredAttributeType); 27 | } 28 | 29 | public object FromFile() 30 | { 31 | return xStream.FromXml(File.ReadAllText(fileName)); 32 | } 33 | 34 | public object FromXml(string xml) 35 | { 36 | return xStream.FromXml(xml); 37 | } 38 | 39 | public string ToXml(object value) 40 | { 41 | string xml = xStream.ToXml(value); 42 | File.WriteAllText(fileName, xml); 43 | return xml; 44 | } 45 | 46 | public XStream XStream 47 | { 48 | get { return xStream; } 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /history/0.2.0/tatala-client-csharp/src/QiLeYuan/Tools/Xstream/Core/IConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Xml; 4 | 5 | namespace Xstream.Core 6 | { 7 | /// 8 | /// IConverter is the interface that all type converter instances 9 | /// should implement to get used with a MarshalContext. 10 | /// 11 | public interface IConverter 12 | { 13 | /// 14 | /// Register is called by a MarshalContext to allow the 15 | /// converter instance to register itself in the context 16 | /// with all appropriate value types and interfaces. 17 | /// 18 | void Register(IMarshalContext context); 19 | 20 | /// 21 | /// Converts the object passed in to its XML representation. 22 | /// The XML string is written on the XmlTextWriter. 23 | /// 24 | void ToXml(object value, FieldInfo field, XmlTextWriter xml, IMarshalContext context); 25 | 26 | /// 27 | /// Converts the XmlNode data passed in back to an actual 28 | /// .NET instance object. 29 | /// 30 | /// Object created from the XML. 31 | object FromXml(object parent, FieldInfo field, Type type, XmlNode xml, IMarshalContext context); 32 | } 33 | 34 | public interface AssignableConverter : IConverter 35 | { 36 | Type ConverteeType { get; } 37 | } 38 | } -------------------------------------------------------------------------------- /history/0.2.0/tatala-client-csharp/src/QiLeYuan/Tools/Xstream/Core/IMarshalContext.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Xml; 4 | 5 | namespace Xstream.Core 6 | { 7 | public interface IMarshalContext 8 | { 9 | bool ContainsType(object o); 10 | object GetOfType(object matchingObj); 11 | void WriteStartTag(Type type, FieldInfo field, XmlTextWriter textWriter); 12 | int GetStackIndex(object value); 13 | void Stack(object value, Type type); 14 | void WriteEndTag(Type type, FieldInfo field, XmlTextWriter xml); 15 | object GetStackObject(int stackIx); 16 | void Stack(object value, Type type, XmlNode xmlNode); 17 | IConverter GetConverter(XmlNode child, ref Type type); 18 | void RegisterConverter(Type type, IConverter converter); 19 | Type IgnoredAttributeType { get; } 20 | bool CaseSensitive { get; set; } 21 | IConverter GetConverter(Type type); 22 | void ClearStack(); 23 | void Alias(string s, Type type); 24 | void Stack(object o); 25 | void AddIgnoreAttribute(Type type); 26 | string GetTypeName(Type type); 27 | void AddConverter(IConverter converter); 28 | bool IsCData(Type type, string fieldName); 29 | IConverter GetCDataConverter(); 30 | void AddCdata(Type type, string name); 31 | } 32 | } -------------------------------------------------------------------------------- /history/0.2.0/tatala-client-csharp/src/QiLeYuan/Tools/Xstream/Core/IXStream.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Xstream.Core 4 | { 5 | public interface IXStream 6 | { 7 | void AddConverter(IConverter converter); 8 | void AddIgnoreAttribute(Type ignoredAttributeType); 9 | object FromXml(string xml); 10 | string ToXml(object value); 11 | } 12 | } -------------------------------------------------------------------------------- /history/0.2.0/tatala-client-csharp/src/QiLeYuan/Tools/Xstream/Core/NullType.cs: -------------------------------------------------------------------------------- 1 | namespace Xstream.Core 2 | { 3 | /// 4 | /// Dummy class, representing null value. 5 | /// 6 | internal class NullType {} 7 | } -------------------------------------------------------------------------------- /history/0.2.0/tatala-client-csharp/src/QiLeYuan/Tools/Xstream/Core/ReferenceComparer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | 3 | namespace Xstream.Core 4 | { 5 | internal class ReferenceComparer : IEqualityComparer 6 | { 7 | bool IEqualityComparer.Equals(object x, object y) 8 | { 9 | return ReferenceEquals(x, y); 10 | } 11 | 12 | int IEqualityComparer.GetHashCode(object obj) 13 | { 14 | return obj.GetHashCode(); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /history/0.2.0/tatala-java-example/build.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 | -------------------------------------------------------------------------------- /history/0.2.0/tatala-java-example/chatroom.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | set classpath=. 3 | set classpath=%classpath%;lib\* 4 | set classpath=%classpath%;dist\tatala-java-example.jar 5 | set classpath=%classpath%;cfg 6 | 7 | java com.qileyuan.tatala.example.client.ChatRoomClient -------------------------------------------------------------------------------- /history/0.2.0/tatala-java-example/chatroomserver.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | set classpath=. 3 | set classpath=%classpath%;lib\* 4 | set classpath=%classpath%;dist\tatala-java-example.jar 5 | set classpath=%classpath%;cfg 6 | 7 | java com.qileyuan.tatala.example.server.ChatRoomServer 10002 8 | -------------------------------------------------------------------------------- /history/0.2.0/tatala-java-example/client.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | set classpath=. 3 | set classpath=%classpath%;lib\* 4 | set classpath=%classpath%;dist\tatala-java-example.jar 5 | set classpath=%classpath%;cfg 6 | 7 | java com.qileyuan.tatala.example.client.ExampleClient -------------------------------------------------------------------------------- /history/0.2.0/tatala-java-example/dist/tatala-java-example.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zijan/Tatala-RPC/b975e54a314b38d41f3f85fe93c2346972966cee/history/0.2.0/tatala-java-example/dist/tatala-java-example.jar -------------------------------------------------------------------------------- /history/0.2.0/tatala-java-example/easyclient.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | set classpath=. 3 | set classpath=%classpath%;lib\* 4 | set classpath=%classpath%;dist\tatala-java-example.jar 5 | set classpath=%classpath%;cfg 6 | 7 | java com.qileyuan.tatala.example.client.EasyClient -------------------------------------------------------------------------------- /history/0.2.0/tatala-java-example/lib/log4j-1.2.13.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zijan/Tatala-RPC/b975e54a314b38d41f3f85fe93c2346972966cee/history/0.2.0/tatala-java-example/lib/log4j-1.2.13.jar -------------------------------------------------------------------------------- /history/0.2.0/tatala-java-example/lib/protobuf-java-2.6.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zijan/Tatala-RPC/b975e54a314b38d41f3f85fe93c2346972966cee/history/0.2.0/tatala-java-example/lib/protobuf-java-2.6.1.jar -------------------------------------------------------------------------------- /history/0.2.0/tatala-java-example/lib/tatala.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zijan/Tatala-RPC/b975e54a314b38d41f3f85fe93c2346972966cee/history/0.2.0/tatala-java-example/lib/tatala.jar -------------------------------------------------------------------------------- /history/0.2.0/tatala-java-example/server.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | set classpath=. 3 | set classpath=%classpath%;lib\* 4 | set classpath=%classpath%;dist\tatala-java-example.jar 5 | set classpath=%classpath%;cfg 6 | 7 | java com.qileyuan.tatala.example.server.ExampleServer 8 | -------------------------------------------------------------------------------- /history/0.2.0/tatala-java-example/src/com/qileyuan/tatala/example/client/ChatRoomClient.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zijan/Tatala-RPC/b975e54a314b38d41f3f85fe93c2346972966cee/history/0.2.0/tatala-java-example/src/com/qileyuan/tatala/example/client/ChatRoomClient.java -------------------------------------------------------------------------------- /history/0.2.0/tatala-java-example/src/com/qileyuan/tatala/example/proxy/ChatRoomClientDefaultProxy.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.example.proxy; 2 | 3 | import com.qileyuan.tatala.example.client.ChatRoomClient; 4 | import com.qileyuan.tatala.proxy.DefaultProxy; 5 | import com.qileyuan.tatala.socket.to.TransferObject; 6 | 7 | public class ChatRoomClientDefaultProxy extends DefaultProxy { 8 | 9 | public Object execute(TransferObject to){ 10 | String calleeMethod = to.getCalleeMethod(); 11 | if(calleeMethod.equals("receiveMessage")){ 12 | String message = to.getString(); 13 | ChatRoomClient.getInstance().receiveMessage(message); 14 | } 15 | return null; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /history/0.2.0/tatala-java-example/src/com/qileyuan/tatala/example/proxy/ChatRoomServerProxy.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.example.proxy; 2 | 3 | import com.qileyuan.tatala.example.service.ChatRoomServerLogic; 4 | import com.qileyuan.tatala.socket.server.ServerSession; 5 | import com.qileyuan.tatala.socket.to.OrderedTransferObject; 6 | import com.qileyuan.tatala.socket.to.TransferObject; 7 | 8 | public class ChatRoomServerProxy { 9 | 10 | private ChatRoomServerLogic serverLogic = ChatRoomServerLogic.getInstance(); 11 | 12 | public void login(TransferObject to){ 13 | String username = to.getString(); 14 | serverLogic.login(to.getClientId(), username); 15 | } 16 | 17 | public void receiveMessage(TransferObject to){ 18 | String message = to.getString(); 19 | serverLogic.broadcast(to.getClientId(), message); 20 | } 21 | 22 | public static void sendMessage(ServerSession session, String sendMessage){ 23 | TransferObject to = new OrderedTransferObject(); 24 | to.setServerCall(true); 25 | //comment out for call client default proxy 26 | //to.setCalleeClass("com.qileyuan.tatala.example.proxy.ChatRoomClientProxy"); 27 | to.setDefaultCallee(true); 28 | to.setCalleeMethod("receiveMessage"); 29 | to.putString(sendMessage); 30 | session.executeServerCall(to); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /history/0.2.0/tatala-java-example/src/com/qileyuan/tatala/example/server/ChatRoomServer.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.example.server; 2 | 3 | import org.apache.log4j.Logger; 4 | 5 | import com.qileyuan.tatala.example.service.ChatRoomServerLogic; 6 | import com.qileyuan.tatala.socket.server.AioSocketServer; 7 | 8 | public class ChatRoomServer { 9 | static Logger log = Logger.getLogger(ChatRoomServer.class); 10 | 11 | public static void initialize(){ 12 | log.info("Chat Room Server initialize..."); 13 | } 14 | 15 | public static void startup(int listenPort, int poolSize){ 16 | log.info("Chat Room Server starting..."); 17 | 18 | AioSocketServer server = new AioSocketServer(listenPort, poolSize); 19 | server.start(); 20 | 21 | ChatRoomServerLogic serverLogic = ChatRoomServerLogic.getInstance(); 22 | //chat room server logic need session map from AioSocketServer 23 | serverLogic.setSessionMap(AioSocketServer.getSessionMap()); 24 | } 25 | 26 | public static void main(String args[]) { 27 | log.info("*** Chat Room Server ***"); 28 | int listenPort = 10002; 29 | int poolSize = 16; 30 | if(args != null && args.length > 1){ 31 | listenPort = Integer.parseInt(args[0]); 32 | poolSize = Integer.parseInt(args[1]); 33 | } 34 | initialize(); 35 | startup(listenPort, poolSize); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /history/0.2.0/tatala-java-example/src/com/qileyuan/tatala/example/server/ExampleServer.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.example.server; 2 | 3 | import org.apache.log4j.Logger; 4 | 5 | import com.qileyuan.tatala.example.proxy.ExampleDefaultProxy; 6 | import com.qileyuan.tatala.proxy.DefaultProxy; 7 | import com.qileyuan.tatala.socket.server.AioSocketServer; 8 | 9 | public class ExampleServer { 10 | static Logger log = Logger.getLogger(ExampleServer.class); 11 | 12 | public static void initialize(){ 13 | log.info("Example Tatala Server initialize..."); 14 | } 15 | 16 | public static void startup(int listenPort, int poolSize){ 17 | log.info("Example Tatala Server starting..."); 18 | 19 | AioSocketServer server = new AioSocketServer(listenPort, poolSize); 20 | 21 | try { 22 | //set default proxy or callee class here 23 | DefaultProxy defaultProxy = new ExampleDefaultProxy(); 24 | server.registerProxy(defaultProxy); 25 | server.start(); 26 | } catch (Exception e) { 27 | e.printStackTrace(); 28 | } 29 | } 30 | 31 | public static void main(String args[]) { 32 | log.info("*** Example Tatala Server ***"); 33 | int listenPort = 10001; 34 | int poolSize = 16; 35 | if(args != null && args.length > 1){ 36 | listenPort = Integer.parseInt(args[0]); 37 | poolSize = Integer.parseInt(args[1]); 38 | } 39 | 40 | initialize(); 41 | startup(listenPort, poolSize); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /history/0.2.0/tatala-java-example/src/com/qileyuan/tatala/example/service/ExampleManager.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.example.service; 2 | 3 | import java.util.Date; 4 | import java.util.List; 5 | import java.util.Map; 6 | import java.util.Set; 7 | 8 | import com.qileyuan.tatala.example.service.model.Account; 9 | import com.qileyuan.tatala.example.service.model.AllTypeBean; 10 | 11 | 12 | /** 13 | * This interface is a sample for the socket server provider. 14 | * @author JimT 15 | * 16 | */ 17 | public interface ExampleManager { 18 | public String sayHello(int Id, String name); 19 | public void doSomething(); 20 | public void exceptionCall(int Id); 21 | public Account getAccount(Account account); 22 | public List getAccountList(List accountList); 23 | public Map getAccountMap(Map accountMap); 24 | public Set getAccountSet(Set accountSet); 25 | public AllTypeBean getAllTypeBean(boolean aboolean, byte abyte, short ashort, char achar, int aint, long along, 26 | float afloat, double adouble, Date adate, String astring); 27 | public String[] getArray(byte[] bytearr, String[] strarr); 28 | } 29 | -------------------------------------------------------------------------------- /history/0.2.0/tatala-java-example/src/com/qileyuan/tatala/example/service/ExampleReturnException.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.example.service; 2 | 3 | import com.qileyuan.tatala.socket.exception.TatalaRollbackException; 4 | 5 | 6 | public class ExampleReturnException extends TatalaRollbackException{ 7 | private static final long serialVersionUID = 1L; 8 | 9 | public ExampleReturnException() { 10 | super(); 11 | } 12 | 13 | public ExampleReturnException(String msg) { 14 | super(msg); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /history/0.2.0/tatala-java-example/src/com/qileyuan/tatala/example/service/model/Account.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.example.service.model; 2 | 3 | import java.io.Serializable; 4 | 5 | public class Account implements Serializable{ 6 | private static final long serialVersionUID = 1L; 7 | private int id; 8 | private String name; 9 | private String address; 10 | 11 | public int getId() { 12 | return id; 13 | } 14 | public void setId(int id) { 15 | this.id = id; 16 | } 17 | public String getName() { 18 | return name; 19 | } 20 | public void setName(String name) { 21 | this.name = name; 22 | } 23 | public String getAddress() { 24 | return address; 25 | } 26 | public void setAddress(String address) { 27 | this.address = address; 28 | } 29 | 30 | public String toString(){ 31 | return "[id: "+id+"][name: "+name+"][address: "+address+"]"; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /history/0.2.0/tatala-java-example/src/com/qileyuan/tatala/example/service/model/proto/account.proto: -------------------------------------------------------------------------------- 1 | option java_package = "com.qileyuan.tatala.example.service.model.proto"; 2 | option java_outer_classname = "AccountProto"; 3 | 4 | message Account { 5 | required int32 id = 1; 6 | required string name = 2; 7 | optional string address = 3; 8 | } -------------------------------------------------------------------------------- /history/0.2.0/tatala-java/build.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 | -------------------------------------------------------------------------------- /history/0.2.0/tatala-java/dist/tatala.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zijan/Tatala-RPC/b975e54a314b38d41f3f85fe93c2346972966cee/history/0.2.0/tatala-java/dist/tatala.jar -------------------------------------------------------------------------------- /history/0.2.0/tatala-java/lib/log4j-1.2.13.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zijan/Tatala-RPC/b975e54a314b38d41f3f85fe93c2346972966cee/history/0.2.0/tatala-java/lib/log4j-1.2.13.jar -------------------------------------------------------------------------------- /history/0.2.0/tatala-java/src/com/qileyuan/tatala/executor/ServerExecutor.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.executor; 2 | 3 | import com.qileyuan.tatala.socket.client.SocketController; 4 | import com.qileyuan.tatala.socket.to.TransferObject; 5 | 6 | /** 7 | * This class is the distribution-method-call executor, which dispatches request to socket controller. 8 | * 9 | * @author Jim Tang 10 | * 11 | */ 12 | public class ServerExecutor{ 13 | public static Object execute(TransferObject to){ 14 | return SocketController.execute(to); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /history/0.2.0/tatala-java/src/com/qileyuan/tatala/proxy/ClientProxyFactory.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.proxy; 2 | 3 | import java.lang.reflect.Proxy; 4 | 5 | import com.qileyuan.tatala.socket.to.TransferObjectFactory; 6 | 7 | public class ClientProxyFactory { 8 | public static Object create(Class clazz, TransferObjectFactory transferObjectFactory) { 9 | return Proxy.newProxyInstance( 10 | ClientProxyFactory.class.getClassLoader(), 11 | new Class[] { clazz }, 12 | new ClientProxy(transferObjectFactory)); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /history/0.2.0/tatala-java/src/com/qileyuan/tatala/proxy/DefaultProxy.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.proxy; 2 | 3 | import org.apache.log4j.Logger; 4 | 5 | import com.qileyuan.tatala.socket.to.TransferObject; 6 | 7 | public class DefaultProxy { 8 | Logger log = Logger.getLogger(DefaultProxy.class); 9 | public Object execute(TransferObject to){ 10 | log.error("This is DefaultProxy. You need extend it by specific proxy or callee class."); 11 | return null; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /history/0.2.0/tatala-java/src/com/qileyuan/tatala/socket/client/AioClientReceiveHandler.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.socket.client; 2 | 3 | import java.nio.ByteBuffer; 4 | import java.nio.channels.CompletionHandler; 5 | 6 | import org.apache.log4j.Logger; 7 | 8 | public class AioClientReceiveHandler implements CompletionHandler { 9 | Logger log = Logger.getLogger(AioClientReceiveHandler.class); 10 | 11 | @Override 12 | public void completed(Integer receivedCount, LongClientSession session) { 13 | 14 | //server close socket channel or network issue 15 | if(receivedCount < 0){ 16 | session.close(); 17 | return; 18 | } 19 | try { 20 | ByteBuffer byteBuffer = session.getByteBuffer(); 21 | if(receivedCount > 0){ 22 | byteBuffer.flip(); 23 | byte[] receiveData = new byte[byteBuffer.limit()]; 24 | byteBuffer.get(receiveData); 25 | session.write(receiveData); 26 | byteBuffer.compact(); 27 | 28 | //chech whether one receive from server is done 29 | session.checkOneReceiveDone(receivedCount, receiveData); 30 | } 31 | } finally { 32 | session.receive(); 33 | } 34 | } 35 | 36 | @Override 37 | public void failed(Throwable exc, LongClientSession session) { 38 | log.error("Receive error: " + exc.getMessage(), exc); 39 | session.close(); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /history/0.2.0/tatala-java/src/com/qileyuan/tatala/socket/exception/SocketExecuteException.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.socket.exception; 2 | 3 | public class SocketExecuteException extends Exception { 4 | 5 | private static final long serialVersionUID = 1L; 6 | 7 | public SocketExecuteException() { 8 | super(); 9 | } 10 | 11 | public SocketExecuteException(String msg) { 12 | super(msg); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /history/0.2.0/tatala-java/src/com/qileyuan/tatala/socket/exception/TatalaRollbackException.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.socket.exception; 2 | 3 | public class TatalaRollbackException extends RuntimeException{ 4 | 5 | private static final long serialVersionUID = 1L; 6 | 7 | public TatalaRollbackException() { 8 | super(); 9 | } 10 | 11 | public TatalaRollbackException(String msg) { 12 | super(msg); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /history/0.2.0/tatala-java/src/com/qileyuan/tatala/socket/server/AioReceiveHandler.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.socket.server; 2 | 3 | import java.io.IOException; 4 | import java.nio.ByteBuffer; 5 | import java.nio.channels.CompletionHandler; 6 | 7 | import org.apache.log4j.Logger; 8 | 9 | public class AioReceiveHandler implements CompletionHandler{ 10 | Logger log = Logger.getLogger(AioReceiveHandler.class); 11 | 12 | @Override 13 | public void completed(Integer receivedCount, ServerSession session) { 14 | if(receivedCount < 0){ 15 | session.close(); 16 | return; 17 | } 18 | try { 19 | ByteBuffer byteBuffer = session.getByteBuffer(); 20 | 21 | if (receivedCount > 0) { 22 | byteBuffer.flip(); 23 | byte[] receiveData = new byte[byteBuffer.limit()]; 24 | byteBuffer.get(receiveData); 25 | session.write(receiveData); 26 | byteBuffer.compact(); 27 | 28 | //chech whether one client request is done 29 | session.checkOneReceiveDone(receivedCount, receiveData); 30 | } 31 | } finally { 32 | session.receive(); 33 | } 34 | } 35 | 36 | @Override 37 | public void failed(Throwable exc, ServerSession session) { 38 | //if client close connection, don't log error 39 | if(!IOException.class.isAssignableFrom(exc.getClass())){ 40 | log.error("Receive error: " + exc.getMessage()); 41 | } 42 | session.close(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /history/0.2.0/tatala-java/src/com/qileyuan/tatala/socket/server/AioSocketHandler.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.socket.server; 2 | 3 | import java.nio.channels.AsynchronousSocketChannel; 4 | import java.nio.channels.CompletionHandler; 5 | 6 | import org.apache.log4j.Logger; 7 | 8 | public class AioSocketHandler implements CompletionHandler { 9 | Logger log = Logger.getLogger(AioSocketHandler.class); 10 | 11 | private ServerSession session; 12 | 13 | public AioSocketHandler(ServerSession session){ 14 | this.session = session; 15 | } 16 | 17 | @Override 18 | public void completed(AsynchronousSocketChannel socketChannel, AioSocketServer aioSocketServer) { 19 | try { 20 | session.setSocketChannel(socketChannel); 21 | session.start(); 22 | } finally{ 23 | aioSocketServer.acceptConnections(); 24 | } 25 | } 26 | 27 | @Override 28 | public void failed(Throwable exc, AioSocketServer aioSocketServer) { 29 | log.error("Accept error", exc); 30 | aioSocketServer.acceptConnections(); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /history/0.2.0/tatala-java/src/com/qileyuan/tatala/socket/server/SessionFilter.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.socket.server; 2 | 3 | public interface SessionFilter { 4 | public void onClose(ServerSession session); 5 | //if return true, ignore execute code 6 | public boolean onReceive(ServerSession session, byte[] receiveData); 7 | } 8 | -------------------------------------------------------------------------------- /history/0.2.0/tatala-java/src/com/qileyuan/tatala/socket/to/TransferObjectWrapper.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.socket.to; 2 | 3 | import com.qileyuan.tatala.socket.io.TransferInputStream; 4 | import com.qileyuan.tatala.socket.io.TransferOutputStream; 5 | 6 | /** 7 | * This is customization object wrapper interface. 8 | * 9 | * @author JimT 10 | * 11 | */ 12 | public interface TransferObjectWrapper { 13 | public int getLength(); 14 | public void getByteArray(TransferOutputStream touts); 15 | public TransferObjectWrapper getObjectWrapper(TransferInputStream tins); 16 | } 17 | -------------------------------------------------------------------------------- /history/0.2.0/tatala-java/src/com/qileyuan/tatala/socket/util/NetworkUtil.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.socket.util; 2 | 3 | import java.io.IOException; 4 | import java.net.InetSocketAddress; 5 | import java.nio.channels.AsynchronousSocketChannel; 6 | 7 | public class NetworkUtil { 8 | public static long convertIpPortToUniqueId(byte[] quad, int port) { 9 | return (((long)port) << 32 10 | | ((long)(quad[0] & 0xFF)) << 24 11 | | ((long)(quad[1] & 0xFF)) << 16 12 | | ((long)(quad[2] & 0xFF)) << 8 13 | | ((long)(quad[3] & 0xFF))); 14 | } 15 | 16 | public static long getClientIdBySocketChannel(AsynchronousSocketChannel socketChannel) throws IOException{ 17 | InetSocketAddress address = (InetSocketAddress)socketChannel.getRemoteAddress(); 18 | byte[] quad = address.getAddress().getAddress(); 19 | int port = address.getPort(); 20 | long clientId = NetworkUtil.convertIpPortToUniqueId(quad, port); 21 | return clientId; 22 | } 23 | 24 | public static String getIpPortByClientId(long clientId){ 25 | long port = clientId >> 32; 26 | long ip1 = (clientId >> 24) - (port << 8); 27 | long ip2 = (clientId >> 16) - (ip1 << 8) - (port << 16); 28 | long ip3 = (clientId >> 8) - (ip2 << 8) - (ip1 << 16) - (port << 24); 29 | long ip4 = clientId - (ip3 << 8) - (ip2 << 16) - (ip1 << 24) - (port << 32); 30 | return ip1+"."+ip2+"."+ip3+"."+ip4+":"+port; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /tatala-client-csharp/cfg/controller.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 127.0.0.1 4 | 10001 5 | 5000 6 | 3 7 | test1 8 | 9 | 10 | 127.0.0.1 11 | 10002 12 | 5000 13 | 3 14 | test2 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /tatala-client-csharp/src/Example/Tatala/model/TestAccount.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | /** 4 | * This class is a customization object. 5 | * @author JimT 6 | * 7 | */ 8 | namespace Example.tatala.model { 9 | 10 | public class TestAccount { 11 | 12 | private int id; 13 | private String name; 14 | private String address; 15 | 16 | public int getId() { 17 | return id; 18 | } 19 | public void setId(int id) { 20 | this.id = id; 21 | } 22 | public String getName() { 23 | return name; 24 | } 25 | public void setName(String name) { 26 | this.name = name; 27 | } 28 | public String getAddress() { 29 | return address; 30 | } 31 | public void setAddress(String address) { 32 | this.address = address; 33 | } 34 | 35 | public override String ToString() { 36 | return "[id: " + id + "][name: " + name + "][address: " + address + "]"; 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /tatala-client-csharp/src/Example/Tatala/proxy/ChatRoomClientDefaultProxy.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Example.tatala.client; 3 | using QiLeYuan.Tatala.proxy; 4 | using QiLeYuan.Tatala.socket.to; 5 | 6 | namespace Example.tatala.proxy { 7 | public class ChatRoomClientDefaultProxy : DefaultProxy { 8 | 9 | public override Object execute(TransferObject baseto) { 10 | StandardTransferObject to = (StandardTransferObject)baseto; 11 | String calleeMethod = to.getCalleeMethod(); 12 | if (calleeMethod.Equals("receiveMessage")) { 13 | String message = to.getString("message"); 14 | ChatRoomClient.getInstance().receiveMessage(message); 15 | } 16 | 17 | return null; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /tatala-client-csharp/src/QiLeYuan/Tatala/executor/LocalTarget.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using QiLeYuan.Tatala.socket.to; 4 | using QiLeYuan.Tools.debug; 5 | 6 | /** 7 | * This class is local target, simply provider local-method-call. 8 | * 9 | * @author JimT 10 | * 11 | */ 12 | namespace QiLeYuan.Tatala.executor { 13 | 14 | public class LocalTarget : ServerTarget { 15 | public Object execute(TransferObject to) { 16 | 17 | String calleeClass = to.getCalleeClass(); 18 | String calleeMethod = to.getCalleeMethod(); 19 | 20 | Object retobj = null; 21 | try { 22 | Type type = Type.GetType(calleeClass); 23 | Object instance = Activator.CreateInstance(type); 24 | MethodInfo method = type.GetMethod(calleeMethod); 25 | retobj = method.Invoke(instance, new object[] { to }); 26 | } catch (Exception e) { 27 | Logging.LogError(e.ToString()); 28 | } 29 | 30 | return retobj; 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /tatala-client-csharp/src/QiLeYuan/Tatala/executor/ServerExecutor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using QiLeYuan.Tatala.util; 3 | using QiLeYuan.Tatala.socket.to; 4 | 5 | /** 6 | * This class is the distribution-method-call executor, which dispatches request to different target. 7 | * For now, it only supports local and socket distribution. 8 | * 9 | * @author JimT 10 | * 11 | */ 12 | namespace QiLeYuan.Tatala.executor { 13 | 14 | public class ServerExecutor { 15 | private static ServerTarget target; 16 | public static Object execute(TransferObject to) { 17 | Object retObj = null; 18 | //for csharp client, server target is Socket. 19 | target = new SocketServerTarget(); 20 | retObj = target.execute(to); 21 | return retObj; 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /tatala-client-csharp/src/QiLeYuan/Tatala/executor/ServerTarget.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using QiLeYuan.Tatala.socket.to; 3 | 4 | namespace QiLeYuan.Tatala.executor { 5 | 6 | public interface ServerTarget { 7 | Object execute(TransferObject to); 8 | } 9 | } -------------------------------------------------------------------------------- /tatala-client-csharp/src/QiLeYuan/Tatala/executor/SocketServerTarget.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using QiLeYuan.Tatala.socket.client; 3 | using QiLeYuan.Tatala.socket.to; 4 | 5 | /** 6 | * This class is socket server target, provider socket distribution-method-call. 7 | * @author JimT 8 | * 9 | */ 10 | namespace QiLeYuan.Tatala.executor { 11 | 12 | public class SocketServerTarget : ServerTarget { 13 | 14 | public Object execute(TransferObject to) { 15 | Object resultObject = null; 16 | 17 | resultObject = SocketController.execute(to); 18 | 19 | return resultObject; 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /tatala-client-csharp/src/QiLeYuan/Tatala/proxy/DefaultProxy.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using QiLeYuan.Tatala.socket.to; 3 | using QiLeYuan.Tools.debug; 4 | 5 | namespace QiLeYuan.Tatala.proxy { 6 | public class DefaultProxy { 7 | public virtual Object execute(TransferObject to) { 8 | Logging.LogError("This is DefaultProxy. You need extend it by specific proxy."); 9 | return null; 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /tatala-client-csharp/src/QiLeYuan/Tatala/socket/client/Future.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using QiLeYuan.Tatala.socket.client; 3 | 4 | namespace QiLeYuan.Tatala.socket.client { 5 | public class Future { 6 | private SocketController.ExecuteDelegate executeDelegate; 7 | private IAsyncResult asyncResult; 8 | 9 | public Future(SocketController.ExecuteDelegate executeDelegate, IAsyncResult asyncResult) { 10 | this.executeDelegate = executeDelegate; 11 | this.asyncResult = asyncResult; 12 | } 13 | 14 | public Object Get() { 15 | return executeDelegate.EndInvoke(asyncResult); 16 | } 17 | 18 | public bool IsDone() { 19 | return asyncResult.IsCompleted; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tatala-client-csharp/src/QiLeYuan/Tatala/socket/to/TransferObjectWrapper.cs: -------------------------------------------------------------------------------- 1 | using QiLeYuan.Tatala.socket.io; 2 | 3 | /** 4 | * This is customization object wrapper interface. 5 | * 6 | * @author JimT 7 | * 8 | */ 9 | namespace QiLeYuan.Tatala.socket.to { 10 | public interface TransferObjectWrapper { 11 | int getLength(); 12 | void getByteArray(TransferOutputStream touts); 13 | TransferObjectWrapper getObjectWrapper(TransferInputStream tins); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tatala-client-csharp/src/QiLeYuan/Tatala/socket/to/helper/BooleanMapHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using QiLeYuan.Tatala.socket.io; 4 | using QiLeYuan.Tatala.socket.util; 5 | 6 | namespace QiLeYuan.Tatala.socket.to.helper { 7 | 8 | public class BooleanMapHelper { 9 | public static int getByteArrayLength(Dictionary booleanMap) { 10 | int blength = 0; 11 | foreach (KeyValuePair item in booleanMap) { 12 | // type 13 | blength += TransferUtil.getLengthOfByte(); 14 | // key 15 | String key = item.Key; 16 | blength += TransferUtil.getLengthOfString(key); 17 | // value 18 | blength += TransferUtil.getLengthOfBoolean(); 19 | } 20 | return blength; 21 | } 22 | 23 | public static void getByteArray(Dictionary booleanMap, TransferOutputStream touts) { 24 | 25 | foreach (KeyValuePair item in booleanMap) { 26 | // type 27 | touts.writeByte(TransferObject.DATATYPE_BOOLEAN); 28 | // key 29 | String key = item.Key; 30 | touts.writeString(key); 31 | // value 32 | bool value = item.Value; 33 | touts.writeBoolean(value); 34 | } 35 | } 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /tatala-client-csharp/src/QiLeYuan/Tatala/socket/to/helper/ByteArrayMapHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using QiLeYuan.Tatala.socket.util; 4 | using QiLeYuan.Tatala.socket.io; 5 | 6 | namespace QiLeYuan.Tatala.socket.to.helper { 7 | public class ByteArrayMapHelper { 8 | public static int getByteArrayLength(Dictionary byteArrayMap) { 9 | int blength = 0; 10 | foreach (KeyValuePair item in byteArrayMap) { 11 | // type 12 | blength += TransferUtil.getLengthOfByte(); 13 | // key 14 | String key = item.Key; 15 | blength += TransferUtil.getLengthOfString(key); 16 | // value 17 | byte[] values = item.Value; 18 | blength += TransferUtil.getLengthOfByteArray(values); 19 | } 20 | return blength; 21 | } 22 | 23 | public static void getByteArray(Dictionary byteArrayMap, TransferOutputStream touts) { 24 | foreach (KeyValuePair item in byteArrayMap) { 25 | // type 26 | touts.writeByte(TransferObject.DATATYPE_BYTEARRAY); 27 | // key 28 | String key = item.Key; 29 | touts.writeString(key); 30 | // value 31 | byte[] values = item.Value; 32 | touts.writeByteArray(values); 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /tatala-client-csharp/src/QiLeYuan/Tatala/socket/to/helper/ByteMapHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using QiLeYuan.Tatala.socket.io; 4 | using QiLeYuan.Tatala.socket.util; 5 | 6 | namespace QiLeYuan.Tatala.socket.to.helper { 7 | 8 | public class ByteMapHelper { 9 | public static int getByteArrayLength(Dictionary byteMap) { 10 | int blength = 0; 11 | foreach (KeyValuePair item in byteMap) { 12 | // type 13 | blength += TransferUtil.getLengthOfByte(); 14 | // key 15 | String key = item.Key; 16 | blength += TransferUtil.getLengthOfString(key); 17 | // value 18 | blength += TransferUtil.getLengthOfByte(); 19 | } 20 | return blength; 21 | } 22 | 23 | public static void getByteArray(Dictionary byteMap, TransferOutputStream touts) { 24 | foreach (KeyValuePair item in byteMap) { 25 | // type 26 | touts.writeByte(TransferObject.DATATYPE_BYTE); 27 | // key 28 | String key = item.Key; 29 | touts.writeString(key); 30 | // value 31 | byte value = item.Value; 32 | touts.writeByte(value); 33 | } 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /tatala-client-csharp/src/QiLeYuan/Tatala/socket/to/helper/CharMapHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using QiLeYuan.Tatala.socket.io; 4 | using QiLeYuan.Tatala.socket.util; 5 | 6 | namespace QiLeYuan.Tatala.socket.to.helper { 7 | 8 | public class CharMapHelper { 9 | public static int getByteArrayLength(Dictionary charMap) { 10 | int blength = 0; 11 | foreach (KeyValuePair item in charMap) { 12 | // type 13 | blength += TransferUtil.getLengthOfByte(); 14 | // key 15 | String key = item.Key; 16 | blength += TransferUtil.getLengthOfString(key); 17 | // value 18 | blength += TransferUtil.getLengthOfChar(); 19 | } 20 | return blength; 21 | } 22 | 23 | public static void getByteArray(Dictionary charMap, TransferOutputStream touts) { 24 | foreach (KeyValuePair item in charMap) { 25 | // type 26 | touts.writeByte(TransferObject.DATATYPE_CHAR); 27 | // key 28 | String key = item.Key; 29 | touts.writeString(key); 30 | // value 31 | char value = item.Value; 32 | touts.writeChar(value); 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /tatala-client-csharp/src/QiLeYuan/Tatala/socket/to/helper/DateMapHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using QiLeYuan.Tatala.socket.io; 4 | using QiLeYuan.Tatala.socket.util; 5 | 6 | namespace QiLeYuan.Tatala.socket.to.helper { 7 | 8 | public class DateMapHelper { 9 | public static int getByteArrayLength(Dictionary dateMap) { 10 | int blength = 0; 11 | foreach (KeyValuePair item in dateMap) { 12 | // type 13 | blength += TransferUtil.getLengthOfByte(); 14 | // key 15 | String key = item.Key; 16 | blength += TransferUtil.getLengthOfString(key); 17 | // value 18 | blength += TransferUtil.getLengthOfDate(); 19 | } 20 | return blength; 21 | } 22 | 23 | public static void getByteArray(Dictionary dateMap, TransferOutputStream touts) { 24 | foreach (KeyValuePair item in dateMap) { 25 | // type 26 | touts.writeByte(TransferObject.DATATYPE_DATE); 27 | // key 28 | String key = item.Key; 29 | touts.writeString(key); 30 | // value 31 | DateTime value = item.Value; 32 | touts.writeDate(value); 33 | } 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /tatala-client-csharp/src/QiLeYuan/Tatala/socket/to/helper/DoubleMapHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using QiLeYuan.Tatala.socket.util; 4 | using QiLeYuan.Tatala.socket.io; 5 | 6 | namespace QiLeYuan.Tatala.socket.to.helper { 7 | 8 | public class DoubleMapHelper { 9 | public static int getByteArrayLength(Dictionary doubleMap) { 10 | int blength = 0; 11 | foreach (KeyValuePair item in doubleMap) { 12 | // type 13 | blength += TransferUtil.getLengthOfByte(); 14 | // key 15 | String key = item.Key; 16 | blength += TransferUtil.getLengthOfString(key); 17 | // value 18 | blength += TransferUtil.getLengthOfDouble(); 19 | } 20 | return blength; 21 | } 22 | 23 | public static void getByteArray(Dictionary doubleMap, TransferOutputStream touts) { 24 | foreach (KeyValuePair item in doubleMap) { 25 | // type 26 | touts.writeByte(TransferObject.DATATYPE_DOUBLE); 27 | // key 28 | String key = item.Key; 29 | touts.writeString(key); 30 | // value 31 | double value = item.Value; 32 | touts.writeDouble(value); 33 | } 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /tatala-client-csharp/src/QiLeYuan/Tatala/socket/to/helper/FloatMapHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using QiLeYuan.Tatala.socket.io; 4 | using QiLeYuan.Tatala.socket.util; 5 | 6 | namespace QiLeYuan.Tatala.socket.to.helper { 7 | 8 | public class FloatMapHelper { 9 | public static int getByteArrayLength(Dictionary floatMap) { 10 | int blength = 0; 11 | foreach (KeyValuePair item in floatMap) { 12 | // type 13 | blength += TransferUtil.getLengthOfByte(); 14 | // key 15 | String key = item.Key; 16 | blength += TransferUtil.getLengthOfString(key); 17 | // value 18 | blength += TransferUtil.getLengthOfFloat(); 19 | } 20 | return blength; 21 | } 22 | 23 | public static void getByteArray(Dictionary floatMap, TransferOutputStream touts) { 24 | foreach (KeyValuePair item in floatMap) { 25 | // type 26 | touts.writeByte(TransferObject.DATATYPE_FLOAT); 27 | // key 28 | String key = item.Key; 29 | touts.writeString(key); 30 | // value 31 | float value = item.Value; 32 | touts.writeFloat(value); 33 | } 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /tatala-client-csharp/src/QiLeYuan/Tatala/socket/to/helper/IntArrayMapHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using QiLeYuan.Tatala.socket.io; 4 | using QiLeYuan.Tatala.socket.util; 5 | 6 | namespace QiLeYuan.Tatala.socket.to.helper { 7 | 8 | public class IntArrayMapHelper { 9 | public static int getByteArrayLength(Dictionary intArrayMap) { 10 | int blength = 0; 11 | foreach (KeyValuePair item in intArrayMap) { 12 | // type 13 | blength += TransferUtil.getLengthOfByte(); 14 | // key 15 | String key = item.Key; 16 | blength += TransferUtil.getLengthOfString(key); 17 | // value 18 | int[] values = item.Value; 19 | blength += TransferUtil.getLengthOfIntArray(values); 20 | } 21 | return blength; 22 | } 23 | 24 | public static void getByteArray(Dictionary intArrayMap, TransferOutputStream touts) { 25 | foreach (KeyValuePair item in intArrayMap) { 26 | // type 27 | touts.writeByte(TransferObject.DATATYPE_INTARRAY); 28 | // key 29 | String key = item.Key; 30 | touts.writeString(key); 31 | // value 32 | int[] values = item.Value; 33 | touts.writeIntArray(values); 34 | } 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /tatala-client-csharp/src/QiLeYuan/Tatala/socket/to/helper/IntMapHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using QiLeYuan.Tatala.socket.io; 4 | using QiLeYuan.Tatala.socket.util; 5 | 6 | namespace QiLeYuan.Tatala.socket.to.helper { 7 | 8 | public class IntMapHelper { 9 | public static int getByteArrayLength(Dictionary intMap) { 10 | int blength = 0; 11 | foreach (KeyValuePair item in intMap) { 12 | // type 13 | blength += TransferUtil.getLengthOfByte(); 14 | // key 15 | String key = item.Key; 16 | blength += TransferUtil.getLengthOfString(key); 17 | // value 18 | blength += TransferUtil.getLengthOfInt(); 19 | } 20 | return blength; 21 | } 22 | 23 | public static void getByteArray(Dictionary intMap, TransferOutputStream touts) { 24 | foreach (KeyValuePair item in intMap) { 25 | // type 26 | touts.writeByte(TransferObject.DATATYPE_INT); 27 | // key 28 | String key = item.Key; 29 | touts.writeString(key); 30 | // value 31 | int value = item.Value; 32 | touts.writeInt(value); 33 | } 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /tatala-client-csharp/src/QiLeYuan/Tatala/socket/to/helper/LongArrayMapHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using QiLeYuan.Tatala.socket.io; 4 | using QiLeYuan.Tatala.socket.util; 5 | 6 | namespace QiLeYuan.Tatala.socket.to.helper { 7 | 8 | public class LongArrayMapHelper { 9 | public static int getByteArrayLength(Dictionary longArrayMap) { 10 | int blength = 0; 11 | foreach (KeyValuePair item in longArrayMap) { 12 | // type 13 | blength += TransferUtil.getLengthOfByte(); 14 | // key 15 | String key = item.Key; 16 | blength += TransferUtil.getLengthOfString(key); 17 | // value 18 | long[] values = item.Value; 19 | blength += TransferUtil.getLengthOfLongArray(values); 20 | } 21 | return blength; 22 | } 23 | 24 | public static void getByteArray(Dictionary longArrayMap, TransferOutputStream touts) { 25 | foreach (KeyValuePair item in longArrayMap) { 26 | // type 27 | touts.writeByte(TransferObject.DATATYPE_LONGARRAY); 28 | // key 29 | String key = item.Key; 30 | touts.writeString(key); 31 | // value 32 | long[] values = item.Value; 33 | touts.writeLongArray(values); 34 | } 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /tatala-client-csharp/src/QiLeYuan/Tatala/socket/to/helper/LongMapHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using QiLeYuan.Tatala.socket.io; 4 | using QiLeYuan.Tatala.socket.util; 5 | 6 | namespace QiLeYuan.Tatala.socket.to.helper { 7 | 8 | public class LongMapHelper { 9 | public static int getByteArrayLength(Dictionary longMap) { 10 | int blength = 0; 11 | foreach (KeyValuePair item in longMap) { 12 | // type 13 | blength += TransferUtil.getLengthOfByte(); 14 | // key 15 | String key = item.Key; 16 | blength += TransferUtil.getLengthOfString(key); 17 | // value 18 | blength += TransferUtil.getLengthOfLong(); 19 | } 20 | return blength; 21 | } 22 | 23 | public static void getByteArray(Dictionary longMap, TransferOutputStream touts) { 24 | foreach (KeyValuePair item in longMap) { 25 | // type 26 | touts.writeByte(TransferObject.DATATYPE_LONG); 27 | // key 28 | String key = item.Key; 29 | touts.writeString(key); 30 | // value 31 | long value = item.Value; 32 | touts.writeLong(value); 33 | } 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /tatala-client-csharp/src/QiLeYuan/Tatala/socket/to/helper/ShortMapHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using QiLeYuan.Tatala.socket.io; 4 | using QiLeYuan.Tatala.socket.util; 5 | 6 | namespace QiLeYuan.Tatala.socket.to.helper { 7 | 8 | public class ShortMapHelper { 9 | public static int getByteArrayLength(Dictionary shortMap) { 10 | int blength = 0; 11 | foreach (KeyValuePair item in shortMap) { 12 | // type 13 | blength += TransferUtil.getLengthOfByte(); 14 | // key 15 | String key = item.Key; 16 | blength += TransferUtil.getLengthOfString(key); 17 | // value 18 | blength += TransferUtil.getLengthOfShort(); 19 | } 20 | return blength; 21 | } 22 | 23 | public static void getByteArray(Dictionary shortMap, TransferOutputStream touts) { 24 | foreach (KeyValuePair item in shortMap) { 25 | // type 26 | touts.writeByte(TransferObject.DATATYPE_SHORT); 27 | // key 28 | String key = item.Key; 29 | touts.writeString(key); 30 | // value 31 | short value = item.Value; 32 | touts.writeShort(value); 33 | } 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /tatala-client-csharp/src/QiLeYuan/Tatala/socket/to/helper/StringMapHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using QiLeYuan.Tatala.socket.io; 4 | using QiLeYuan.Tatala.socket.util; 5 | 6 | namespace QiLeYuan.Tatala.socket.to.helper { 7 | 8 | public class StringMapHelper { 9 | public static int getByteArrayLength(Dictionary stringMap) { 10 | int blength = 0; 11 | foreach (KeyValuePair item in stringMap) { 12 | // type 13 | blength += TransferUtil.getLengthOfByte(); 14 | // key 15 | String key = item.Key; 16 | blength += TransferUtil.getLengthOfString(key); 17 | // value 18 | String value = item.Value; 19 | blength += TransferUtil.getLengthOfString(value); 20 | } 21 | return blength; 22 | } 23 | 24 | public static void getByteArray(Dictionary stringMap, TransferOutputStream touts) { 25 | foreach (KeyValuePair item in stringMap) { 26 | // type 27 | touts.writeByte(TransferObject.DATATYPE_STRING); 28 | // key 29 | String key = item.Key; 30 | touts.writeString(key); 31 | // value 32 | String value = item.Value; 33 | touts.writeString(value); 34 | } 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /tatala-client-csharp/src/QiLeYuan/Tools/Xstream/Core/ConditionalConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Xstream.Core 4 | { 5 | public interface ConditionalConverter : IConverter 6 | { 7 | bool Match(Type type); 8 | } 9 | } -------------------------------------------------------------------------------- /tatala-client-csharp/src/QiLeYuan/Tools/Xstream/Core/ConversionException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Xstream.Core 5 | { 6 | /// 7 | /// Exception that occurs then (de)serialization of an object fails. 8 | /// 9 | [Serializable] 10 | public class ConversionException : Exception 11 | { 12 | internal ConversionException(SerializationInfo info, StreamingContext context) : base(info, context) {} 13 | internal ConversionException(string message) : base(message) {} 14 | internal ConversionException(string message, Exception innerException) : base(message, innerException) {} 15 | } 16 | } -------------------------------------------------------------------------------- /tatala-client-csharp/src/QiLeYuan/Tools/Xstream/Core/Converters/NoopConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Xml; 4 | 5 | namespace Xstream.Core.Converters 6 | { 7 | public class NoopConverter : IConverter 8 | { 9 | private static NoopConverter instance = new NoopConverter(); 10 | private NoopConverter() {} 11 | 12 | public static IConverter Instance 13 | { 14 | get { return instance; } 15 | } 16 | 17 | public void Register(IMarshalContext context) 18 | { 19 | } 20 | 21 | public void ToXml(object value, FieldInfo field, XmlTextWriter xml, IMarshalContext context) 22 | { 23 | } 24 | 25 | public object FromXml(object parent, FieldInfo field, Type type, XmlNode xml, IMarshalContext context) 26 | { 27 | throw new NotImplementedException(); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /tatala-client-csharp/src/QiLeYuan/Tools/Xstream/Core/Converters/NullConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Xml; 4 | 5 | namespace Xstream.Core.Converters 6 | { 7 | /// 8 | /// Special converter to convert null values. 9 | /// 10 | internal class NullConverter : IConverter 11 | { 12 | private static readonly Type __type = typeof( NullType ); 13 | 14 | /// 15 | /// Register is called by a MarshalContext to allow the 16 | /// converter instance to register itself in the context 17 | /// with all appropriate value types and interfaces. 18 | /// 19 | public void Register(IMarshalContext context) 20 | { 21 | context.RegisterConverter( __type, this ); 22 | context.Alias( "null", __type ); 23 | } 24 | 25 | /// 26 | /// Converts the object passed in to its XML representation. 27 | /// The XML string is written on the XmlTextWriter. 28 | /// 29 | public void ToXml(object value, FieldInfo field, XmlTextWriter xml, IMarshalContext context) 30 | { 31 | xml.WriteElementString( "null", string.Empty ); 32 | } 33 | 34 | /// 35 | /// Converts the XmlNode data passed in back to an actual 36 | /// .NET instance object. 37 | /// 38 | /// Object created from the XML. 39 | public object FromXml(object parent, FieldInfo field, Type type, XmlNode xml, IMarshalContext context) 40 | { 41 | return null; 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /tatala-client-csharp/src/QiLeYuan/Tools/Xstream/Core/Converters/PointerConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Xml; 4 | 5 | namespace Xstream.Core.Converters 6 | { 7 | /// 8 | /// Converts a pointer (System.Reflection.Pointer) to xml and back. 9 | /// 10 | /// 11 | /// Not implemented to convert pointer types. 12 | /// 13 | internal class PointerConverter : IConverter 14 | { 15 | private static readonly Type __type = typeof( Pointer ); 16 | 17 | /// 18 | /// Register is called by a MarshalContext to allow the 19 | /// converter instance to register itself in the context 20 | /// with all appropriate value types and interfaces. 21 | /// 22 | public void Register(IMarshalContext context) 23 | { 24 | context.RegisterConverter( __type, this ); 25 | } 26 | 27 | /// 28 | /// Converts the object passed in to its XML representation. 29 | /// The XML string is written on the XmlTextWriter. 30 | /// 31 | public void ToXml(object value, FieldInfo field, XmlTextWriter xml, IMarshalContext context) 32 | { 33 | } 34 | 35 | /// 36 | /// Converts the XmlNode data passed in, back to an actual 37 | /// .NET instance object. 38 | /// 39 | /// Object created from the XML. 40 | public object FromXml(object parent, FieldInfo field, Type type, XmlNode xml, IMarshalContext context) 41 | { 42 | return null; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /tatala-client-csharp/src/QiLeYuan/Tools/Xstream/Core/Converters/TargetForceLoader.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | namespace Xstream.Core.Converters 4 | { 5 | internal class TargetForceLoader 6 | { 7 | public static object GetTargetValue(object value) 8 | { 9 | if (value == null) return value; 10 | ForceLoadTheEntityBecauseItIsLazy(value); 11 | 12 | FieldInfo interceptorField = value.GetType().GetField("__interceptor"); 13 | if (interceptorField == null) return value; 14 | 15 | object interceptorValue = interceptorField.GetValue(value); 16 | FieldInfo targetField = interceptorValue.GetType().BaseType.GetField("_target", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); 17 | return targetField.GetValue(interceptorValue); 18 | } 19 | 20 | private static void ForceLoadTheEntityBecauseItIsLazy(object value) 21 | { 22 | try 23 | { 24 | value.GetType().GetMethod("get_Version", BindingFlags.Public | BindingFlags.Instance).Invoke(value, new object[] {}); 25 | } 26 | catch (TargetInvocationException e) 27 | { 28 | throw e.InnerException.InnerException; 29 | } 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /tatala-client-csharp/src/QiLeYuan/Tools/Xstream/Core/FileXStream.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | 4 | namespace Xstream.Core 5 | { 6 | public class FileXStream : IXStream 7 | { 8 | // Fields 9 | private readonly string fileName; 10 | private readonly XStream xStream; 11 | 12 | // Methods 13 | public FileXStream(string fileName) 14 | { 15 | this.fileName = fileName; 16 | xStream = new XStream(); 17 | } 18 | 19 | public void AddConverter(IConverter converter) 20 | { 21 | xStream.AddConverter(converter); 22 | } 23 | 24 | public void AddIgnoreAttribute(Type ignoredAttributeType) 25 | { 26 | xStream.AddIgnoreAttribute(ignoredAttributeType); 27 | } 28 | 29 | public object FromFile() 30 | { 31 | return xStream.FromXml(File.ReadAllText(fileName)); 32 | } 33 | 34 | public object FromXml(string xml) 35 | { 36 | return xStream.FromXml(xml); 37 | } 38 | 39 | public string ToXml(object value) 40 | { 41 | string xml = xStream.ToXml(value); 42 | File.WriteAllText(fileName, xml); 43 | return xml; 44 | } 45 | 46 | public XStream XStream 47 | { 48 | get { return xStream; } 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /tatala-client-csharp/src/QiLeYuan/Tools/Xstream/Core/IConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Xml; 4 | 5 | namespace Xstream.Core 6 | { 7 | /// 8 | /// IConverter is the interface that all type converter instances 9 | /// should implement to get used with a MarshalContext. 10 | /// 11 | public interface IConverter 12 | { 13 | /// 14 | /// Register is called by a MarshalContext to allow the 15 | /// converter instance to register itself in the context 16 | /// with all appropriate value types and interfaces. 17 | /// 18 | void Register(IMarshalContext context); 19 | 20 | /// 21 | /// Converts the object passed in to its XML representation. 22 | /// The XML string is written on the XmlTextWriter. 23 | /// 24 | void ToXml(object value, FieldInfo field, XmlTextWriter xml, IMarshalContext context); 25 | 26 | /// 27 | /// Converts the XmlNode data passed in back to an actual 28 | /// .NET instance object. 29 | /// 30 | /// Object created from the XML. 31 | object FromXml(object parent, FieldInfo field, Type type, XmlNode xml, IMarshalContext context); 32 | } 33 | 34 | public interface AssignableConverter : IConverter 35 | { 36 | Type ConverteeType { get; } 37 | } 38 | } -------------------------------------------------------------------------------- /tatala-client-csharp/src/QiLeYuan/Tools/Xstream/Core/IMarshalContext.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Xml; 4 | 5 | namespace Xstream.Core 6 | { 7 | public interface IMarshalContext 8 | { 9 | bool ContainsType(object o); 10 | object GetOfType(object matchingObj); 11 | void WriteStartTag(Type type, FieldInfo field, XmlTextWriter textWriter); 12 | int GetStackIndex(object value); 13 | void Stack(object value, Type type); 14 | void WriteEndTag(Type type, FieldInfo field, XmlTextWriter xml); 15 | object GetStackObject(int stackIx); 16 | void Stack(object value, Type type, XmlNode xmlNode); 17 | IConverter GetConverter(XmlNode child, ref Type type); 18 | void RegisterConverter(Type type, IConverter converter); 19 | Type IgnoredAttributeType { get; } 20 | bool CaseSensitive { get; set; } 21 | IConverter GetConverter(Type type); 22 | void ClearStack(); 23 | void Alias(string s, Type type); 24 | void Stack(object o); 25 | void AddIgnoreAttribute(Type type); 26 | string GetTypeName(Type type); 27 | void AddConverter(IConverter converter); 28 | bool IsCData(Type type, string fieldName); 29 | IConverter GetCDataConverter(); 30 | void AddCdata(Type type, string name); 31 | } 32 | } -------------------------------------------------------------------------------- /tatala-client-csharp/src/QiLeYuan/Tools/Xstream/Core/IXStream.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Xstream.Core 4 | { 5 | public interface IXStream 6 | { 7 | void AddConverter(IConverter converter); 8 | void AddIgnoreAttribute(Type ignoredAttributeType); 9 | object FromXml(string xml); 10 | string ToXml(object value); 11 | } 12 | } -------------------------------------------------------------------------------- /tatala-client-csharp/src/QiLeYuan/Tools/Xstream/Core/NullType.cs: -------------------------------------------------------------------------------- 1 | namespace Xstream.Core 2 | { 3 | /// 4 | /// Dummy class, representing null value. 5 | /// 6 | internal class NullType {} 7 | } -------------------------------------------------------------------------------- /tatala-client-csharp/src/QiLeYuan/Tools/Xstream/Core/ReferenceComparer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | 3 | namespace Xstream.Core 4 | { 5 | internal class ReferenceComparer : IEqualityComparer 6 | { 7 | bool IEqualityComparer.Equals(object x, object y) 8 | { 9 | return ReferenceEquals(x, y); 10 | } 11 | 12 | int IEqualityComparer.GetHashCode(object obj) 13 | { 14 | return obj.GetHashCode(); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /tatala-java-example/build.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 | -------------------------------------------------------------------------------- /tatala-java-example/chatroom.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | set classpath=. 3 | set classpath=%classpath%;lib\* 4 | set classpath=%classpath%;target\* 5 | 6 | java com.qileyuan.tatala.example.client.ChatRoomClient -------------------------------------------------------------------------------- /tatala-java-example/chatroomserver.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | set classpath=. 3 | set classpath=%classpath%;lib\* 4 | set classpath=%classpath%;target\* 5 | 6 | java com.qileyuan.tatala.example.server.ChatRoomServer 10002 7 | -------------------------------------------------------------------------------- /tatala-java-example/client.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | set classpath=. 3 | set classpath=%classpath%;lib\* 4 | set classpath=%classpath%;target\* 5 | 6 | java com.qileyuan.tatala.example.client.ExampleClient -------------------------------------------------------------------------------- /tatala-java-example/clusterserver1.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | mvn exec:java -Dexec.mainClass="com.qileyuan.tatala.example.server.ClusterServer" -Dexec.args="127.0.0.1:10001 16 127.0.0.1:2181" 4 | -------------------------------------------------------------------------------- /tatala-java-example/clusterserver2.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | mvn exec:java -Dexec.mainClass="com.qileyuan.tatala.example.server.ClusterServer" -Dexec.args="127.0.0.1:10002 16 127.0.0.1:2181" 4 | -------------------------------------------------------------------------------- /tatala-java-example/easyclient.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | set classpath=. 3 | set classpath=%classpath%;lib\* 4 | set classpath=%classpath%;target\* 5 | 6 | java com.qileyuan.tatala.example.client.EasyClient -------------------------------------------------------------------------------- /tatala-java-example/lib/log4j-1.2.17.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zijan/Tatala-RPC/b975e54a314b38d41f3f85fe93c2346972966cee/tatala-java-example/lib/log4j-1.2.17.jar -------------------------------------------------------------------------------- /tatala-java-example/lib/protobuf-java-2.6.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zijan/Tatala-RPC/b975e54a314b38d41f3f85fe93c2346972966cee/tatala-java-example/lib/protobuf-java-2.6.1.jar -------------------------------------------------------------------------------- /tatala-java-example/lib/tatala-0.3.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zijan/Tatala-RPC/b975e54a314b38d41f3f85fe93c2346972966cee/tatala-java-example/lib/tatala-0.3.0.jar -------------------------------------------------------------------------------- /tatala-java-example/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | com.qileyuan 6 | tatala-java-example 7 | 0.3.0 8 | jar 9 | 10 | Tatala Java Example 11 | 12 | 13 | UTF-8 14 | 1.7 15 | 1.7 16 | 17 | 18 | 19 | 20 | log4j 21 | log4j 22 | 1.2.17 23 | 24 | 25 | com.google.protobuf 26 | protobuf-java 27 | 2.6.1 28 | 29 | 30 | com.github.zijan 31 | tatala 32 | 0.3.0 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /tatala-java-example/server.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | set classpath=. 3 | set classpath=%classpath%;lib\* 4 | set classpath=%classpath%;target\* 5 | 6 | java com.qileyuan.tatala.example.server.ExampleServer 7 | -------------------------------------------------------------------------------- /tatala-java-example/src/main/java/com/qileyuan/tatala/example/proxy/ChatRoomClientDefaultProxy.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.example.proxy; 2 | 3 | import com.qileyuan.tatala.example.client.ChatRoomClient; 4 | import com.qileyuan.tatala.proxy.DefaultProxy; 5 | import com.qileyuan.tatala.socket.to.TransferObject; 6 | 7 | public class ChatRoomClientDefaultProxy extends DefaultProxy { 8 | 9 | public Object execute(TransferObject to){ 10 | String calleeMethod = to.getCalleeMethod(); 11 | if(calleeMethod.equals("receiveMessage")){ 12 | String message = to.getString(); 13 | ChatRoomClient.getInstance().receiveMessage(message); 14 | } 15 | return null; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /tatala-java-example/src/main/java/com/qileyuan/tatala/example/proxy/ChatRoomServerProxy.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.example.proxy; 2 | 3 | import com.qileyuan.tatala.example.service.ChatRoomServerLogic; 4 | import com.qileyuan.tatala.socket.server.ServerSession; 5 | import com.qileyuan.tatala.socket.to.OrderedTransferObject; 6 | import com.qileyuan.tatala.socket.to.TransferObject; 7 | 8 | public class ChatRoomServerProxy { 9 | 10 | private ChatRoomServerLogic serverLogic = ChatRoomServerLogic.getInstance(); 11 | 12 | public void login(TransferObject to){ 13 | String username = to.getString(); 14 | serverLogic.login(to.getClientId(), username); 15 | } 16 | 17 | public void receiveMessage(TransferObject to){ 18 | String message = to.getString(); 19 | serverLogic.broadcast(to.getClientId(), message); 20 | } 21 | 22 | public static void sendMessage(ServerSession session, String sendMessage){ 23 | TransferObject to = new OrderedTransferObject(); 24 | to.setServerCall(true); 25 | //comment out for call client default proxy 26 | //to.setCalleeClass("com.qileyuan.tatala.example.proxy.ChatRoomClientProxy"); 27 | to.setDefaultCallee(true); 28 | to.setCalleeMethod("receiveMessage"); 29 | to.putString(sendMessage); 30 | session.executeServerCall(to); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /tatala-java-example/src/main/java/com/qileyuan/tatala/example/server/ChatRoomServer.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.example.server; 2 | 3 | import org.apache.log4j.Logger; 4 | 5 | import com.qileyuan.tatala.example.service.ChatRoomServerLogic; 6 | import com.qileyuan.tatala.socket.server.AioSocketServer; 7 | 8 | public class ChatRoomServer { 9 | static Logger log = Logger.getLogger(ChatRoomServer.class); 10 | 11 | public static void initialize(){ 12 | log.info("Chat Room Server initialize..."); 13 | } 14 | 15 | public static void startup(int listenPort, int poolSize){ 16 | log.info("Chat Room Server starting..."); 17 | 18 | AioSocketServer server = new AioSocketServer(listenPort, poolSize); 19 | server.start(); 20 | 21 | ChatRoomServerLogic serverLogic = ChatRoomServerLogic.getInstance(); 22 | //chat room server logic need session map from AioSocketServer 23 | serverLogic.setSessionMap(AioSocketServer.getSessionMap()); 24 | } 25 | 26 | public static void main(String args[]) { 27 | log.info("*** Chat Room Server ***"); 28 | int listenPort = 10002; 29 | int poolSize = 16; 30 | if(args != null && args.length > 1){ 31 | listenPort = Integer.parseInt(args[0]); 32 | poolSize = Integer.parseInt(args[1]); 33 | } 34 | initialize(); 35 | startup(listenPort, poolSize); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /tatala-java-example/src/main/java/com/qileyuan/tatala/example/server/ExampleServer.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.example.server; 2 | 3 | import org.apache.log4j.Logger; 4 | 5 | import com.qileyuan.tatala.example.proxy.ExampleDefaultProxy; 6 | import com.qileyuan.tatala.proxy.DefaultProxy; 7 | import com.qileyuan.tatala.socket.server.AioSocketServer; 8 | 9 | public class ExampleServer { 10 | static Logger log = Logger.getLogger(ExampleServer.class); 11 | 12 | public static void initialize(){ 13 | log.info("Example Tatala Server initialize..."); 14 | } 15 | 16 | public static void startup(int listenPort, int poolSize){ 17 | log.info("Example Tatala Server starting..."); 18 | 19 | AioSocketServer server = new AioSocketServer(listenPort, poolSize); 20 | 21 | try { 22 | //set default proxy or callee class here 23 | DefaultProxy defaultProxy = new ExampleDefaultProxy(); 24 | server.registerProxy(defaultProxy); 25 | server.start(); 26 | } catch (Exception e) { 27 | e.printStackTrace(); 28 | } 29 | } 30 | 31 | public static void main(String args[]) { 32 | log.info("*** Example Tatala Server ***"); 33 | int listenPort = 10001; 34 | int poolSize = 16; 35 | if(args != null && args.length > 1){ 36 | listenPort = Integer.parseInt(args[0]); 37 | poolSize = Integer.parseInt(args[1]); 38 | } 39 | 40 | initialize(); 41 | startup(listenPort, poolSize); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /tatala-java-example/src/main/java/com/qileyuan/tatala/example/service/ExampleManager.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.example.service; 2 | 3 | import java.util.Date; 4 | import java.util.List; 5 | import java.util.Map; 6 | import java.util.Set; 7 | 8 | import com.qileyuan.tatala.example.service.model.Account; 9 | import com.qileyuan.tatala.example.service.model.AllTypeBean; 10 | 11 | 12 | /** 13 | * This interface is a sample for the socket server provider. 14 | * @author JimT 15 | * 16 | */ 17 | public interface ExampleManager { 18 | public String sayHello(int Id, String name); 19 | public void doSomething(); 20 | public void exceptionCall(int Id); 21 | public Account getAccount(Account account); 22 | public List getAccountList(List accountList); 23 | public Map getAccountMap(Map accountMap); 24 | public Set getAccountSet(Set accountSet); 25 | public AllTypeBean getAllTypeBean(boolean aboolean, byte abyte, short ashort, char achar, int aint, long along, 26 | float afloat, double adouble, Date adate, String astring); 27 | public String[] getArray(byte[] bytearr, String[] strarr); 28 | } 29 | -------------------------------------------------------------------------------- /tatala-java-example/src/main/java/com/qileyuan/tatala/example/service/ExampleReturnException.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.example.service; 2 | 3 | import com.qileyuan.tatala.socket.exception.TatalaRollbackException; 4 | 5 | 6 | public class ExampleReturnException extends TatalaRollbackException{ 7 | private static final long serialVersionUID = 1L; 8 | 9 | public ExampleReturnException() { 10 | super(); 11 | } 12 | 13 | public ExampleReturnException(String msg) { 14 | super(msg); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /tatala-java-example/src/main/java/com/qileyuan/tatala/example/service/model/Account.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.example.service.model; 2 | 3 | import java.io.Serializable; 4 | 5 | public class Account implements Serializable{ 6 | private static final long serialVersionUID = 1L; 7 | private int id; 8 | private String name; 9 | private String address; 10 | 11 | public int getId() { 12 | return id; 13 | } 14 | public void setId(int id) { 15 | this.id = id; 16 | } 17 | public String getName() { 18 | return name; 19 | } 20 | public void setName(String name) { 21 | this.name = name; 22 | } 23 | public String getAddress() { 24 | return address; 25 | } 26 | public void setAddress(String address) { 27 | this.address = address; 28 | } 29 | 30 | public String toString(){ 31 | return "[id: "+id+"][name: "+name+"][address: "+address+"]"; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /tatala-java-example/src/main/java/com/qileyuan/tatala/example/service/model/proto/account.proto: -------------------------------------------------------------------------------- 1 | option java_package = "com.qileyuan.tatala.example.service.model.proto"; 2 | option java_outer_classname = "AccountProto"; 3 | 4 | message Account { 5 | required int32 id = 1; 6 | required string name = 2; 7 | optional string address = 3; 8 | } -------------------------------------------------------------------------------- /tatala-java-example/target/tatala-java-example-0.3.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zijan/Tatala-RPC/b975e54a314b38d41f3f85fe93c2346972966cee/tatala-java-example/target/tatala-java-example-0.3.0.jar -------------------------------------------------------------------------------- /tatala-java/build.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 | -------------------------------------------------------------------------------- /tatala-java/lib/log4j-1.2.17.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zijan/Tatala-RPC/b975e54a314b38d41f3f85fe93c2346972966cee/tatala-java/lib/log4j-1.2.17.jar -------------------------------------------------------------------------------- /tatala-java/lib/zookeeper-3.5.0-alpha.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zijan/Tatala-RPC/b975e54a314b38d41f3f85fe93c2346972966cee/tatala-java/lib/zookeeper-3.5.0-alpha.jar -------------------------------------------------------------------------------- /tatala-java/src/main/java/com/qileyuan/tatala/executor/ServerExecutor.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.executor; 2 | 3 | import com.qileyuan.tatala.socket.client.SocketController; 4 | import com.qileyuan.tatala.socket.to.TransferObject; 5 | 6 | /** 7 | * This class is the distribution-method-call executor, which dispatches request to socket controller. 8 | * 9 | * @author Jim Tang 10 | * 11 | */ 12 | public class ServerExecutor{ 13 | public static Object execute(TransferObject to){ 14 | return SocketController.execute(to); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /tatala-java/src/main/java/com/qileyuan/tatala/proxy/ClientProxyFactory.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.proxy; 2 | 3 | import java.lang.reflect.Proxy; 4 | 5 | import com.qileyuan.tatala.socket.to.TransferObjectFactory; 6 | 7 | public class ClientProxyFactory { 8 | public static Object create(Class clazz, TransferObjectFactory transferObjectFactory) { 9 | return Proxy.newProxyInstance( 10 | ClientProxyFactory.class.getClassLoader(), 11 | new Class[] { clazz }, 12 | new ClientProxy(transferObjectFactory)); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tatala-java/src/main/java/com/qileyuan/tatala/proxy/DefaultProxy.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.proxy; 2 | 3 | import org.apache.log4j.Logger; 4 | 5 | import com.qileyuan.tatala.socket.to.TransferObject; 6 | 7 | public class DefaultProxy { 8 | Logger log = Logger.getLogger(DefaultProxy.class); 9 | public Object execute(TransferObject to){ 10 | log.error("This is DefaultProxy. You need extend it by specific proxy or callee class."); 11 | return null; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tatala-java/src/main/java/com/qileyuan/tatala/socket/client/AioClientReceiveHandler.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.socket.client; 2 | 3 | import java.nio.ByteBuffer; 4 | import java.nio.channels.CompletionHandler; 5 | 6 | import org.apache.log4j.Logger; 7 | 8 | public class AioClientReceiveHandler implements CompletionHandler { 9 | Logger log = Logger.getLogger(AioClientReceiveHandler.class); 10 | 11 | @Override 12 | public void completed(Integer receivedCount, LongClientSession session) { 13 | 14 | //server close socket channel or network issue 15 | if(receivedCount < 0){ 16 | session.close(); 17 | return; 18 | } 19 | try { 20 | ByteBuffer byteBuffer = session.getByteBuffer(); 21 | if(receivedCount > 0){ 22 | byteBuffer.flip(); 23 | byte[] receiveData = new byte[byteBuffer.limit()]; 24 | byteBuffer.get(receiveData); 25 | session.write(receiveData); 26 | byteBuffer.compact(); 27 | 28 | //chech whether one receive from server is done 29 | session.checkOneReceiveDone(receivedCount, receiveData); 30 | } 31 | } finally { 32 | session.receive(); 33 | } 34 | } 35 | 36 | @Override 37 | public void failed(Throwable exc, LongClientSession session) { 38 | log.error("Receive error: " + exc.getMessage(), exc); 39 | session.close(); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /tatala-java/src/main/java/com/qileyuan/tatala/socket/exception/SocketExecuteException.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.socket.exception; 2 | 3 | public class SocketExecuteException extends Exception { 4 | 5 | private static final long serialVersionUID = 1L; 6 | 7 | public SocketExecuteException() { 8 | super(); 9 | } 10 | 11 | public SocketExecuteException(String msg) { 12 | super(msg); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tatala-java/src/main/java/com/qileyuan/tatala/socket/exception/TatalaRollbackException.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.socket.exception; 2 | 3 | public class TatalaRollbackException extends RuntimeException{ 4 | 5 | private static final long serialVersionUID = 1L; 6 | 7 | public TatalaRollbackException() { 8 | super(); 9 | } 10 | 11 | public TatalaRollbackException(String msg) { 12 | super(msg); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tatala-java/src/main/java/com/qileyuan/tatala/socket/server/AioReceiveHandler.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.socket.server; 2 | 3 | import java.io.IOException; 4 | import java.nio.ByteBuffer; 5 | import java.nio.channels.CompletionHandler; 6 | 7 | import org.apache.log4j.Logger; 8 | 9 | public class AioReceiveHandler implements CompletionHandler{ 10 | Logger log = Logger.getLogger(AioReceiveHandler.class); 11 | 12 | @Override 13 | public void completed(Integer receivedCount, ServerSession session) { 14 | if(receivedCount < 0){ 15 | session.close(); 16 | return; 17 | } 18 | try { 19 | ByteBuffer byteBuffer = session.getByteBuffer(); 20 | 21 | if (receivedCount > 0) { 22 | byteBuffer.flip(); 23 | byte[] receiveData = new byte[byteBuffer.limit()]; 24 | byteBuffer.get(receiveData); 25 | session.write(receiveData); 26 | byteBuffer.compact(); 27 | 28 | //chech whether one client request is done 29 | session.checkOneReceiveDone(receivedCount, receiveData); 30 | } 31 | } finally { 32 | session.receive(); 33 | } 34 | } 35 | 36 | @Override 37 | public void failed(Throwable exc, ServerSession session) { 38 | //if client close connection, don't log error 39 | if(!IOException.class.isAssignableFrom(exc.getClass())){ 40 | log.error("Receive error: " + exc.getMessage()); 41 | } 42 | session.close(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /tatala-java/src/main/java/com/qileyuan/tatala/socket/server/AioSocketHandler.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.socket.server; 2 | 3 | import java.nio.channels.AsynchronousSocketChannel; 4 | import java.nio.channels.CompletionHandler; 5 | 6 | import org.apache.log4j.Logger; 7 | 8 | public class AioSocketHandler implements CompletionHandler { 9 | Logger log = Logger.getLogger(AioSocketHandler.class); 10 | 11 | private ServerSession session; 12 | 13 | public AioSocketHandler(ServerSession session){ 14 | this.session = session; 15 | } 16 | 17 | @Override 18 | public void completed(AsynchronousSocketChannel socketChannel, AioSocketServer aioSocketServer) { 19 | try { 20 | session.setSocketChannel(socketChannel); 21 | session.start(); 22 | } finally{ 23 | aioSocketServer.acceptConnections(); 24 | } 25 | } 26 | 27 | @Override 28 | public void failed(Throwable exc, AioSocketServer aioSocketServer) { 29 | log.error("Accept error", exc); 30 | aioSocketServer.acceptConnections(); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /tatala-java/src/main/java/com/qileyuan/tatala/socket/server/SessionFilter.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.socket.server; 2 | 3 | public interface SessionFilter { 4 | public void onClose(ServerSession session); 5 | //if return true, ignore execute code 6 | public boolean onReceive(ServerSession session, byte[] receiveData); 7 | } 8 | -------------------------------------------------------------------------------- /tatala-java/src/main/java/com/qileyuan/tatala/socket/to/TransferObjectWrapper.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.socket.to; 2 | 3 | import com.qileyuan.tatala.socket.io.TransferInputStream; 4 | import com.qileyuan.tatala.socket.io.TransferOutputStream; 5 | 6 | /** 7 | * This is customization object wrapper interface. 8 | * 9 | * @author JimT 10 | * 11 | */ 12 | public interface TransferObjectWrapper { 13 | public int getLength(); 14 | public void getByteArray(TransferOutputStream touts); 15 | public TransferObjectWrapper getObjectWrapper(TransferInputStream tins); 16 | } 17 | -------------------------------------------------------------------------------- /tatala-java/src/main/java/com/qileyuan/tatala/socket/util/NetworkUtil.java: -------------------------------------------------------------------------------- 1 | package com.qileyuan.tatala.socket.util; 2 | 3 | import java.io.IOException; 4 | import java.net.InetSocketAddress; 5 | import java.nio.channels.AsynchronousSocketChannel; 6 | 7 | public class NetworkUtil { 8 | public static long convertIpPortToUniqueId(byte[] quad, int port) { 9 | return (((long)port) << 32 10 | | ((long)(quad[0] & 0xFF)) << 24 11 | | ((long)(quad[1] & 0xFF)) << 16 12 | | ((long)(quad[2] & 0xFF)) << 8 13 | | ((long)(quad[3] & 0xFF))); 14 | } 15 | 16 | public static long getClientIdBySocketChannel(AsynchronousSocketChannel socketChannel) throws IOException{ 17 | InetSocketAddress address = (InetSocketAddress)socketChannel.getRemoteAddress(); 18 | byte[] quad = address.getAddress().getAddress(); 19 | int port = address.getPort(); 20 | long clientId = NetworkUtil.convertIpPortToUniqueId(quad, port); 21 | return clientId; 22 | } 23 | 24 | public static String getIpPortByClientId(long clientId){ 25 | long port = clientId >> 32; 26 | long ip1 = (clientId >> 24) - (port << 8); 27 | long ip2 = (clientId >> 16) - (ip1 << 8) - (port << 16); 28 | long ip3 = (clientId >> 8) - (ip2 << 8) - (ip1 << 16) - (port << 24); 29 | long ip4 = clientId - (ip3 << 8) - (ip2 << 16) - (ip1 << 24) - (port << 32); 30 | return ip1+"."+ip2+"."+ip3+"."+ip4+":"+port; 31 | } 32 | } 33 | --------------------------------------------------------------------------------