public async Task <List <AppleFeedback> > Feedback() { Task <List <AppleFeedback> > readTask; using (var connection = new Internal.APNSConnection()) { await connection.Connect(Development? "feedback.sandbox.push.apple.com" : "feedback.push.apple.com", 2196, ClientCertificate, 30 * 1000); readTask = _feedbackReadResponse(connection); using (CancellationTokenSource cts = new CancellationTokenSource(15000)) await Task.WhenAny(readTask, Task.Delay(-1, cts.Token)); } await readTask; return(readTask.Result); }
public async Task ConnectAsync() { _connection = new APNSConnection(); string hostname = Config.Development ? "gateway.sandbox.push.apple.com" : "gateway.push.apple.com"; try { await _connection.Connect(hostname, 2195, Config.ClientCertificate, 30 * 1000); } catch (Exception err) { throw new PushNotificationConnectionException("connect(" + hostname + "): failed.", err); } lock (_lockObject) { _isAvailable = _connection.Connected; _notifications = new List <Notification>(Config.RecyleCount); if (_isAvailable) { _receiveTask = Task.Run(_receiveResponceAsync); _connectionTimer = new Timer(_connectionTimer_callback, null, Config.RecyleTimout, Timeout.Infinite); } } }