• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# AtomCollection类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中AtomCollection的典型用法代码示例。如果您正苦于以下问题:C# AtomCollection类的具体用法?C# AtomCollection怎么用?C# AtomCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AtomCollection类属于命名空间,在下文中一共展示了AtomCollection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: OnMetaData

 private void OnMetaData(DataMessage msg)
 {
   this.metadata = msg;
   var info = new AtomCollection();
   info.SetChanInfoType("FLV");
   info.SetChanInfoStreamType("video/x-flv");
   info.SetChanInfoStreamExt(".flv");
   if (metadata.Arguments[0].Type==AMF.AMFValueType.ECMAArray || metadata.Arguments[0].Type==AMF.AMFValueType.Object){
     var bitrate = 0.0;
     var val = metadata.Arguments[0]["maxBitrate"];
     if (!AMF.AMFValue.IsNull(val)) {
       double maxBitrate;
       string maxBitrateStr = System.Text.RegularExpressions.Regex.Replace((string)val, @"([\d]+)k", "$1");
       if (double.TryParse(maxBitrateStr, out maxBitrate)) {
         bitrate += maxBitrate;
       }
     }
     else if (!AMF.AMFValue.IsNull(val = metadata.Arguments[0]["videodatarate"])) {
       bitrate += (double)val;
     }
     if (!AMF.AMFValue.IsNull(val = metadata.Arguments[0]["audiodatarate"])) {
       bitrate += (double)val;
     }
     info.SetChanInfoBitrate((int)bitrate);
   }
   OnChannelInfoChanged(info);
   OnHeaderChanged(msg);
   OnContentChanged(msg);
 }
开发者ID:kumaryu,项目名称:peercaststation,代码行数:29,代码来源:FLVContentBuffer.cs


示例2: Read

 public ParsedContent Read(Stream stream)
 {
     if (stream.Length-stream.Position<=0) throw new EndOfStreamException();
       var res = new ParsedContent();
       var pos = Channel.ContentPosition;
       if (Channel.ContentHeader==null) {
     streamIndex = Channel.GenerateStreamID();
     streamOrigin = DateTime.Now;
     res.ContentHeader = new Content(streamIndex, TimeSpan.Zero, pos, new byte[] { });
     var channel_info = new AtomCollection(Channel.ChannelInfo.Extra);
     channel_info.SetChanInfoType("RAW");
     channel_info.SetChanInfoStreamType("application/octet-stream");
     channel_info.SetChanInfoStreamExt("");
     res.ChannelInfo = new ChannelInfo(channel_info);
       }
       res.Contents = new List<Content>();
       while (stream.Length-stream.Position>0) {
     var bytes = new byte[Math.Min(8192, stream.Length-stream.Position)];
     var sz = stream.Read(bytes, 0, bytes.Length);
     if (sz>0) {
       Array.Resize(ref bytes, sz);
       res.Contents.Add(new Content(streamIndex, DateTime.Now-streamOrigin, pos, bytes));
       pos += sz;
     }
       }
       return res;
 }
开发者ID:At-sushi,项目名称:peercaststation,代码行数:27,代码来源:RawContentReader.cs


示例3: BroadcastStart_Click

 private void BroadcastStart_Click(object sender, EventArgs args)
 {
   Uri source;
   if (Uri.TryCreate(bcStreamUrl.Text, UriKind.Absolute, out source)) {
     StreamSource = source;
   }
   else {
     StreamSource = null;
   }
   var reader = bcContentType.SelectedItem as ContentReaderItem;
   if (reader!=null) ContentReaderFactory = reader.ContentReaderFactory;
   var yp = bcYP.SelectedItem as YellowPageItem;
   if (yp!=null) YellowPage = yp.YellowPage;
   var info = new AtomCollection();
   int bitrate;
   if (Int32.TryParse(bcBitrate.Text, out bitrate)) {
     info.SetChanInfoBitrate(bitrate);
   }
   info.SetChanInfoName(bcChannelName.Text);
   info.SetChanInfoGenre(bcGenre.Text);
   info.SetChanInfoDesc(bcDescription.Text);
   info.SetChanInfoComment(bcComment.Text);
   info.SetChanInfoURL(bcContactUrl.Text);
   ChannelInfo = new ChannelInfo(info);
   var track = new AtomCollection();
   track.SetChanTrackTitle(bcTrackTitle.Text);
   track.SetChanTrackGenre(bcTrackGenre.Text);
   track.SetChanTrackAlbum(bcAlbum.Text);
   track.SetChanTrackCreator(bcCreator.Text);
   track.SetChanTrackURL(bcTrackURL.Text);
   ChannelTrack = new ChannelTrack(track);
   if (StreamSource!=null && ContentReaderFactory!=null && !String.IsNullOrEmpty(ChannelInfo.Name)) {
     DialogResult = DialogResult.OK;
   }
 }
开发者ID:kumaryu,项目名称:peercaststation,代码行数:35,代码来源:BroadcastDialog.cs


示例4: OnFLVHeader

 public void OnFLVHeader()
 {
   var info = new AtomCollection();
   info.SetChanInfoType("FLV");
   info.SetChanInfoStreamType("video/x-flv");
   info.SetChanInfoStreamExt(".flv");
   OnChannelInfoChanged(info);
 }
开发者ID:kumaryu,项目名称:peercaststation,代码行数:8,代码来源:FLVContentBuffer.cs


示例5: Read

 public ParsedContent Read(Stream stream)
 {
     var chunks = 0;
       var res = new ParsedContent();
       var pos = Channel.ContentPosition;
       try {
     while (chunks<8) {
       var chunk = ASFChunk.Read(stream);
       chunks++;
       switch (chunk.KnownType) {
       case ASFChunk.ChunkType.Header: {
       var header = ASFHeader.Read(chunk);
       var info = new AtomCollection(Channel.ChannelInfo.Extra);
       info.SetChanInfoBitrate(header.Bitrate);
       if (header.Streams.Any(type => type==ASFHeader.StreamType.Video)) {
         info.SetChanInfoType("WMV");
         info.SetChanInfoStreamType("video/x-ms-wmv");
         info.SetChanInfoStreamExt(".wmv");
       }
       else if (header.Streams.Any(type => type==ASFHeader.StreamType.Audio)) {
         info.SetChanInfoType("WMA");
         info.SetChanInfoStreamType("audio/x-ms-wma");
         info.SetChanInfoStreamExt(".wma");
       }
       else {
         info.SetChanInfoType("ASF");
         info.SetChanInfoStreamType("video/x-ms-asf");
         info.SetChanInfoStreamExt(".asf");
       }
       res.ChannelInfo = new ChannelInfo(info);
       streamIndex = Channel.GenerateStreamID();
       streamOrigin = DateTime.Now;
       res.ContentHeader = new Content(streamIndex, TimeSpan.Zero, pos, chunk.ToByteArray());
       pos += chunk.TotalLength;
     }
     break;
       case ASFChunk.ChunkType.Data:
     if (res.Contents==null) res.Contents = new System.Collections.Generic.List<Content>();
     res.Contents.Add(new Content(streamIndex, DateTime.Now-streamOrigin, pos, chunk.ToByteArray()));
     pos += chunk.TotalLength;
     break;
       case ASFChunk.ChunkType.Unknown:
     break;
       }
     }
       }
       catch (EndOfStreamException) {
     if (chunks==0) throw;
       }
       return res;
 }
开发者ID:psjp,项目名称:peercaststation,代码行数:51,代码来源:ASFContentReader.cs


示例6: OnPCPHelo

 protected virtual void OnPCPHelo(Atom atom)
 {
     var session_id = atom.Children.GetHeloSessionID();
       var oleh = new AtomCollection();
       oleh.SetHeloSessionID(PeerCast.SessionID);
       Send(new Atom(Atom.PCP_OLEH, oleh));
       if (session_id==null) {
     Logger.Info("Helo has no SessionID");
     Stop(StopReason.NotIdentifiedError);
       }
       else {
     Logger.Debug("Helo from {0}", PeerCast.SessionID.ToString("N"));
     Stop(StopReason.None);
       }
 }
开发者ID:j0hn---,项目名称:peercaststation,代码行数:15,代码来源:PCPPongOutputStream.cs


示例7: ChannelInfoViewModel

        public ChannelInfoViewModel()
        {
            update = new Command(() =>
            {
              var info = new AtomCollection(channel.ChannelInfo.Extra);
              info.SetChanInfoGenre(genre);
              info.SetChanInfoDesc(description);
              info.SetChanInfoURL(contactUrl);
              info.SetChanInfoComment(comment);
              channel.ChannelInfo = new ChannelInfo(info);

              var track = new AtomCollection(channel.ChannelTrack.Extra);
              track.SetChanTrackAlbum(trackAlbum);
              track.SetChanTrackCreator(trackArtist);
              track.SetChanTrackTitle(trackTitle);
              track.SetChanTrackGenre(trackGenre);
              track.SetChanTrackURL(trackUrl);
              channel.ChannelTrack = new ChannelTrack(track);
              IsModified = false;
            },
            () => channel!=null && IsTracker && IsModified);
        }
开发者ID:psjp,项目名称:peercaststation,代码行数:22,代码来源:ChannelInfoViewModel.cs


示例8: DoStop

 protected override void DoStop(StopReason reason)
 {
     switch (reason) {
       case StopReason.None:
     break;
       case StopReason.Any:
     Send(new Atom(Atom.PCP_QUIT, Atom.PCP_ERROR_QUIT));
     break;
       case StopReason.SendTimeoutError:
     Send(new Atom(Atom.PCP_QUIT, Atom.PCP_ERROR_QUIT + Atom.PCP_ERROR_SKIP));
     break;
       case StopReason.BadAgentError:
     Send(new Atom(Atom.PCP_QUIT, Atom.PCP_ERROR_QUIT + Atom.PCP_ERROR_BADAGENT));
     break;
       case StopReason.ConnectionError:
     Send(new Atom(Atom.PCP_QUIT, Atom.PCP_ERROR_QUIT + Atom.PCP_ERROR_READ));
     break;
       case StopReason.NotIdentifiedError:
     Send(new Atom(Atom.PCP_QUIT, Atom.PCP_ERROR_QUIT + Atom.PCP_ERROR_NOTIDENTIFIED));
     break;
       case StopReason.UnavailableError:
     {
       //次に接続するホストを送ってQUIT
       foreach (var node in SelectSourceHosts((IPEndPoint)RemoteEndPoint)) {
     if (Downhost!=null && Downhost.SessionID==node.SessionID) continue;
     var host_atom = new AtomCollection(node.Extra);
     Atom ip = host_atom.FindByName(Atom.PCP_HOST_IP);
     while (ip!=null) {
       host_atom.Remove(ip);
       ip = host_atom.FindByName(Atom.PCP_HOST_IP);
     }
     Atom port = host_atom.FindByName(Atom.PCP_HOST_PORT);
     while (port!=null) {
       host_atom.Remove(port);
       port = host_atom.FindByName(Atom.PCP_HOST_PORT);
     }
     host_atom.SetHostSessionID(node.SessionID);
     var globalendpoint = node.GlobalEndPoint ?? new IPEndPoint(IPAddress.Any, 0);
     host_atom.AddHostIP(globalendpoint.Address);
     host_atom.AddHostPort(globalendpoint.Port);
     var localendpoint  = node.LocalEndPoint ?? new IPEndPoint(IPAddress.Any, 0);
     host_atom.AddHostIP(localendpoint.Address);
     host_atom.AddHostPort(localendpoint.Port);
     host_atom.SetHostNumRelays(node.RelayCount);
     host_atom.SetHostNumListeners(node.DirectCount);
     host_atom.SetHostChannelID(Channel.ChannelID);
     host_atom.SetHostFlags1(
       (node.IsFirewalled ? PCPHostFlags1.Firewalled : PCPHostFlags1.None) |
       (node.IsTracker ? PCPHostFlags1.Tracker : PCPHostFlags1.None) |
       (node.IsRelayFull ? PCPHostFlags1.None : PCPHostFlags1.Relay) |
       (node.IsDirectFull ? PCPHostFlags1.None : PCPHostFlags1.Direct) |
       (node.IsReceiving ? PCPHostFlags1.Receiving : PCPHostFlags1.None) |
       (node.IsControlFull ? PCPHostFlags1.None : PCPHostFlags1.ControlIn));
     Send(new Atom(Atom.PCP_HOST, host_atom));
     Logger.Debug("Sending Node: {0}({1})", globalendpoint, node.SessionID.ToString("N"));
       }
     }
     Send(new Atom(Atom.PCP_QUIT, Atom.PCP_ERROR_QUIT + Atom.PCP_ERROR_UNAVAILABLE));
     break;
       case StopReason.OffAir:
     Send(new Atom(Atom.PCP_QUIT, Atom.PCP_ERROR_QUIT + Atom.PCP_ERROR_OFFAIR));
     break;
       case StopReason.UserShutdown:
     Send(new Atom(Atom.PCP_QUIT, Atom.PCP_ERROR_QUIT + Atom.PCP_ERROR_SHUTDOWN));
     break;
       }
       base.DoStop(reason);
 }
开发者ID:peca-dev,项目名称:peercaststation,代码行数:68,代码来源:PCPOutputStream.cs


示例9: CreateContentHeaderPacket

 protected IEnumerable<Atom> CreateContentHeaderPacket(Channel channel, Content content)
 {
     var chan = new AtomCollection();
       chan.SetChanID(channel.ChannelID);
       var chan_pkt = new AtomCollection();
       chan_pkt.SetChanPktType(Atom.PCP_CHAN_PKT_HEAD);
       chan_pkt.SetChanPktPos((uint)(content.Position & 0xFFFFFFFFU));
       chan_pkt.SetChanPktData(content.Data);
       chan.SetChanPkt(chan_pkt);
       chan.SetChanInfo(channel.ChannelInfo.Extra);
       chan.SetChanTrack(channel.ChannelTrack.Extra);
       Logger.Debug("Sending Header: {0}", content.Position);
       return Enumerable.Repeat(new Atom(Atom.PCP_CHAN, chan), 1);
 }
开发者ID:peca-dev,项目名称:peercaststation,代码行数:14,代码来源:PCPOutputStream.cs


示例10: CreateChanPacket

 private Atom CreateChanPacket()
 {
     var chan = new AtomCollection();
     chan.SetChanID(Channel.ChannelID);
     chan.SetChanInfo(Channel.ChannelInfo.Extra);
     chan.SetChanTrack(Channel.ChannelTrack.Extra);
     return new Atom(Atom.PCP_CHAN, chan);
 }
开发者ID:At-sushi,项目名称:peercaststation,代码行数:8,代码来源:PCPOutputStream.cs


示例11: HostBuilder

 /// <summary>
 /// 指定されたHostBuilderの値でHostBuilderを初期化します
 /// </summary>
 /// <param name="host">初期化元のHostBuilder</param>
 public HostBuilder(HostBuilder host)
 {
   if (host!=null) {
     SessionID = host.SessionID;
     BroadcastID = host.BroadcastID;
     LocalEndPoint = host.LocalEndPoint;
     GlobalEndPoint = host.GlobalEndPoint;
     RelayCount = host.RelayCount;
     DirectCount = host.DirectCount;
     IsFirewalled = host.IsFirewalled;
     IsTracker = host.IsTracker;
     IsRelayFull = host.IsRelayFull;
     IsDirectFull = host.IsDirectFull;
     IsReceiving = host.IsReceiving;
     IsControlFull = host.IsControlFull;
     Extensions = new List<string>(host.Extensions);
     Extra = new AtomCollection(host.Extra);
   }
   else {
     SessionID = Guid.Empty;
     BroadcastID = Guid.Empty;
     LocalEndPoint = null;
     GlobalEndPoint = null;
     RelayCount = 0;
     DirectCount = 0;
     IsFirewalled = false;
     IsTracker = false;
     IsRelayFull = false;
     IsDirectFull = false;
     IsReceiving = false;
     IsControlFull = false;
     Extensions = new List<string>();
     Extra = new AtomCollection();
   }
 }
开发者ID:kumaryu,项目名称:peercaststation,代码行数:39,代码来源:Host.cs


示例12: BroadcastChannel

      private string BroadcastChannel(
        int?    yellowPageId,
        string  sourceUri,
        string  contentReader,
        JObject info,
        JObject track,
        string  sourceStream=null)
      {
        IYellowPageClient yp = null;
        if (yellowPageId.HasValue) {
          yp = PeerCast.YellowPages.FirstOrDefault(y => GetObjectId(y)==yellowPageId.Value);
          if (yp==null) throw new RPCError(RPCErrorCode.InvalidParams, "Yellow page not found");
        }
        if (sourceUri==null) throw new RPCError(RPCErrorCode.InvalidParams, "source uri required");
        Uri source;
        try {
          source = new Uri(sourceUri);
        }
        catch (UriFormatException) {
          throw new RPCError(RPCErrorCode.InvalidParams, "Invalid Uri");
        }
        var content_reader = PeerCast.ContentReaderFactories.FirstOrDefault(reader => reader.Name==contentReader);
        if (content_reader==null) throw new RPCError(RPCErrorCode.InvalidParams, "Content reader not found");
        var source_stream = PeerCast.SourceStreamFactories
          .Where(sstream => (sstream.Type & SourceStreamType.Broadcast)!=0)
          .FirstOrDefault(sstream => sstream.Name==sourceStream);
        if (source_stream==null) {
          source_stream = PeerCast.SourceStreamFactories
            .Where(sstream => (sstream.Type & SourceStreamType.Broadcast)!=0)
            .FirstOrDefault(sstream => sstream.Scheme==source.Scheme);
        }
        if (source_stream==null) throw new RPCError(RPCErrorCode.InvalidParams, "Source stream not found");

        var new_info = new AtomCollection();
        if (info!=null) {
          info.TryGetThen("name",    v => new_info.SetChanInfoName(v));
          info.TryGetThen("url",     v => new_info.SetChanInfoURL(v));
          info.TryGetThen("genre",   v => new_info.SetChanInfoGenre(v));
          info.TryGetThen("desc",    v => new_info.SetChanInfoDesc(v));
          info.TryGetThen("comment", v => new_info.SetChanInfoComment(v));
        }
        var channel_info  = new ChannelInfo(new_info);
        if (channel_info.Name==null || channel_info.Name=="") {
          throw new RPCError(RPCErrorCode.InvalidParams, "Channel name must not be empty");
        }
        var channel_id = PeerCastStation.Core.BroadcastChannel.CreateChannelID(
          PeerCast.BroadcastID,
          channel_info.Name,
          channel_info.Genre ?? "",
          source.ToString());
        var channel = PeerCast.BroadcastChannel(yp, channel_id, channel_info, source, source_stream, content_reader);
        if (track!=null) {
          var new_track = new AtomCollection(channel.ChannelTrack.Extra);
          track.TryGetThen("name",    v => new_track.SetChanTrackTitle(v));
          track.TryGetThen("genre",   v => new_track.SetChanTrackGenre(v));
          track.TryGetThen("album",   v => new_track.SetChanTrackAlbum(v));
          track.TryGetThen("creator", v => new_track.SetChanTrackCreator(v));
          track.TryGetThen("url",     v => new_track.SetChanTrackURL(v));
          channel.ChannelTrack = new ChannelTrack(new_track);
        }
        return channel.ChannelID.ToString("N").ToUpper();
      }
开发者ID:kumaryu,项目名称:peercaststation,代码行数:62,代码来源:APIHost.cs


示例13: OnPCPBcst

 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);
       }
 }
开发者ID:peca-dev,项目名称:peercaststation,代码行数:22,代码来源:PCPSourceStream.cs


示例14: CreateHostPacket

 /// <summary>
 /// 現在のチャンネルとPeerCastの状態からHostパケットを作ります
 /// </summary>
 /// <returns>作ったPCP_HOSTパケット</returns>
 private Atom CreateHostPacket()
 {
     var host = new AtomCollection();
       host.SetHostChannelID(Channel.ChannelID);
       host.SetHostSessionID(PeerCast.SessionID);
       var globalendpoint =
     PeerCast.GetGlobalEndPoint(
       RemoteEndPoint.AddressFamily,
       OutputStreamType.Relay);
       if (globalendpoint!=null) {
     host.AddHostIP(globalendpoint.Address);
     host.AddHostPort(globalendpoint.Port);
       }
       var localendpoint =
     PeerCast.GetLocalEndPoint(
       RemoteEndPoint.AddressFamily,
       OutputStreamType.Relay);
       if (localendpoint!=null) {
     host.AddHostIP(localendpoint.Address);
     host.AddHostPort(localendpoint.Port);
       }
       host.SetHostNumListeners(Channel.LocalDirects);
       host.SetHostNumRelays(Channel.LocalRelays);
       host.SetHostUptime(Channel.Uptime);
       if (Channel.Contents.Count > 0) {
     host.SetHostOldPos((uint)(Channel.Contents.Oldest.Position & 0xFFFFFFFFU));
     host.SetHostNewPos((uint)(Channel.Contents.Newest.Position & 0xFFFFFFFFU));
       }
       PCPVersion.SetHostVersion(host);
       host.SetHostFlags1(
     (PeerCast.AccessController.IsChannelRelayable(Channel) ? PCPHostFlags1.Relay : 0) |
     (PeerCast.AccessController.IsChannelPlayable(Channel) ? PCPHostFlags1.Direct : 0) |
     ((!PeerCast.IsFirewalled.HasValue || PeerCast.IsFirewalled.Value) ? PCPHostFlags1.Firewalled : 0) |
     (RecvRate>0 ? PCPHostFlags1.Receiving : 0));
       host.SetHostUphostIP(RemoteEndPoint.Address);
       host.SetHostUphostPort(RemoteEndPoint.Port);
       return new Atom(Atom.PCP_HOST, host);
 }
开发者ID:peca-dev,项目名称:peercaststation,代码行数:42,代码来源:PCPSourceStream.cs


示例15: OnPCPBcst

 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);
       }
 }
开发者ID:peca-dev,项目名称:peercaststation,代码行数:24,代码来源:PCPOutputStream.cs


示例16: PingHost

 protected virtual bool PingHost(IPEndPoint target, Guid remote_session_id)
 {
     Logger.Debug("Ping requested. Try to ping: {0}({1})", target, remote_session_id);
       bool result = false;
       try {
     var client = new System.Net.Sockets.TcpClient();
     client.Connect(target);
     client.ReceiveTimeout = 3000;
     client.SendTimeout    = 3000;
     var stream = client.GetStream();
     var conn = new Atom(Atom.PCP_CONNECT, 1);
     AtomWriter.Write(stream, conn);
     var helo = new AtomCollection();
     helo.SetHeloSessionID(PeerCast.SessionID);
     AtomWriter.Write(stream, new Atom(Atom.PCP_HELO, helo));
     var res = AtomReader.Read(stream);
     if (res.Name==Atom.PCP_OLEH) {
       var session_id = res.Children.GetHeloSessionID();
       if (session_id.HasValue && session_id.Value==remote_session_id) {
     Logger.Debug("Ping succeeded");
     result = true;
       }
       else {
     Logger.Debug("Ping failed. Remote SessionID mismatched");
       }
     }
     AtomWriter.Write(stream, new Atom(Atom.PCP_QUIT, Atom.PCP_ERROR_QUIT));
     stream.Close();
     client.Close();
       }
       catch (InvalidDataException e) {
     Logger.Debug("Ping failed");
     Logger.Debug(e);
       }
       catch (System.Net.Sockets.SocketException e) {
     Logger.Debug("Ping failed");
     Logger.Debug(e);
       }
       catch (EndOfStreamException e) {
     Logger.Debug("Ping failed");
     Logger.Debug(e);
       }
       catch (System.IO.IOException io_error) {
     Logger.Debug("Ping failed");
     Logger.Debug(io_error);
     if (!(io_error.InnerException is System.Net.Sockets.SocketException)) {
       throw;
     }
       }
       return result;
 }
开发者ID:peca-dev,项目名称:peercaststation,代码行数:51,代码来源:PCPOutputStream.cs


示例17: PingHost

 private async Task<bool> PingHost(IPEndPoint target, Guid remote_session_id, CancellationToken cancel_token)
 {
   Logger.Debug("Ping requested. Try to ping: {0}({1})", target, remote_session_id);
   bool result = false;
   try {
     var client = new System.Net.Sockets.TcpClient();
     client.ReceiveTimeout = 2000;
     client.SendTimeout    = 2000;
     await client.ConnectAsync(target.Address, target.Port);
     var stream = client.GetStream();
     await stream.WriteAsync(new Atom(Atom.PCP_CONNECT, 1), cancel_token);
     var helo = new AtomCollection();
     helo.SetHeloSessionID(PeerCast.SessionID);
     await stream.WriteAsync(new Atom(Atom.PCP_HELO, helo), cancel_token);
     var res = await stream.ReadAtomAsync(cancel_token);
     if (res.Name==Atom.PCP_OLEH) {
       var session_id = res.Children.GetHeloSessionID();
       if (session_id.HasValue && session_id.Value==remote_session_id) {
         Logger.Debug("Ping succeeded");
         result = true;
       }
       else {
         Logger.Debug("Ping failed. Remote SessionID mismatched");
       }
     }
     await stream.WriteAsync(new Atom(Atom.PCP_QUIT, Atom.PCP_ERROR_QUIT), cancel_token);
     stream.Close();
     client.Close();
   }
   catch (InvalidDataException e) {
     Logger.Debug("Ping failed");
     Logger.Debug(e);
   }
   catch (System.Net.Sockets.SocketException e) {
     Logger.Debug("Ping failed");
     Logger.Debug(e);
   }
   catch (EndOfStreamException e) {
     Logger.Debug("Ping failed");
     Logger.Debug(e);
   }
   catch (System.IO.IOException io_error) {
     Logger.Debug("Ping failed");
     Logger.Debug(io_error);
     if (!(io_error.InnerException is System.Net.Sockets.SocketException)) {
       throw;
     }
   }
   return result;
 }
开发者ID:kumaryu,项目名称:peercaststation,代码行数:50,代码来源:PCPOutputStream.cs


示例18: OnChannelInfoChanged

 private void OnChannelInfoChanged(AtomCollection info)
 {
     contents.ChannelInfo = new ChannelInfo(info);
 }
开发者ID:At-sushi,项目名称:peercaststation,代码行数:4,代码来源:FLVContentBuffer.cs


示例19: CreateChannelTrack

 private ChannelTrack CreateChannelTrack(BroadcastViewModel viewModel)
 {
     var collection = new AtomCollection();
       collection.SetChanTrackTitle(viewModel.TrackTitle);
       collection.SetChanTrackGenre(viewModel.TrackGenre);
       collection.SetChanTrackAlbum(viewModel.TrackAlbum);
       collection.SetChanTrackCreator(viewModel.TrackArtist);
       collection.SetChanTrackURL(viewModel.TrackUrl);
       return new ChannelTrack(collection);
 }
开发者ID:psjp,项目名称:peercaststation,代码行数:10,代码来源:BroadcastViewModel.cs


示例20: CreateChannelInfo

 private ChannelInfo CreateChannelInfo(BroadcastViewModel viewModel)
 {
     var info = new AtomCollection();
       if (viewModel.bitrate.HasValue) info.SetChanInfoBitrate(viewModel.bitrate.Value);
       info.SetChanInfoName(viewModel.channelName);
       info.SetChanInfoGenre(viewModel.genre);
       info.SetChanInfoDesc(viewModel.description);
       info.SetChanInfoComment(viewModel.comment);
       info.SetChanInfoURL(viewModel.contactUrl);
       return new ChannelInfo(info);
 }
开发者ID:psjp,项目名称:peercaststation,代码行数:11,代码来源:BroadcastViewModel.cs



注:本文中的AtomCollection类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# AtomicBoolean类代码示例发布时间:2022-05-24
下一篇:
C# Atom类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap