Exemple #1
0
        private void ProcessOverlayServiceMessageSentEvent(OverlayServiceEventArgs args)
        {
            // TODO

            if (args.Message.MsgType == OverlayNodeServiceMessage.MessageType.LeaveRequested || args.Message.MsgType == OverlayNodeServiceMessage.MessageType.ExitRequested) {

            }

            // allow waiting threads to proceed
            args.WaitHandle.Set();
        }
        private void Leave()
        {
            Log.Write(LogEvent.Info, "Leaving the network for node {0}", LocalNode);

            // stop stabilization threads
            MaintenanceSrv.Stop();

            StopOverlayStateService();

            if (OverlayMessageSent != null) {
                var args = new OverlayServiceEventArgs {
                                Message = new OverlayNodeServiceMessage { MsgType = OverlayNodeServiceMessage.MessageType.LeaveRequested },
                                WaitHandle = new ManualResetEventSlim()
                            };
                OverlayMessageSent(args);
                args.WaitHandle.Wait();
            }

            // stop network communication server
            CommunicationMgr.Stop();

            // reset local node
            LocalNode.Reset();

            // mark as disconnected
            LocalNode.State = NodeState.Disconnected;

            Log.Write(LogEvent.Info, "Left the network for node {0}", LocalNode);
        }