예제 #1
0
 private async Task SendVoidRequest(AdapterMsg requestMsg)
 {
     using (Response res = await connection.SendRequest(requestMsg.GetMessageCode(), stream => StdJson.ObjectToStream(requestMsg, stream))) {
         if (res.Success)
         {
             return;
         }
         else
         {
             throw new Exception(res.ErrorMsg);
         }
     }
 }
예제 #2
0
 private async Task <T> SendRequest <T>(AdapterMsg requestMsg)
 {
     if (connection == null)
     {
         throw new Exception("ExternalAdapter.SendRequest: connection is null");
     }
     using (Response res = await connection.SendRequest(requestMsg.GetMessageCode(), stream => StdJson.ObjectToStream(requestMsg, stream))) {
         if (res.Success)
         {
             return(StdJson.ObjectFromUtf8Stream <T>(res.SuccessPayload !) ?? throw new Exception($"ExternalAdapter.SendRequest {requestMsg.GetType().Name}: returned result is null"));
         }
         else
         {
             throw new Exception(res.ErrorMsg);
         }
     }
 }