protected void OnPCPBcst(Atom atom)
        {
            var dest = atom.Children.GetBcstDest();

            if (dest == null || dest == PeerCast.SessionID)
            {
                foreach (var c in atom.Children)
                {
                    ProcessAtom(c);
                }
            }
            var ttl   = atom.Children.GetBcstTTL();
            var hops  = atom.Children.GetBcstHops();
            var from  = atom.Children.GetBcstFrom();
            var group = atom.Children.GetBcstGroup();

            if (ttl != null &&
                hops != null &&
                group != null &&
                from != null &&
                dest != PeerCast.SessionID &&
                ttl > 1)
            {
                var bcst = new AtomCollection(atom.Children);
                bcst.SetBcstTTL((byte)(ttl - 1));
                bcst.SetBcstHops((byte)(hops + 1));
                Channel.Broadcast(uphost, new Atom(atom.Name, bcst), group.Value);
            }
        }
Beispiel #2
0
        private async Task OnPCPBcst(Atom atom, CancellationToken cancel_token)
        {
            var dest  = atom.Children.GetBcstDest();
            var ttl   = atom.Children.GetBcstTTL();
            var hops  = atom.Children.GetBcstHops();
            var from  = atom.Children.GetBcstFrom();
            var group = atom.Children.GetBcstGroup();

            if (ttl != null &&
                hops != null &&
                group != null &&
                from != null &&
                dest != PeerCast.SessionID &&
                ttl > 0)
            {
                Logger.Debug("Relaying BCST TTL: {0}, Hops: {1}", ttl, hops);
                var bcst = new AtomCollection(atom.Children);
                bcst.SetBcstTTL((byte)(ttl - 1));
                bcst.SetBcstHops((byte)(hops + 1));
                Channel.Broadcast(Downhost, new Atom(atom.Name, bcst), group.Value);
            }
            if (dest == null || dest == PeerCast.SessionID)
            {
                Logger.Debug("Processing BCST({0})", dest == null ? "(null)" : dest.Value.ToString("N"));
                foreach (var c in atom.Children)
                {
                    await ProcessAtom(c, cancel_token).ConfigureAwait(false);
                }
            }
        }
        protected virtual void OnPCPBcst(Atom atom)
        {
            var dest  = atom.Children.GetBcstDest();
            var ttl   = atom.Children.GetBcstTTL();
            var hops  = atom.Children.GetBcstHops();
            var from  = atom.Children.GetBcstFrom();
            var group = atom.Children.GetBcstGroup();

            if (ttl != null &&
                hops != null &&
                group != null &&
                from != null &&
                dest != PeerCast.SessionID &&
                ttl > 0)
            {
                Logger.Debug("Relaying BCST TTL: {0}, Hops: {1}", ttl, hops);
                var bcst = new AtomCollection(atom.Children);
                bcst.SetBcstTTL((byte)(ttl - 1));
                bcst.SetBcstHops((byte)(hops + 1));
                Channel.Broadcast(Downhost, new Atom(atom.Name, bcst), group.Value);
            }
            if (dest == null || dest == PeerCast.SessionID)
            {
                Logger.Debug("Processing BCST({0})", dest == null ? "(null)" : dest.Value.ToString("N"));
                foreach (var c in atom.Children)
                {
                    ProcessAtom(c);
                }
            }
        }
Beispiel #4
0
        private Atom CreateBroadcastPacket(BroadcastGroup group, Atom packet)
        {
            var bcst = new AtomCollection();

            bcst.SetBcstFrom(PeerCast.SessionID);
            bcst.SetBcstGroup(group);
            bcst.SetBcstHops(0);
            bcst.SetBcstTTL(11);
            PCPVersion.SetBcstVersion(bcst);
            bcst.SetBcstChannelID(Channel.ChannelID);
            bcst.Add(packet);
            return(new Atom(Atom.PCP_BCST, bcst));
        }
        private Atom CreateChannelBcst(Channel channel, bool playing)
        {
            var bcst = new AtomCollection();

            bcst.SetBcstTTL(1);
            bcst.SetBcstHops(0);
            bcst.SetBcstFrom(PeerCast.SessionID);
            PCPVersion.SetBcstVersion(bcst);
            bcst.SetBcstChannelID(channel.ChannelID);
            bcst.SetBcstGroup(BroadcastGroup.Root);
            PostChannelInfo(bcst, channel);
            PostHostInfo(bcst, channel, playing);
            return(new Atom(Atom.PCP_BCST, bcst));
        }
Beispiel #6
0
        /// <summary>
        /// 指定したパケットを含むブロードキャストパケットを作成します
        /// </summary>
        /// <param name="group">配送先グループ</param>
        /// <param name="packet">配送するパケット</param>
        /// <returns>作成したPCP_BCSTパケット</returns>
        public virtual Atom CreateBroadcastPacket(BroadcastGroup group, Atom packet)
        {
            var bcst = new AtomCollection();

            bcst.SetBcstFrom(PeerCast.SessionID);
            bcst.SetBcstGroup(group);
            bcst.SetBcstHops(0);
            bcst.SetBcstTTL(11);
            bcst.SetBcstVersion(PCP_VERSION);
            bcst.SetBcstVersionVP(PCP_VERSION_VP);
            bcst.SetBcstChannelID(Channel.ChannelID);
            bcst.Add(packet);
            return(new Atom(Atom.PCP_BCST, bcst));
        }
        private void PostChannelBcst(Channel channel, bool playing)
        {
            var bcst = new AtomCollection();

            bcst.SetBcstTTL(1);
            bcst.SetBcstHops(0);
            bcst.SetBcstFrom(PeerCast.SessionID);
            bcst.SetBcstVersion(PCP_VERSION);
            bcst.SetBcstVersionVP(PCP_VERSION_VP);
            bcst.SetBcstChannelID(channel.ChannelID);
            bcst.SetBcstGroup(BroadcastGroup.Root);
            PostChannelInfo(bcst, channel);
            PostHostInfo(bcst, channel, playing);
            lock (posts) posts.Add(new Atom(Atom.PCP_BCST, bcst));
        }
        private void OnPCPBcst(Atom atom)
        {
            var channel_id = atom.Children.GetBcstChannelID();

            if (channel_id != null)
            {
                Channel channel;
                lock (announcingChannels) {
                    channel = announcingChannels.Find(c => c.Channel.ChannelID == channel_id).Channel;
                }
                var group = atom.Children.GetBcstGroup();
                var from  = atom.Children.GetBcstFrom();
                var ttl   = atom.Children.GetBcstTTL();
                var hops  = atom.Children.GetBcstHops();
                if (channel != null && group != null && from != null && ttl != null && ttl.Value > 0)
                {
                    var bcst = new AtomCollection(atom.Children);
                    bcst.SetBcstTTL((byte)(ttl.Value - 1));
                    bcst.SetBcstHops((byte)((hops ?? 0) + 1));
                    channel.Broadcast(null, new Atom(Atom.PCP_BCST, bcst), group.Value);
                }
            }
        }
 /// <summary>
 /// 指定したパケットを含むブロードキャストパケットを作成します
 /// </summary>
 /// <param name="group">配送先グループ</param>
 /// <param name="packet">配送するパケット</param>
 /// <returns>作成したPCP_BCSTパケット</returns>
 private Atom CreateBroadcastPacket(BroadcastGroup group, Atom packet)
 {
     var bcst = new AtomCollection();
       bcst.SetBcstFrom(PeerCast.SessionID);
       bcst.SetBcstGroup(group);
       bcst.SetBcstHops(0);
       bcst.SetBcstTTL(11);
       PCPVersion.SetBcstVersion(bcst);
       bcst.SetBcstChannelID(Channel.ChannelID);
       bcst.Add(packet);
       return new Atom(Atom.PCP_BCST, bcst);
 }
 protected void OnPCPBcst(Atom atom)
 {
     var dest = atom.Children.GetBcstDest();
       if (dest==null || dest==PeerCast.SessionID) {
     foreach (var c in atom.Children) ProcessAtom(c);
       }
       var ttl = atom.Children.GetBcstTTL();
       var hops = atom.Children.GetBcstHops();
       var from = atom.Children.GetBcstFrom();
       var group = atom.Children.GetBcstGroup();
       if (ttl != null &&
       hops != null &&
       group != null &&
       from != null &&
       dest != PeerCast.SessionID &&
       ttl>1) {
     var bcst = new AtomCollection(atom.Children);
     bcst.SetBcstTTL((byte)(ttl - 1));
     bcst.SetBcstHops((byte)(hops + 1));
     Channel.Broadcast(uphost, new Atom(atom.Name, bcst), group.Value);
       }
 }
 protected virtual void OnPCPBcst(Atom atom)
 {
     var dest = atom.Children.GetBcstDest();
       var ttl = atom.Children.GetBcstTTL();
       var hops = atom.Children.GetBcstHops();
       var from = atom.Children.GetBcstFrom();
       var group = atom.Children.GetBcstGroup();
       if (ttl != null &&
       hops != null &&
       group != null &&
       from != null &&
       dest != PeerCast.SessionID &&
       ttl>0) {
     Logger.Debug("Relaying BCST TTL: {0}, Hops: {1}", ttl, hops);
     var bcst = new AtomCollection(atom.Children);
     bcst.SetBcstTTL((byte)(ttl - 1));
     bcst.SetBcstHops((byte)(hops + 1));
     Channel.Broadcast(Downhost, new Atom(atom.Name, bcst), group.Value);
       }
       if (dest==null || dest==PeerCast.SessionID) {
     Logger.Debug("Processing BCST({0})", dest==null ? "(null)" : dest.Value.ToString("N"));
     foreach (var c in atom.Children) ProcessAtom(c);
       }
 }
 private void PostChannelBcst(Channel channel, bool playing)
 {
     var bcst = new AtomCollection();
       bcst.SetBcstTTL(1);
       bcst.SetBcstHops(0);
       bcst.SetBcstFrom(PeerCast.SessionID);
       PCPVersion.SetBcstVersion(bcst);
       bcst.SetBcstChannelID(channel.ChannelID);
       bcst.SetBcstGroup(BroadcastGroup.Root);
       PostChannelInfo(bcst, channel);
       PostHostInfo(bcst, channel, playing);
       lock (posts) posts.Add(new Atom(Atom.PCP_BCST, bcst));
 }
 private void OnPCPBcst(Atom atom)
 {
     var channel_id = atom.Children.GetBcstChannelID();
       if (channel_id!=null) {
     Channel channel;
     lock (announcingChannels) {
       channel = announcingChannels.Find(c => c.Channel.ChannelID==channel_id).Channel;
     }
     var group = atom.Children.GetBcstGroup();
     var from  = atom.Children.GetBcstFrom();
     var ttl   = atom.Children.GetBcstTTL();
     var hops  = atom.Children.GetBcstHops();
     if (channel!=null && group!=null && from!=null && ttl!=null && ttl.Value>0) {
       var bcst = new AtomCollection(atom.Children);
       bcst.SetBcstTTL((byte)(ttl.Value-1));
       bcst.SetBcstHops((byte)((hops ?? 0)+1));
       channel.Broadcast(null, new Atom(Atom.PCP_BCST, bcst), group.Value);
     }
       }
 }