Ejemplo n.º 1
0
        private void InternalShutdown()
        {
            lock (padlock)
            {
                if (state == Net2State.STARTED)
                {
                    List <Net2HandlerBase> channels;

                    lock (@lock)
                    {
                        channels = channels_list.Values.ToList();
                    }

                    foreach (var item in channels)
                    {
                        item.Dispose();
                    }

                    // net2_service.Dispose();

                    state = Net2State.STOPPED;

                    net2_consul.removeService(NameSpace);
                    Net2NTPClient.delegateNewLogx -= delegateNewLog;
                    net2_config.name_space         = "";
                }
                else
                {
                    throw new Exception("Init first");
                }
            }
        }
Ejemplo n.º 2
0
 protected void setState(Net2State new_state)
 {
     if (this.internal_state != new_state)
     {
         this.internal_state = new_state;
         reportState();
     }
 }
Ejemplo n.º 3
0
        private void Initialize(Net2Config net2_config, DelegateGetResponse response_callback)
        {
            lock (padlock)
            {
                if (state == Net2State.STOPPED)
                {
                    channels_list = new Dictionary <ulong, Net2HandlerBase>();

                    if (response_callback == null)
                    {
                        GetResponse = ResponseCallback;
                    }
                    else
                    {
                        GetResponse = response_callback;
                    }

                    this.net2_config      = net2_config;
                    local_network_address = net2_config.local_network_address;

                    Net2NTPClient.delegateNewLogx += delegateNewLog;
                    net2_ntp = new Net2NTPClient(net2_config.ntp_server_host_name, true);


                    delegateNewLog("test", LogType.INFO, "test");

                    net2_consul = new Net2Consul("http://" + net2_config.consul_network_address + ":" + net2_config.consul_network_port, net2_config.consul_mode);

                    main_timer          = new System.Timers.Timer();
                    main_timer.Interval = 1000;
                    main_timer.Elapsed += Main_timer_Elapsed;
                    main_timer.Enabled  = true;
                    main_timer.Start();

                    state = Net2State.STARTED;
                }
                else
                {
                    throw new Exception("Already inited");
                }
            }
        }