// Server IPC Cycle. // Receive a request. Service the request. Reply with the result. static public async Task <int> ReceiveServiceReply(BufferedStream bufferedStream, IServiceRequest serviceRequest, ILogger logger, IAppDocument appDocument) { int numberSent; // Receive the request from the client. ITcpFrame requestFrame = await ReceiveFrame(bufferedStream, logger); // Identify and create the specific service to be performed. IPerformService performService = serviceRequest.CreateService(requestFrame, logger); // Perform the specific service and provide a response. ITcpFrame responseFrame = performService.PerformService(logger, appDocument); // Reply the response to the client. numberSent = await SendFrame(responseFrame, bufferedStream, logger); return(numberSent); }