当前位置: 首页>>代码示例>>C#>>正文


C# AtomCollection.SetHeloBCID方法代码示例

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


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

示例1: AnnounceThreadProc

 private void AnnounceThreadProc()
 {
     Logger.Debug("Thread started");
       var host = Uri.DnsSafeHost;
       var port = Uri.Port;
       if (port<0) port = PCPVersion.DefaultPort;
       while (!IsStopped) {
     int next_update = Environment.TickCount;
     posts.Clear();
     try {
       Logger.Debug("Connecting to YP");
       AnnouncingStatus = AnnouncingStatus.Connecting;
       using (var client = new TcpClient(host, port)) {
     remoteEndPoint = (IPEndPoint)client.Client.RemoteEndPoint;
     using (var stream = client.GetStream()) {
       AtomWriter.Write(stream, new Atom(new ID4("pcp\n"), (int)1));
       var helo = new AtomCollection();
       Logger.Debug("Sending Handshake");
       helo.SetHeloAgent(PeerCast.AgentName);
       helo.SetHeloVersion(1218);
       helo.SetHeloSessionID(PeerCast.SessionID);
       helo.SetHeloBCID(PeerCast.BroadcastID);
       if (PeerCast.IsFirewalled.HasValue) {
         if (PeerCast.IsFirewalled.Value) {
           //Do nothing
         }
         else {
           var listener = PeerCast.FindListener(
             ((IPEndPoint)client.Client.RemoteEndPoint).Address,
             OutputStreamType.Relay | OutputStreamType.Metadata);
           if (listener!=null) {
             helo.SetHeloPort(listener.LocalEndPoint.Port);
           }
         }
       }
       else {
         var listener = PeerCast.FindListener(
           ((IPEndPoint)client.Client.RemoteEndPoint).Address,
           OutputStreamType.Relay | OutputStreamType.Metadata);
         if (listener!=null) {
           helo.SetHeloPing(listener.LocalEndPoint.Port);
         }
       }
       AtomWriter.Write(stream, new Atom(Atom.PCP_HELO, helo));
       while (!IsStopped) {
         var atom = AtomReader.Read(stream);
         if (atom.Name==Atom.PCP_OLEH) {
           OnPCPOleh(atom);
           break;
         }
         else if (atom.Name==Atom.PCP_QUIT) {
           Logger.Debug("Handshake aborted by PCP_QUIT ({0})", atom.GetInt32());
           throw new QuitException();
         }
         if (restartEvent.WaitOne(10)) throw new RestartException();
       }
       Logger.Debug("Handshake succeeded");
       AnnouncingStatus = AnnouncingStatus.Connected;
       while (!IsStopped) {
         if (next_update-Environment.TickCount<=0) {
           Logger.Debug("Sending channel info");
           lock (announcingChannels) {
             foreach (var announcing in announcingChannels) {
               PostChannelBcst(announcing.Channel, true);
             }
           }
           next_update = Environment.TickCount+30000;
         }
         if (stream.DataAvailable) {
           Atom atom = AtomReader.Read(stream);
           ProcessAtom(atom);
         }
         lock (posts) {
           foreach (var atom in posts) {
             AtomWriter.Write(stream, atom);
           }
           posts.Clear();
         }
         if (restartEvent.WaitOne(10)) throw new RestartException();
       }
       lock (posts) {
         foreach (var atom in posts) {
           AtomWriter.Write(stream, atom);
         }
         posts.Clear();
       }
       Logger.Debug("Closing connection");
       AtomWriter.Write(stream, new Atom(Atom.PCP_QUIT, Atom.PCP_ERROR_QUIT));
     }
       }
     }
     catch (RestartException) {
       Logger.Debug("Connection retrying");
       AnnouncingStatus = AnnouncingStatus.Connecting;
     }
     catch (BannedException) {
       AnnouncingStatus = AnnouncingStatus.Error;
       Logger.Error("Your BCID is banned");
       break;
     }
//.........这里部分代码省略.........
开发者ID:psjp,项目名称:peercaststation,代码行数:101,代码来源:PCPYellowPageClient.cs


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