public Host ToHost() { return new Host( SessionID, BroadcastID, LocalEndPoint, GlobalEndPoint, RelayCount, DirectCount, IsFirewalled, IsTracker, IsRelayFull, IsDirectFull, IsReceiving, IsControlFull, Extensions, Extra); }
private void OnPCPHost(Atom atom) { var session_id = atom.Children.GetHostSessionID(); if (session_id!=null) { var node = Channel.SourceNodes.FirstOrDefault(x => x.SessionID.Equals(session_id)); var host = new HostBuilder(node); if (node==null) { host.SessionID = (Guid)session_id; } host.Extra.Update(atom.Children); host.DirectCount = atom.Children.GetHostNumListeners() ?? 0; host.RelayCount = atom.Children.GetHostNumRelays() ?? 0; var flags1 = atom.Children.GetHostFlags1(); if (flags1 != null) { host.IsFirewalled = (flags1.Value & PCPHostFlags1.Firewalled) != 0; host.IsTracker = (flags1.Value & PCPHostFlags1.Tracker) != 0; host.IsRelayFull = (flags1.Value & PCPHostFlags1.Relay) == 0; host.IsDirectFull = (flags1.Value & PCPHostFlags1.Direct) == 0; host.IsReceiving = (flags1.Value & PCPHostFlags1.Receiving) != 0; host.IsControlFull = (flags1.Value & PCPHostFlags1.ControlIn) == 0; } var endpoints = atom.Children.GetHostEndPoints(); if (endpoints.Length>0 && (host.GlobalEndPoint==null || !host.GlobalEndPoint.Equals(endpoints[0]))) { host.GlobalEndPoint = endpoints[0]; } if (endpoints.Length>1 && (host.LocalEndPoint==null || !host.LocalEndPoint.Equals(endpoints[1]))) { host.LocalEndPoint = endpoints[1]; } Channel.AddSourceNode(host.ToHost()); } }