コード例 #1
0
 private async Task SendVoidRequest(ModuleMsg 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>(ModuleMsg requestMsg)
 {
     if (connection == null)
     {
         throw new Exception("ExternalModule.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($"ExternalModule.SendRequest {requestMsg.GetType().Name}: returned result is null"));
         }
         else
         {
             throw new Exception(res.ErrorMsg);
         }
     }
 }