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; } } }
/// <summary> /// Get set of current observed neighbors /// </summary> /// <returns>set of neighbors</returns> public Neighbor[] GetNeighbors() { lock (_lock) { int count = _neighbours.Count; Neighbor[] res = new Neighbor[count]; for (int i = 0; i < count; i++) { Entry e = (Entry)_neighbours[i]; res[i].shortAdr = e.addrShort; res[i].lqi = e.lqiRx; } return res; } }