public TCompactProtocol(TClientTransport trans) : base(trans) { TTypeToCompactType[(int) TType.Stop] = Types.Stop; TTypeToCompactType[(int) TType.Bool] = Types.BooleanTrue; TTypeToCompactType[(int) TType.Byte] = Types.Byte; TTypeToCompactType[(int) TType.I16] = Types.I16; TTypeToCompactType[(int) TType.I32] = Types.I32; TTypeToCompactType[(int) TType.I64] = Types.I64; TTypeToCompactType[(int) TType.Double] = Types.Double; TTypeToCompactType[(int) TType.String] = Types.Binary; TTypeToCompactType[(int) TType.List] = Types.List; TTypeToCompactType[(int) TType.Set] = Types.Set; TTypeToCompactType[(int) TType.Map] = Types.Map; TTypeToCompactType[(int) TType.Struct] = Types.Struct; }
public Task ProcessContextAsync(object serverContext, TClientTransport transport, CancellationToken cancellationToken) { callCount++; return Task.CompletedTask; }
public ITAsyncProcessor GetAsyncProcessor(TClientTransport trans, TBaseServer baseServer = null) { return _tAsyncProcessor; }
public TProtocol GetProtocol(TClientTransport trans) { return new TJsonProtocol(trans); }
/// <summary> /// TJsonProtocol Constructor /// </summary> public TJsonProtocol(TClientTransport trans) : base(trans) { //throw new NotImplementedException("TJsonProtocol is not fully ready for usage"); Context = new JsonBaseContext(this); Reader = new LookaheadReader(this); }
public TProtocol GetProtocol(TClientTransport trans) { return new TCompactProtocol(trans); }
private static TProtocol GetProtocol(string[] args, TClientTransport transport) { var protocol = args.FirstOrDefault(x => x.StartsWith("-p"))?.Split(':')?[1]; Protocol selectedProtocol; if (Enum.TryParse(protocol, true, out selectedProtocol)) { switch (selectedProtocol) { case Protocol.Binary: return new TBinaryProtocol(transport); case Protocol.Compact: return new TCompactProtocol(transport); case Protocol.Json: return new TJsonProtocol(transport); } } return new TBinaryProtocol(transport); }
private async Task Execute(TClientTransport client, CancellationToken cancellationToken) { Logger.LogTrace("Started client request processing"); var processor = ItProcessorFactory.GetAsyncProcessor(client, this); TClientTransport inputTransport = null; TClientTransport outputTransport = null; TProtocol inputProtocol = null; TProtocol outputProtocol = null; object connectionContext = null; try { inputTransport = InputTransportFactory.GetTransport(client); outputTransport = OutputTransportFactory.GetTransport(client); inputProtocol = InputProtocolFactory.GetProtocol(inputTransport); outputProtocol = OutputProtocolFactory.GetProtocol(outputTransport); if (ServerEventHandler != null) { connectionContext = await ServerEventHandler.CreateContextAsync(inputProtocol, outputProtocol, cancellationToken); } while (!cancellationToken.IsCancellationRequested) { if (!await inputTransport.PeekAsync(cancellationToken)) { break; } if (ServerEventHandler != null) { await ServerEventHandler.ProcessContextAsync(connectionContext, inputTransport, cancellationToken); } if (!await processor.ProcessAsync(inputProtocol, outputProtocol, cancellationToken)) { break; } } } catch (TTransportException ttx) { Logger.LogTrace($"Transport exception: {ttx}"); } catch (Exception x) { Logger.LogError($"Error: {x}"); } if (ServerEventHandler != null) { await ServerEventHandler.DeleteContextAsync(connectionContext, inputProtocol, outputProtocol, cancellationToken); } inputTransport?.Close(); outputTransport?.Close(); Logger.LogTrace("Completed client request processing"); }
public ClientTest(TestParams param) { transport = param.CreateTransport(); client = new ThriftAsync.Test.ThriftTest.Client(param.CreateProtocol(transport)); numIterations = param.numIterations; }
public TProtocol CreateProtocol(TClientTransport transport) { if (protocol == "compact") { return new TCompactProtocol(transport); } if (protocol == "json") { return new TJsonProtocol(transport); } return new TBinaryProtocol(transport); }
public TProtocol GetProtocol(TClientTransport trans) { return new TBinaryProtocol(trans, StrictRead, StrictWrite); }
public TBinaryProtocol(TClientTransport trans, bool strictRead, bool strictWrite) : base(trans) { StrictRead = strictRead; StrictWrite = strictWrite; }
public TBinaryProtocol(TClientTransport trans) : this(trans, false, true) { }