예제 #1
0
        public JsonContent(T data, IContractSerializer contractSerializer)
        {
            this.data = data ?? throw new ArgumentNullException(nameof(data));
            this.contractSerializer = contractSerializer ?? throw new ArgumentNullException(nameof(contractSerializer));

            Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(contractSerializer.ContentType);
        }
예제 #2
0
 public MultiplexTelemetryChannel(
     IContractSerializer contractSerializer,
     ProcessTelemetryRequest executeRequestDelegate,
     ProcessTelemetryEvent handleEventDelegate,
     ITelemetryStreamConnectionSource connectionSource,
     ITelemetryStreamConnectionSink connectionSink)
     : base(
         contractSerializer,
         connectionSource,
         connectionSink,
        public TelemetryServer(IPEndPoint listenerEndpoint,
                               ProcessTelemetryRequest processTelemetryRequest,
                               ProcessTelemetryEvent processTelemetryEvent,
                               IContractSerializer contractSerializer)
        {
            _processTelemetryRequest = processTelemetryRequest;
            _processTelemetryEvent   = processTelemetryEvent;
            _contractSerializer      = contractSerializer;
            _packageWrapper          = new TelemetryPackageWrapper(contractSerializer);

            listener = new Socket(listenerEndpoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
            listener.Bind(listenerEndpoint);
            listener.Listen(Environment.ProcessorCount * 2);

            incomingConnectionListener = new MultiThreadProcessor(ThreadPriority.Highest, HandleSocketConnection);
        }
예제 #4
0
        public TelemetryClient(IPEndPoint endPoint,
                               ProcessTelemetryRequest processTelemetryRequest,
                               ProcessTelemetryEvent processTelemetryEvent,
                               IContractSerializer contractSerializer,
                               ITelemetryCryptoProvider cryptoProvider)
        {
            _processTelemetryRequest = processTelemetryRequest;
            _processTelemetryEvent   = processTelemetryEvent;
            _contractSerializer      = contractSerializer;
            _cryptoProvider          = cryptoProvider;
            _endPoint = endPoint;

            Channel = new MultiplexTelemetryChannel(
                contractSerializer,
                processTelemetryRequest,
                processTelemetryEvent,
                new MultiplexInputSource(channelResources.GetResource, cryptoProvider),
                new MultiplexOutputSink(channelResources.GetResource, cryptoProvider));

            Connect();
        }
예제 #5
0
 public RemoteTaskService(HttpClient httpClient, IContractSerializer contractSerializer)
 {
     this.httpClient         = httpClient ?? throw new ArgumentNullException(nameof(httpClient));
     this.contractSerializer = contractSerializer ?? throw new ArgumentNullException(nameof(contractSerializer));
 }
 public TelemetryPackageWrapper(IContractSerializer modelSerializer)
 {
     _modelSerializer = modelSerializer;
 }
 public static JsonContent <T> CreateJsonContent <T>(this IContractSerializer contractSerializer, T data)
     where T : class
 {
     return(new JsonContent <T>(data, contractSerializer));
 }
 public static async Task <T> DeserializeHttpResponseAsync <T>(this IContractSerializer contractSerializer, HttpResponseMessage response)
 {
     return(contractSerializer.Deserialize <T>(await response.Content.ReadAsStreamAsync(), false));
 }