示例#1
0
        private void NeighborConfirmHandler(
            object sender,
            Status status,
            Neighbor[] neighbors)
        {
            MsgNeighbors msg = new MsgNeighbors();

            msg.neighbors     = neighbors;
            msg.neighborCount = 0;
            if (neighbors != null)
            {
                msg.neighborCount = neighbors.Length;
            }

            Frame frame = null;

            if (msg.neighborCount > 0)
            {
                frame = Frame.GetFrame(_head, msg.Length() + _tail);
                if (msg.WriteToFrame(frame))
                {
                    _net.DataRequest(0, ref frame, 0, null);
                }

                Frame.Release(ref frame);
            }

            if (_coordinator)
            {
                lock (_statusLock)
                {
                    for (int i = 0; i < _status.Length; i++)
                    {
                        _status[i].txBps = (_status[i].txBps * 1000) / (UInt32)_reportInterval;
                    }

                    _monitor.Status(_status);
                    // reset status
                    NodeStatus[] res = new NodeStatus[_status.Length];
                    for (int i = 0; i < _status.Length; i++)
                    {
                        res[i].addr = _status[i].addr;
                    }

                    _status = res;
                }
            }
        }
示例#2
0
文件: Network.cs 项目: prabby/miniclr
        private void NeighborConfirmHandler(
            object sender,
            Status status,
            Neighbor[] neighbors)
        {
            MsgNeighbors msg = new MsgNeighbors();
            msg.neighbors = neighbors;
            msg.neighborCount = 0;
            if (neighbors != null)
                msg.neighborCount = neighbors.Length;

            Frame frame = null;
            if (msg.neighborCount > 0)
            {
                frame = Frame.GetFrame(_head, msg.Length() + _tail);
                if (msg.WriteToFrame(frame))
                {
                    _net.DataRequest(0, ref frame, 0, null);
                }

                Frame.Release(ref frame);
            }

            if (_coordinator)
            {
                lock (_statusLock)
                {
                    for (int i = 0; i < _status.Length; i++)
                        _status[i].txBps = (_status[i].txBps * 1000) / (UInt32)_reportInterval;

                    _monitor.Status(_status);
                    // reset status
                    NodeStatus[] res = new NodeStatus[_status.Length];
                    for (int i = 0; i < _status.Length; i++)
                    {
                        res[i].addr = _status[i].addr;
                    }

                    _status = res;
                }
            }
        }