/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { PutFileResponse response = new PutFileResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("blobId", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.BlobId = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("commitId", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.CommitId = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("treeId", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.TreeId = unmarshaller.Unmarshall(context); continue; } } return(response); }
private async Task <PutResult> PutFileAsync( Context context, HashType hashType, AbsolutePath path, FileRealizationMode realizationMode, int sessionId) { DateTime startTime = DateTime.UtcNow; PutFileResponse response = await RunClientActionAndThrowIfFailedAsync(context, async() => await _client.PutFileAsync( new PutFileRequest { Header = new RequestHeader(context.Id, sessionId), ContentHash = ByteString.Empty, HashType = (int)hashType, FileRealizationMode = (int)realizationMode, Path = path.Path })); long ticksWaited = response.Header.ServerReceiptTimeUtcTicks - startTime.Ticks; _tracer.TrackClientWaitForServerTicks(ticksWaited); if (!response.Header.Succeeded) { await ResetOnUnknownSessionAsync(context, response.Header, sessionId); return(new PutResult(new ContentHash(hashType), response.Header.ErrorMessage, response.Header.Diagnostics)); } else { return(new PutResult(response.ContentHash.ToContentHash((HashType)response.HashType), response.ContentSize)); } }
private static void SocketServer_NewDataReceived(WebSocketSession session, byte[] value) { try { var request = WebSocketBlockWrite.ByteToPutFileRequest(value); switch (request.RequestType) { case WebSocketRequestType.PutFileRequest: PutFileResponse putFileResponse = new PutFileResponse { RequestId = request.RequestId, ExecuteSuccess = true }; session.Send(JsonConvert.SerializeObject(putFileResponse)); //var data = WebSocketBlockWrite.PutFileResponseToByte(putFileResponse); //session.Send(data, 0, data.Length); break; } } catch (Exception ex) { Console.WriteLine(ex); } }