-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Your Name
committed
Jul 17, 2017
1 parent
ba26278
commit 966704e
Showing
15 changed files
with
203 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
module KissRpc.IDL.kiss-testInterface; | ||
|
||
import KissRpc.IDL.kiss-testMessage; | ||
import KissRpc.IDL.kiss-testService; | ||
|
||
import KissRpc.RpcRequest; | ||
import KissRpc.RpcClientImpl; | ||
import KissRpc.RpcClient; | ||
import KissRpc.RpcResponse; | ||
import KissRpc.Unit; | ||
|
||
abstract class RpcAddressBookInterface{ | ||
|
||
this(RpcClient rpClient){ | ||
rpImpl = new RpcClientImpl!(RpcAddressBookService)(rpClient); | ||
} | ||
|
||
contacts getContactListInterface(string accountName, const RPC_PACKAGE_COMPRESS_TYPE compressType, const int secondsTimeOut, string bindFunc = __FUNCTION__){ | ||
|
||
auto req = new RpcRequest(compressType, secondsTimeOut); | ||
|
||
req.push(accountName); | ||
|
||
RpcResponse resp = rpImpl.syncCall(req, bindFunc); | ||
|
||
if(resp.getStatus == RESPONSE_STATUS.RS_OK){ | ||
contacts ret_contacts; | ||
|
||
resp.pop(ret_contacts); | ||
|
||
return ret_contacts; | ||
}else{ | ||
throw new Exception("rpc sync call error, function:" ~ bindFunc); | ||
} | ||
} | ||
|
||
|
||
alias RpcgetContactListCallback = void delegate(contacts); | ||
|
||
void getContactListInterface(string accountName, RpcgetContactListCallback rpcCallback, const RPC_PACKAGE_COMPRESS_TYPE compressType, const int secondsTimeOut, string bindFunc = __FUNCTION__){ | ||
|
||
auto req = new RpcRequest(compressType, secondsTimeOut); | ||
|
||
req.push(accountName); | ||
|
||
rpImpl.asyncCall(req, delegate(RpcResponse resp){ | ||
|
||
if(resp.getStatus == RESPONSE_STATUS.RS_OK){ | ||
|
||
contacts ret_contacts; | ||
|
||
resp.pop(ret_contacts); | ||
|
||
rpcCallback(ret_contacts); | ||
}else{ | ||
throw new Exception("rpc sync call error, function:" ~ bindFunc); | ||
}}, bindFunc); | ||
} | ||
|
||
|
||
RpcClientImpl!(RpcAddressBookService) rpImpl; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
module KissRpc.IDL.kiss-testMessage; | ||
import std.typetuple; | ||
|
||
|
||
struct UserInfo{ | ||
|
||
string[] addressList; | ||
double wiget; | ||
string phone; | ||
int age; | ||
string userName; | ||
|
||
TypeTuple!(string[], double, string, int, string, ) memberList; | ||
|
||
void createTypeTulple(){ | ||
|
||
memberList[0] = addressList; | ||
memberList[1] = wiget; | ||
memberList[2] = phone; | ||
memberList[3] = age; | ||
memberList[4] = userName; | ||
} | ||
|
||
void restoreTypeTunlp(){ | ||
|
||
addressList = memberList[0]; | ||
wiget = memberList[1]; | ||
phone = memberList[2]; | ||
age = memberList[3]; | ||
userName = memberList[4]; | ||
} | ||
|
||
} | ||
|
||
|
||
struct contacts{ | ||
|
||
UserInfo[] userInfoList; | ||
int number; | ||
|
||
TypeTuple!(UserInfo[], int, ) memberList; | ||
|
||
void createTypeTulple(){ | ||
|
||
memberList[0] = userInfoList; | ||
memberList[1] = number; | ||
} | ||
|
||
void restoreTypeTunlp(){ | ||
|
||
userInfoList = memberList[0]; | ||
number = memberList[1]; | ||
} | ||
|
||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module KissRpc.IDL.kiss-testService; | ||
|
||
|
||
import KissRpc.IDL.kiss-testInterface; | ||
import KissRpc.IDL.kiss-testMessage; | ||
|
||
import KissRpc.RpcClient; | ||
import KissRpc.Unit; | ||
|
||
class RpcAddressBookService: RpcAddressBookInterface{ | ||
|
||
this(RpcClient rpClient){ | ||
super(rpClient); | ||
} | ||
|
||
contacts getContactList(string accountName, const RPC_PACKAGE_COMPRESS_TYPE compressType = RPC_PACKAGE_COMPRESS_TYPE.RPCT_NO, const int secondsTimeOut = RPC_REQUEST_TIMEOUT_SECONDS){ | ||
|
||
contacts ret = super.getContactListInterface(accountName, compressType, secondsTimeOut); | ||
return ret; | ||
} | ||
|
||
|
||
void getContactList(string accountName, RpcgetContactListCallback rpcCallback, const RPC_PACKAGE_COMPRESS_TYPE compressType = RPC_PACKAGE_COMPRESS_TYPE.RPCT_NO, const int secondsTimeOut = RPC_REQUEST_TIMEOUT_SECONDS){ | ||
|
||
super.getContactListInterface(accountName, rpcCallback, compressType, secondsTimeOut); | ||
} | ||
|
||
|
||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.