コード例 #1
0
ファイル: AsyncCall.cs プロジェクト: tempbottle/grpc
        /// <summary>
        /// On client-side, we only fire readCompletionDelegate once all messages have been read
        /// and status has been received.
        /// </summary>
        protected override void ProcessLastRead(AsyncCompletionDelegate <TResponse> completionDelegate)
        {
            if (completionDelegate != null && readingDone && finishedStatus.HasValue)
            {
                bool shouldComplete;
                lock (myLock)
                {
                    shouldComplete        = !readObserverCompleted;
                    readObserverCompleted = true;
                }

                if (shouldComplete)
                {
                    var status = finishedStatus.Value.Status;
                    if (status.StatusCode != StatusCode.OK)
                    {
                        FireCompletion(completionDelegate, default(TResponse), new RpcException(status));
                    }
                    else
                    {
                        FireCompletion(completionDelegate, default(TResponse), null);
                    }
                }
            }
        }
コード例 #2
0
ファイル: AsyncCallBase.cs プロジェクト: xiexiemanyou/grpc
        /// <summary>
        /// Handles streaming read completion.
        /// </summary>
        protected void HandleReadFinished(bool success, byte[] receivedMessage)
        {
            AsyncCompletionDelegate <TRead> origCompletionDelegate = null;

            lock (myLock)
            {
                origCompletionDelegate = readCompletionDelegate;
                readCompletionDelegate = null;

                if (receivedMessage == null)
                {
                    // This was the last read.
                    readingDone = true;
                }

                ReleaseResourcesIfPossible();
            }

            // TODO: handle the case when error occured...

            if (receivedMessage != null)
            {
                // TODO: handle deserialization error
                TRead msg;
                TryDeserialize(receivedMessage, out msg);

                FireCompletion(origCompletionDelegate, msg, null);
            }
            else
            {
                FireCompletion(origCompletionDelegate, default(TRead), null);
            }
        }
コード例 #3
0
 public void GetEventsAsync(int year, int month, AsyncCompletionDelegate resultDelegate)
 {
     List<StableSession.YearMonth> months = new List<StableSession.YearMonth>
     {
         new StableSession.YearMonth() { Year = year, Month = month }
     };
     GetEventsAsync(months, resultDelegate);
 }
コード例 #4
0
 protected void FireCompletion <T>(AsyncCompletionDelegate <T> completionDelegate, T value, Exception error)
 {
     try
     {
         completionDelegate(value, error);
     }
     catch (Exception e)
     {
         Console.WriteLine("Exception occured while invoking completion delegate: " + e);
     }
 }
コード例 #5
0
ファイル: AsyncCallBase.cs プロジェクト: muisaja7/grpc
        /// <summary>
        /// Initiates reading a message. Only one read operation can be active at a time.
        /// completionDelegate is invoked upon completion.
        /// </summary>
        protected void StartReadMessageInternal(AsyncCompletionDelegate <TRead> completionDelegate)
        {
            lock (myLock)
            {
                Preconditions.CheckNotNull(completionDelegate, "Completion delegate cannot be null");
                CheckReadingAllowed();

                call.StartReceiveMessage(HandleReadFinished);
                readCompletionDelegate = completionDelegate;
            }
        }
コード例 #6
0
 protected void FireCompletion <T>(AsyncCompletionDelegate <T> completionDelegate, T value, Exception error)
 {
     try
     {
         completionDelegate(value, error);
     }
     catch (Exception e)
     {
         Logger.Error(e, "Exception occured while invoking completion delegate.");
     }
 }
コード例 #7
0
ファイル: AsyncCallBase.cs プロジェクト: cj525/grpc
        /// <summary>
        /// Initiates reading a message. Only one read operation can be active at a time.
        /// completionDelegate is invoked upon completion.
        /// </summary>
        protected void StartReadMessageInternal(AsyncCompletionDelegate <TRead> completionDelegate)
        {
            lock (myLock)
            {
                Preconditions.CheckNotNull(completionDelegate, "Completion delegate cannot be null");
                CheckReadingAllowed();

                // I feel like a prerequisite variable should be set before entering that code path
                readCompletionDelegate = completionDelegate;
                call.StartReceiveMessage(HandleReadFinished);
            }
        }
コード例 #8
0
        /// <summary>
        /// Sends call result status, also indicating server is done with streaming responses.
        /// Only one pending send action is allowed at any given time.
        /// completionDelegate is called when the operation finishes.
        /// </summary>
        public void StartSendStatusFromServer(Status status, AsyncCompletionDelegate <object> completionDelegate)
        {
            lock (myLock)
            {
                Preconditions.CheckNotNull(completionDelegate, "Completion delegate cannot be null");
                CheckSendingAllowed();

                call.StartSendStatusFromServer(status, halfclosedHandler);
                halfcloseRequested     = true;
                sendCompletionDelegate = completionDelegate;
            }
        }
コード例 #9
0
ファイル: AsyncCall.cs プロジェクト: tempbottle/grpc
        /// <summary>
        /// Sends halfclose, indicating client is done with streaming requests.
        /// Only one pending send action is allowed at any given time.
        /// completionDelegate is called when the operation finishes.
        /// </summary>
        public void StartSendCloseFromClient(AsyncCompletionDelegate <object> completionDelegate)
        {
            lock (myLock)
            {
                Preconditions.CheckNotNull(completionDelegate, "Completion delegate cannot be null");
                CheckSendingAllowed();

                call.StartSendCloseFromClient(HandleHalfclosed);

                halfcloseRequested     = true;
                sendCompletionDelegate = completionDelegate;
            }
        }
コード例 #10
0
        public void GetPendingEventsAsync(AsyncCompletionDelegate resultDelegate)
        {
            StableSession.Instance.GetPendingEventsAsync((events, reason) =>
            {
                PendingEvents = events;

                if (resultDelegate != null)
                    resultDelegate(events != null, reason);

                if (events != null)
                    OnPendingEventsChanged();
            });
        }
コード例 #11
0
        /// <summary>
        /// Initiates sending a message. Only one send operation can be active at a time.
        /// completionDelegate is invoked upon completion.
        /// </summary>
        protected void StartSendMessageInternal(TWrite msg, AsyncCompletionDelegate <object> completionDelegate)
        {
            byte[] payload = UnsafeSerialize(msg);

            lock (myLock)
            {
                Preconditions.CheckNotNull(completionDelegate, "Completion delegate cannot be null");
                CheckSendingAllowed();

                call.StartSendMessage(payload, HandleSendFinished);
                sendCompletionDelegate = completionDelegate;
            }
        }
コード例 #12
0
        /// <summary>
        /// Sends call result status, also indicating server is done with streaming responses.
        /// Only one pending send action is allowed at any given time.
        /// completionDelegate is called when the operation finishes.
        /// </summary>
        public void StartSendStatusFromServer(Status status, Metadata trailers, AsyncCompletionDelegate <object> completionDelegate)
        {
            lock (myLock)
            {
                Preconditions.CheckNotNull(completionDelegate, "Completion delegate cannot be null");
                CheckSendingAllowed();

                using (var metadataArray = MetadataArraySafeHandle.Create(trailers))
                {
                    call.StartSendStatusFromServer(HandleHalfclosed, status, metadataArray, !initialMetadataSent);
                }
                halfcloseRequested     = true;
                readingDone            = true;
                sendCompletionDelegate = completionDelegate;
            }
        }
コード例 #13
0
        /// <summary>
        /// Initiates sending a message. Only one send operation can be active at a time.
        /// completionDelegate is invoked upon completion.
        /// </summary>
        protected void StartSendMessageInternal(TWrite msg, WriteFlags writeFlags, AsyncCompletionDelegate <object> completionDelegate)
        {
            byte[] payload = UnsafeSerialize(msg);

            lock (myLock)
            {
                GrpcPreconditions.CheckNotNull(completionDelegate, "Completion delegate cannot be null");
                CheckSendingAllowed(allowFinished: false);

                call.StartSendMessage(HandleSendFinished, payload, writeFlags, !initialMetadataSent);

                sendCompletionDelegate = completionDelegate;
                initialMetadataSent    = true;
                streamingWritesCounter++;
            }
        }
コード例 #14
0
        public void GetMailAsync(AsyncCompletionDelegate resultDelegate)
        {
            LoadingMail = true;

            StableSession.Instance.GetMailAsync((messages, reason) =>
            {
                Messages = messages;
                LoadingMail = false;

                if (resultDelegate != null)
                    resultDelegate(Messages != null, reason);

                OnMessagesChanged();
                OnUnreadCountChanged();
            });
        }
コード例 #15
0
ファイル: AsyncCall.cs プロジェクト: tempbottle/grpc
        /// <summary>
        /// Handles receive status completion for calls with streaming response.
        /// </summary>
        private void HandleFinished(bool success, BatchContextSafeHandle ctx)
        {
            var fullStatus = ctx.GetReceivedStatusOnClient();

            AsyncCompletionDelegate <TResponse> origReadCompletionDelegate = null;

            lock (myLock)
            {
                finished       = true;
                finishedStatus = fullStatus;

                origReadCompletionDelegate = readCompletionDelegate;

                ReleaseResourcesIfPossible();
            }

            ProcessLastRead(origReadCompletionDelegate);
        }
コード例 #16
0
ファイル: AsyncCall.cs プロジェクト: varung/grpc
        /// <summary>
        /// Handles receive status completion for calls with streaming response.
        /// </summary>
        private void HandleFinished(bool wasError, BatchContextSafeHandleNotOwned ctx)
        {
            var status = ctx.GetReceivedStatus();

            AsyncCompletionDelegate <TResponse> origReadCompletionDelegate = null;

            lock (myLock)
            {
                finished       = true;
                finishedStatus = status;

                origReadCompletionDelegate = readCompletionDelegate;

                ReleaseResourcesIfPossible();
            }

            ProcessLastRead(origReadCompletionDelegate);
        }
コード例 #17
0
ファイル: AsyncCallBase.cs プロジェクト: muisaja7/grpc
        /// <summary>
        /// Handles send completion.
        /// </summary>
        protected void HandleSendFinished(bool success, BatchContextSafeHandle ctx)
        {
            AsyncCompletionDelegate <object> origCompletionDelegate = null;

            lock (myLock)
            {
                origCompletionDelegate = sendCompletionDelegate;
                sendCompletionDelegate = null;

                ReleaseResourcesIfPossible();
            }

            if (!success)
            {
                FireCompletion(origCompletionDelegate, null, new InvalidOperationException("Send failed"));
            }
            else
            {
                FireCompletion(origCompletionDelegate, null, null);
            }
        }
コード例 #18
0
ファイル: AsyncCallBase.cs プロジェクト: zen-li/grpc
        /// <summary>
        /// Handles send status from server completion.
        /// </summary>
        protected void HandleSendStatusFromServerFinished(bool success)
        {
            AsyncCompletionDelegate <object> origCompletionDelegate = null;

            lock (myLock)
            {
                origCompletionDelegate = sendCompletionDelegate;
                sendCompletionDelegate = null;

                ReleaseResourcesIfPossible();
            }

            if (!success)
            {
                FireCompletion(origCompletionDelegate, null, new InvalidOperationException("Error sending status from server."));
            }
            else
            {
                FireCompletion(origCompletionDelegate, null, null);
            }
        }
コード例 #19
0
ファイル: AsyncCallBase.cs プロジェクト: wfarr/grpc
        /// <summary>
        /// Handles send completion.
        /// </summary>
        private void HandleSendFinished(bool wasError, BatchContextSafeHandleNotOwned ctx)
        {
            AsyncCompletionDelegate origCompletionDelegate = null;

            lock (myLock)
            {
                origCompletionDelegate = sendCompletionDelegate;
                sendCompletionDelegate = null;

                ReleaseResourcesIfPossible();
            }

            if (wasError)
            {
                FireCompletion(origCompletionDelegate, new OperationFailedException("Send failed"));
            }
            else
            {
                FireCompletion(origCompletionDelegate, null);
            }
        }
コード例 #20
0
        /// <summary>
        /// Handles halfclose completion.
        /// </summary>
        protected void HandleHalfclosed(bool success)
        {
            AsyncCompletionDelegate <object> origCompletionDelegate = null;

            lock (myLock)
            {
                origCompletionDelegate = sendCompletionDelegate;
                sendCompletionDelegate = null;

                ReleaseResourcesIfPossible();
            }

            if (!success)
            {
                FireCompletion(origCompletionDelegate, null, new InvalidOperationException("Halfclose failed"));
            }
            else
            {
                FireCompletion(origCompletionDelegate, null, null);
            }
        }
コード例 #21
0
        /// <summary>
        /// Handles halfclose (send close from client) completion.
        /// </summary>
        protected void HandleSendCloseFromClientFinished(bool success)
        {
            AsyncCompletionDelegate <object> origCompletionDelegate = null;

            lock (myLock)
            {
                origCompletionDelegate = sendCompletionDelegate;
                sendCompletionDelegate = null;

                ReleaseResourcesIfPossible();
            }

            if (!success)
            {
                FireCompletion(origCompletionDelegate, null, new InvalidOperationException("Sending close from client has failed."));
            }
            else
            {
                FireCompletion(origCompletionDelegate, null, null);
            }
        }
コード例 #22
0
ファイル: AsyncCallBase.cs プロジェクト: muisaja7/grpc
        /// <summary>
        /// Handles streaming read completion.
        /// </summary>
        protected void HandleReadFinished(bool success, BatchContextSafeHandle ctx)
        {
            var payload = ctx.GetReceivedMessage();

            AsyncCompletionDelegate <TRead> origCompletionDelegate = null;

            lock (myLock)
            {
                origCompletionDelegate = readCompletionDelegate;
                if (payload != null)
                {
                    readCompletionDelegate = null;
                }
                else
                {
                    // This was the last read. Keeping the readCompletionDelegate
                    // to be either fired by this handler or by client-side finished
                    // handler.
                    readingDone = true;
                }

                ReleaseResourcesIfPossible();
            }

            // TODO: handle the case when error occured...

            if (payload != null)
            {
                // TODO: handle deserialization error
                TRead msg;
                TryDeserialize(payload, out msg);

                FireCompletion(origCompletionDelegate, msg, null);
            }
            else
            {
                ProcessLastRead(origCompletionDelegate);
            }
        }
コード例 #23
0
        /// <summary>
        /// Initiates sending a initial metadata.
        /// Even though C-core allows sending metadata in parallel to sending messages, we will treat sending metadata as a send message operation
        /// to make things simpler.
        /// completionDelegate is invoked upon completion.
        /// </summary>
        public void StartSendInitialMetadata(Metadata headers, AsyncCompletionDelegate <object> completionDelegate)
        {
            lock (myLock)
            {
                Preconditions.CheckNotNull(headers, "metadata");
                Preconditions.CheckNotNull(completionDelegate, "Completion delegate cannot be null");

                Preconditions.CheckState(!initialMetadataSent, "Response headers can only be sent once per call.");
                Preconditions.CheckState(streamingWritesCounter == 0, "Response headers can only be sent before the first write starts.");
                CheckSendingAllowed();

                Preconditions.CheckNotNull(completionDelegate, "Completion delegate cannot be null");

                using (var metadataArray = MetadataArraySafeHandle.Create(headers))
                {
                    call.StartSendInitialMetadata(HandleSendFinished, metadataArray);
                }

                this.initialMetadataSent = true;
                sendCompletionDelegate   = completionDelegate;
            }
        }
コード例 #24
0
        /// <summary>
        /// Handles halfclose completion.
        /// </summary>
        protected void HandleHalfclosed(bool success, BatchContextSafeHandle ctx)
        {
            AsyncCompletionDelegate <object> origCompletionDelegate = null;

            lock (myLock)
            {
                halfclosed             = true;
                origCompletionDelegate = sendCompletionDelegate;
                sendCompletionDelegate = null;

                ReleaseResourcesIfPossible();
            }

            if (!success)
            {
                FireCompletion(origCompletionDelegate, null, new OperationFailedException("Halfclose failed"));
            }
            else
            {
                FireCompletion(origCompletionDelegate, null, null);
            }
        }
コード例 #25
0
 public IntPtr GetAsyncCompletionDelegate()
 {
     if (IntPtr.Zero == _asyncCompletionDelegatePointer)
     {
         lock (_delegatelock) {
             if (IntPtr.Zero == _asyncCompletionDelegatePointer)
             {
                 AsyncCompletionDelegate d = new AsyncCompletionDelegate(AsyncCompletionHandler);
                 if (null != d)
                 {
                     IntPtr p = Marshal.GetFunctionPointerForDelegate(d);
                     if (IntPtr.Zero != p)
                     {
                         _asyncCompletionDelegate        = d;
                         _asyncCompletionDelegatePointer = p;
                     }
                 }
             }
         }
     }
     return(_asyncCompletionDelegatePointer);
 }
コード例 #26
0
        /// <summary>
        /// Handles halfclose completion.
        /// </summary>
        private void HandleHalfclosed(bool wasError, BatchContextSafeHandleNotOwned ctx)
        {
            AsyncCompletionDelegate <object> origCompletionDelegate = null;

            lock (myLock)
            {
                halfclosed             = true;
                origCompletionDelegate = sendCompletionDelegate;
                sendCompletionDelegate = null;

                ReleaseResourcesIfPossible();
            }

            if (wasError)
            {
                FireCompletion(origCompletionDelegate, null, new OperationFailedException("Halfclose failed"));
            }
            else
            {
                FireCompletion(origCompletionDelegate, null, null);
            }
        }
コード例 #27
0
ファイル: AsyncCall.cs プロジェクト: zen-li/grpc
        /// <summary>
        /// Sends halfclose, indicating client is done with streaming requests.
        /// Only one pending send action is allowed at any given time.
        /// completionDelegate is called when the operation finishes.
        /// </summary>
        public void StartSendCloseFromClient(AsyncCompletionDelegate <object> completionDelegate)
        {
            lock (myLock)
            {
                GrpcPreconditions.CheckNotNull(completionDelegate, "Completion delegate cannot be null");
                CheckSendingAllowed(allowFinished: true);

                if (!disposed && !finished)
                {
                    call.StartSendCloseFromClient(HandleSendCloseFromClientFinished);
                }
                else
                {
                    // In case the call has already been finished by the serverside,
                    // the halfclose has already been done implicitly, so we only
                    // emit the notification for the completion delegate.
                    Task.Run(() => HandleSendCloseFromClientFinished(true));
                }

                halfcloseRequested     = true;
                sendCompletionDelegate = completionDelegate;
            }
        }
コード例 #28
0
        /// <summary>
        /// Handles streaming read completion.
        /// </summary>
        protected void HandleReadFinished(bool success, byte[] receivedMessage)
        {
            TRead msg = default(TRead);
            var   deserializeException = (success && receivedMessage != null) ? TryDeserialize(receivedMessage, out msg) : null;

            AsyncCompletionDelegate <TRead> origCompletionDelegate = null;

            lock (myLock)
            {
                origCompletionDelegate = readCompletionDelegate;
                readCompletionDelegate = null;

                if (receivedMessage == null)
                {
                    // This was the last read.
                    readingDone = true;
                }

                if (deserializeException != null && IsClient)
                {
                    readingDone = true;
                    CancelWithStatus(DeserializeResponseFailureStatus);
                }

                ReleaseResourcesIfPossible();
            }

            // TODO: handle the case when success==false

            if (deserializeException != null && !IsClient)
            {
                FireCompletion(origCompletionDelegate, default(TRead), new IOException("Failed to deserialize request message.", deserializeException));
                return;
            }
            FireCompletion(origCompletionDelegate, msg, null);
        }
コード例 #29
0
ファイル: AsyncCallBase.cs プロジェクト: muisaja7/grpc
 // TODO(jtattermusch): find more fitting name for this method.
 /// <summary>
 /// Default behavior just completes the read observer, but more sofisticated behavior might be required
 /// by subclasses.
 /// </summary>
 protected virtual void ProcessLastRead(AsyncCompletionDelegate <TRead> completionDelegate)
 {
     FireCompletion(completionDelegate, default(TRead), null);
 }
コード例 #30
0
        public void MarkMailReadAsync(CharacterMailMessage message, AsyncCompletionDelegate resultDelegate)
        {
            StableSession.Instance.MarkMailReadAsync(message.MailId, (bool result, string reason) =>
            {
                if (result)
                {
                    message.ReadDate = DateTime.UtcNow;
                }

                if (resultDelegate != null)
                    resultDelegate(result, reason);

                if (!result) 
                    return;

                OnMessagesChanged();
                OnUnreadCountChanged();
            });
        }
コード例 #31
0
        public void DeleteMailAsync(CharacterMailMessage message, AsyncCompletionDelegate resultDelegate)
        {
            StableSession.Instance.DeleteMailAsync(message.MailId, (bool result, string reason) =>
            {
                if (result)
                {
                    Messages.Remove(message);
                }

                if (resultDelegate != null)
                    resultDelegate(result, reason);

                if (!result)
                    return;

                OnMessagesChanged();
                OnUnreadCountChanged();
            });
        }
コード例 #32
0
ファイル: AsyncCall.cs プロジェクト: tempbottle/grpc
 /// <summary>
 /// Receives a streaming response. Only one pending read action is allowed at any given time.
 /// completionDelegate is called when the operation finishes.
 /// </summary>
 public void StartReadMessage(AsyncCompletionDelegate <TResponse> completionDelegate)
 {
     StartReadMessageInternal(completionDelegate);
 }
コード例 #33
0
ファイル: AsyncCall.cs プロジェクト: tempbottle/grpc
 /// <summary>
 /// Sends a streaming request. Only one pending send action is allowed at any given time.
 /// completionDelegate is called when the operation finishes.
 /// </summary>
 public void StartSendMessage(TRequest msg, WriteFlags writeFlags, AsyncCompletionDelegate <object> completionDelegate)
 {
     StartSendMessageInternal(msg, writeFlags, completionDelegate);
 }
コード例 #34
0
ファイル: AsyncCallServer.cs プロジェクト: hmings888/grpc
 /// <summary>
 /// Sends a streaming response. Only one pending send action is allowed at any given time.
 /// completionDelegate is called when the operation finishes.
 /// </summary>
 public void StartSendMessage(TResponse msg, AsyncCompletionDelegate <object> completionDelegate)
 {
     StartSendMessageInternal(msg, completionDelegate);
 }
コード例 #35
0
ファイル: AsyncCompletion.cs プロジェクト: jwatt/kythe
 public AsyncCompletionTaskSource()
 {
     completionDelegate = new AsyncCompletionDelegate(HandleCompletion);
 }
コード例 #36
0
 public IntPtr GetAsyncCompletionDelegate() {
     if (IntPtr.Zero == _asyncCompletionDelegatePointer) {
         lock (_delegatelock) {
             if (IntPtr.Zero == _asyncCompletionDelegatePointer) {
                 AsyncCompletionDelegate d = new AsyncCompletionDelegate(AsyncCompletionHandler);
                 if (null != d) {
                     IntPtr p = Marshal.GetFunctionPointerForDelegate(d);
                     if (IntPtr.Zero != p) {
                         _asyncCompletionDelegate = d;
                         _asyncCompletionDelegatePointer = p;
                     }
                 }
             }
         }
     }
     return _asyncCompletionDelegatePointer;
 }
コード例 #37
0
        public void GetEventsAsync(List<StableSession.YearMonth> months, AsyncCompletionDelegate resultDelegate)
        {
            List<StableSession.YearMonth> newMonths = months.Where(month => _cachedMonths.Contains(month) != true).ToList();
            if (newMonths.Count <= 0)
                return;


            StableSession.Instance.GetEventsAsync(newMonths, (events, reason) =>
            {
                if (events != null)
                {
                    if (Events != null)
                    {
                        foreach (StableSession.YearMonth month in newMonths)
                        {
                            DateTime startDate = new DateTime(month.Year, month.Month, 1);
                            DateTime endDate = new DateTime(month.Year, month.Month,
                                DateTime.DaysInMonth(month.Year, month.Month));
                            Events.RemoveAll(@event => @event.IsIn(startDate, endDate));
                        }
                    }

                    _cachedMonths.UnionWith(months);
                    Events = Events != null ? Events.Union(events, new EventComparer()).ToList() : events;
                    Events.Sort(new EventDateComparer());
                }

                if (resultDelegate != null)
                    resultDelegate(events != null, reason);

                if (events != null)
                    OnEventsChanged();
            });
        }
コード例 #38
0
ファイル: AsyncCall.cs プロジェクト: wfarr/grpc
 /// <summary>
 /// Sends a streaming request. Only one pending send action is allowed at any given time.
 /// completionDelegate is called when the operation finishes.
 /// </summary>
 public void StartSendMessage(TRequest msg, AsyncCompletionDelegate completionDelegate)
 {
     StartSendMessageInternal(msg, completionDelegate);
 }
コード例 #39
0
        public void DeleteEventAsync(CalendarEvent eventData, AsyncCompletionDelegate resultDelegate)
        {
            StableSession.Instance.DeleteEventAsync(eventData.EventId.Value, (result, reason) =>
            {
                if (result)
                {
                    PendingEvents.RemoveAll(@event => @event.EventId == eventData.EventId);
                    Events.RemoveAll(@event => @event.EventId == eventData.EventId);
                }

                if (resultDelegate != null)
                {
                    resultDelegate(result, reason);
                }

                if (result)
                {
                    OnEventsChanged();
                    OnPendingEventsChanged();
                }

            });
        }
コード例 #40
0
        public void ReplyInvitationAsync(UInt64 eventId, bool accept, AsyncCompletionDelegate resultDelegate)
        {
            StableSession.Instance.ReplyInvitationAsync(eventId, accept, (eventData, reason) => 
            {
                if (eventData != null)
                {
                    PendingEvents.RemoveAll(@event => @event.EventId == eventId);
                    if (accept)
                    {
                        Events.Add(eventData);
                        Events.Sort(new EventDateComparer());
                    }
                }

                if (resultDelegate != null)
                {
                    resultDelegate(eventData != null, reason);
                }

                if (eventData != null)
                {
                    OnEventsChanged();
                    OnPendingEventsChanged();
                }

            });
        }