Skip to content

Commit

Permalink
mdf generate file
Browse files Browse the repository at this point in the history
  • Loading branch information
noclear committed Sep 4, 2017
1 parent f216635 commit 1c3e637
Show file tree
Hide file tree
Showing 65 changed files with 634 additions and 282 deletions.
2 changes: 1 addition & 1 deletion IDL-Example/client/source/IDL/flatbuffer/kissidl.d
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// automatically generated by the FlatBuffers compiler, do not modify

module KissRpc.IDL.flatbuffer.kissidl;
module kissrpc.IDL.flatbuffer.kissidl;

import std.typecons;
import flatbuffers;
Expand Down
2 changes: 1 addition & 1 deletion IDL-Example/client/source/IDL/flatbuffer/kissidl.fbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace KissRpc.IDL.flatbuffer;
namespace kissrpc.IDL.flatbuffer;

table UserInfoFB{
name:string;
Expand Down
18 changes: 9 additions & 9 deletions IDL-Example/client/source/IDL/kissidlInterface.d
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
module KissRpc.IDL.kissidlInterface;
module kissrpc.IDL.kissidlInterface;

import KissRpc.IDL.kissidlMessage;
import KissRpc.IDL.kissidlService;
import kissrpc.IDL.kissidlMessage;
import kissrpc.IDL.kissidlService;

import KissRpc.RpcRequest;
import KissRpc.RpcClientImpl;
import KissRpc.RpcClient;
import KissRpc.RpcResponse;
import KissRpc.Unit;
import kissrpc.RpcRequest;
import kissrpc.RpcClientImpl;
import kissrpc.RpcClient;
import kissrpc.RpcResponse;
import kissrpc.Unit;
import flatbuffers;
import KissRpc.IDL.flatbuffer.kissidl;
import kissrpc.IDL.flatbuffer.kissidl;

abstract class RpcAddressBookInterface{

Expand Down
2 changes: 1 addition & 1 deletion IDL-Example/client/source/IDL/kissidlMessage.d
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module KissRpc.IDL.kissidlMessage;
module kissrpc.IDL.kissidlMessage;
import std.typetuple;


Expand Down
10 changes: 5 additions & 5 deletions IDL-Example/client/source/IDL/kissidlService.d
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module KissRpc.IDL.kissidlService;
module kissrpc.IDL.kissidlService;


import KissRpc.IDL.kissidlInterface;
import KissRpc.IDL.kissidlMessage;
import kissrpc.IDL.kissidlInterface;
import kissrpc.IDL.kissidlMessage;

import KissRpc.RpcClient;
import KissRpc.Unit;
import kissrpc.RpcClient;
import kissrpc.Unit;


class RpcAddressBookService: RpcAddressBookInterface{
Expand Down
14 changes: 7 additions & 7 deletions IDL-Example/client/source/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
import core.time;
import std.datetime;

import KissRpc.RpcClient;
import KissRpc.RpcSocketBaseInterface;
import KissRpc.Logs;
import kissrpc.RpcClient;
import kissrpc.RpcSocketBaseInterface;
import kissrpc.Logs;

import KissRpc.IDL.kissidlService;
import KissRpc.IDL.kissidlMessage;
import kissrpc.IDL.kissidlService;
import kissrpc.IDL.kissidlMessage;

import kiss.event.GroupPoll;
import KissRpc.Unit;
import kissrpc.Unit;

import std.conv;

Expand Down Expand Up @@ -139,7 +139,7 @@ private:

void main()
{
import KissRpc.Logs;
import kissrpc.Logs;
auto poll = new GroupPoll!();
auto client = new ClientSocket;
client.connectToServer(poll);
Expand Down
2 changes: 1 addition & 1 deletion IDL-Example/server/source/IDL/flatbuffer/kissidl.d
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// automatically generated by the FlatBuffers compiler, do not modify

module KissRpc.IDL.flatbuffer.kissidl;
module kissrpc.IDL.flatbuffer.kissidl;

import std.typecons;
import flatbuffers;
Expand Down
2 changes: 1 addition & 1 deletion IDL-Example/server/source/IDL/flatbuffer/kissidl.fbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace KissRpc.IDL.flatbuffer;
namespace kissrpc.IDL.flatbuffer;

table UserInfoFB{
name:string;
Expand Down
16 changes: 8 additions & 8 deletions IDL-Example/server/source/IDL/kissidlInterface.d
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
module KissRpc.IDL.kissidlInterface;
module kissrpc.IDL.kissidlInterface;

import KissRpc.IDL.kissidlMessage;
import KissRpc.IDL.kissidlService;
import kissrpc.IDL.kissidlMessage;
import kissrpc.IDL.kissidlService;

import KissRpc.RpcServer;
import KissRpc.RpcServerImpl;
import KissRpc.RpcResponse;
import KissRpc.RpcRequest;
import kissrpc.RpcServer;
import kissrpc.RpcServerImpl;
import kissrpc.RpcResponse;
import kissrpc.RpcRequest;
import flatbuffers;
import KissRpc.IDL.flatbuffer.kissidl;
import kissrpc.IDL.flatbuffer.kissidl;

abstract class RpcAddressBookInterface{

Expand Down
2 changes: 1 addition & 1 deletion IDL-Example/server/source/IDL/kissidlMessage.d
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module KissRpc.IDL.kissidlMessage;
module kissrpc.IDL.kissidlMessage;
import std.typetuple;


Expand Down
10 changes: 5 additions & 5 deletions IDL-Example/server/source/IDL/kissidlService.d
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module KissRpc.IDL.kissidlService;
module kissrpc.IDL.kissidlService;

import KissRpc.IDL.kissidlInterface;
import KissRpc.IDL.kissidlMessage;
import kissrpc.IDL.kissidlInterface;
import kissrpc.IDL.kissidlMessage;

import KissRpc.RpcServer;
import KissRpc.Unit;
import kissrpc.RpcServer;
import kissrpc.Unit;
import std.conv;

class RpcAddressBookService: RpcAddressBookInterface{
Expand Down
10 changes: 5 additions & 5 deletions IDL-Example/server/source/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import std.stdio;
import std.conv;

import KissRpc.Unit;
import KissRpc.Logs;
import KissRpc.RpcServer;
import KissRpc.RpcSocketBaseInterface;
import kissrpc.Unit;
import kissrpc.Logs;
import kissrpc.RpcServer;
import kissrpc.RpcSocketBaseInterface;

import kiss.event.GroupPoll;
import std.traits;
Expand Down Expand Up @@ -46,7 +46,7 @@ class ServerSocket : ServerSocketEventInterface
void main(string[] args)
{

import KissRpc.IDL.kissidlService;
import kissrpc.IDL.kissidlService;

auto rpServer = new RpcServer(new ServerSocket);
auto address_book_service = new RpcAddressBookService(rpServer);
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ string | string
* import hander files

```
import KissRpc.IDL.kissidlService;
import KissRpc.IDL.kissidlMessage;
import KissRpc.Unit;
import kissrpc.IDL.kissidlService;
import kissrpc.IDL.kissidlMessage;
import kissrpc.Unit;
```


Expand Down
Binary file modified kiss-rpc-idl/KissRpcIdl
Binary file not shown.
6 changes: 3 additions & 3 deletions kiss-rpc-idl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ string | string
* import hander files

```
import KissRpc.IDL.kissidlService;
import KissRpc.IDL.kissidlMessage;
import KissRpc.Unit;
import kissrpc.IDL.kissidlService;
import kissrpc.IDL.kissidlMessage;
import kissrpc.Unit;
```


Expand Down
13 changes: 13 additions & 0 deletions kiss-rpc-idl/TestRpc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

//kiss rpc idl demo

@message:UserInfo
{
int i:1;
string name:2;
}

@service:Test
{
UserInfo getName(UserInfo userInfo);
}
30 changes: 30 additions & 0 deletions kiss-rpc-idl/kiss-idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

//kiss rpc idl demo



@message:UserInfo
{
string name:1;
int age:2;
double widget:3;
}

@message:Contacts
{
int number:1;
UserInfo[] userInfoList:2;
}


@message:AccountName
{
string name:1;
int count:2;
}

@service:AddressBook //接口类
{
Contacts getContactList(AccountName accountName);
}

111 changes: 111 additions & 0 deletions kiss-rpc-idl/kissrpc/generated/client/TestRpcInterface.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
module kissrpc.generated.TestRpcInterface;

import kissrpc.generated.TestRpcMessage;
import kissrpc.generated.TestRpcService;

import kissrpc.RpcRequest;
import kissrpc.RpcClientImpl;
import kissrpc.RpcClient;
import kissrpc.RpcResponse;
import kissrpc.Unit;
import flatbuffers;
import kissrpc.generated.message.TestRpc;

abstract class RpcTestInterface{

this(RpcClient rpClient){
rpImpl = new RpcClientImpl!(RpcTestService)(rpClient);
}

UserInfo getNameInterface(const UserInfo userInfo, const RPC_PACKAGE_COMPRESS_TYPE compressType, const int secondsTimeOut, const size_t funcId = 2791659981){

auto builder = new FlatBufferBuilder(512);

//input flatbuffer code for UserInfoFB class




auto userInfoPos = UserInfoFB.createUserInfoFB(builder, userInfo.i, builder.createString(userInfo.name), );


builder.finish(userInfoPos);

auto req = new RpcRequest(compressType, secondsTimeOut);

req.push(builder.sizedByteArray);

RpcResponse resp = rpImpl.syncCall(req, RPC_PACKAGE_PROTOCOL.TPP_FLAT_BUF, funcId);

if(resp.getStatus == RESPONSE_STATUS.RS_OK){

ubyte[] flatBufBytes;
resp.pop(flatBufBytes);

auto ret_UserInfoFB = UserInfoFB.getRootAsUserInfoFB(new ByteBuffer(flatBufBytes));
UserInfo ret_UserInfo;

//input flatbuffer code for UserInfoFB class




ret_UserInfo.i = ret_UserInfoFB.i;
ret_UserInfo.name = ret_UserInfoFB.name;


return ret_UserInfo;
}else{
throw new Exception("rpc sync call error, function:" ~ RpcBindFunctionMap[funcId]);
}
}


alias RpcgetNameCallback = void delegate(UserInfo);

void getNameInterface(const UserInfo userInfo, RpcgetNameCallback rpcCallback, const RPC_PACKAGE_COMPRESS_TYPE compressType, const int secondsTimeOut, const size_t funcId = 2791659981){

auto builder = new FlatBufferBuilder(512);
//input flatbuffer code for UserInfoFB class




auto userInfoPos = UserInfoFB.createUserInfoFB(builder, userInfo.i, builder.createString(userInfo.name), );


builder.finish(userInfoPos);
auto req = new RpcRequest(compressType, secondsTimeOut);

req.push(builder.sizedByteArray);

rpImpl.asyncCall(req, delegate(RpcResponse resp){

if(resp.getStatus == RESPONSE_STATUS.RS_OK){

ubyte[] flatBufBytes;
UserInfo ret_UserInfo;

resp.pop(flatBufBytes);

auto ret_UserInfoFB = UserInfoFB.getRootAsUserInfoFB(new ByteBuffer(flatBufBytes));
//input flatbuffer code for UserInfoFB class




ret_UserInfo.i = ret_UserInfoFB.i;
ret_UserInfo.name = ret_UserInfoFB.name;


rpcCallback(ret_UserInfo);
}else{
throw new Exception("rpc sync call error, function:" ~ RpcBindFunctionMap[funcId]);
}}, RPC_PACKAGE_PROTOCOL.TPP_FLAT_BUF, funcId);
}


RpcClientImpl!(RpcTestService) rpImpl;
}


34 changes: 34 additions & 0 deletions kiss-rpc-idl/kissrpc/generated/client/TestRpcService.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module kissrpc.generated.TestRpcService;


import kissrpc.generated.TestRpcInterface;
import kissrpc.generated.TestRpcMessage;

import kissrpc.RpcClient;
import kissrpc.Unit;


class RpcTestService: RpcTestInterface{

this(RpcClient rpClient){
RpcBindFunctionMap[2791659981] = typeid(&RpcTestService.getName).toString();
super(rpClient);
}

UserInfo getName(UserInfo userInfo, const RPC_PACKAGE_COMPRESS_TYPE compressType = RPC_PACKAGE_COMPRESS_TYPE.RPCT_NO, const int secondsTimeOut = RPC_REQUEST_TIMEOUT_SECONDS){

UserInfo ret = super.getNameInterface(userInfo, compressType, secondsTimeOut);
return ret;
}


void getName(UserInfo userInfo, RpcgetNameCallback rpcCallback, const RPC_PACKAGE_COMPRESS_TYPE compressType = RPC_PACKAGE_COMPRESS_TYPE.RPCT_NO, const int secondsTimeOut = RPC_REQUEST_TIMEOUT_SECONDS){

super.getNameInterface(userInfo, rpcCallback, compressType, secondsTimeOut);
}


}



Loading

0 comments on commit 1c3e637

Please sign in to comment.