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


C# MemBlock.ToBase16String方法代码示例

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


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

示例1: Announce

    /**
     * When a packet is to be delivered to this node,
     * this method is called.  This method is public so that
     * we can chain protocols through the node.  For instance,
     * after a packet is handled, it may be a wrapped packet
     * which actually contains another packet inside.  Thus,
     * the unwrapped packet could be "Announced" by the handler
     *
     * One needs to be careful to prevent an infinite loop of
     * a Handler announcing the packet it is supposed to handle.
     */
    protected virtual void Announce(MemBlock b, ISender from)
    {
      //When Subscribe or unsubscribe are called,
      //they make copies of the ArrayList, thus we
      //only need to hold the sync while we are
      //getting the list of handlers.

      /* 
       * Note that getting from Hashtable is threadsafe, multiple
       * threads writing is a problem
       */
      MemBlock payload = null;
      int handlers = 0;
      MultiSource ns = null;
      PType t = null;
      try {
        t = PType.Parse(b, out payload);
        ns = (MultiSource)DemuxHandler.GetTypeSource(t);
        handlers = ns.Announce(payload, from);
        /**
         * @todo if no one handled the packet, we might want to send some
         * ICMP-like message.
         */
        if( handlers == 0 ) {
          string p_s = payload.GetString(System.Text.Encoding.ASCII);
          ProtocolLog.WriteIf(ProtocolLog.Exceptions, String.Format(
            "No Handler for packet type: {0} from: {2}\n{1} :: {3}", t, p_s, from, b.ToBase16String()));
        }
      }
      catch(Exception x) {
        ProtocolLog.WriteIf(ProtocolLog.Exceptions, String.Format(
          "Packet Handling Exception"));
        string nodeSource = "null";
        if (ns != null) {
          nodeSource = ns.ToString();
        }
        ProtocolLog.WriteIf(ProtocolLog.Exceptions, String.Format(
          "Handler: {0}\tEdge: {1}", nodeSource, from));
        ProtocolLog.WriteIf(ProtocolLog.Exceptions, String.Format(
          "Exception: {0}", x));
      }
    }
开发者ID:hseom,项目名称:brunet,代码行数:53,代码来源:Node.cs


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