Пример #1
0
        public WebSocket(PushBulletClient client, PushBulletClientConfig config, JsonSerializer serializer)
        {
            _socket = new CasinoSocket();
            _socket.MessageReceived += MessageReceived;

            _client     = client;
            _config     = config;
            _serializer = serializer;
        }
Пример #2
0
        public PushBulletClient(PushBulletClientConfig config)
        {
            if (string.IsNullOrWhiteSpace(config.Token))
            {
                throw new NoNullAllowedException("Token can't be null or empty");
            }

            _config     = config;
            _serializer = new JsonSerializer();

            _devices = new ConcurrentDictionary <string, Device>();
            _pushes  = new ConcurrentDictionary <string, Push>();

            RequestClient = new RequestClient(this, _config, _serializer);
        }
Пример #3
0
        public RequestClient(PushBulletClient client, PushBulletClientConfig config, JsonSerializer serializer)
        {
            _client = client;

            _http = new HttpClient
            {
                BaseAddress = new Uri(config.ApiBaseUrl)
            };

            _http.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            _http.DefaultRequestHeaders.Add("Access-Token", config.Token);

            _serializer = serializer;
            _semaphore  = new SemaphoreSlim(1, 1);
        }