本文整理汇总了C#中Brunet.MemBlock.ToBase16String方法的典型用法代码示例。如果您正苦于以下问题:C# MemBlock.ToBase16String方法的具体用法?C# MemBlock.ToBase16String怎么用?C# MemBlock.ToBase16String使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Brunet.MemBlock
的用法示例。
在下文中一共展示了MemBlock.ToBase16String方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReceivedPacketEvent
/**
* This method is used by subclasses.
* @param b the packet to send a ReceivedPacket event for
*/
public void ReceivedPacketEvent(MemBlock b)
{
if( 1 == _is_closed ) {
//We should not be receiving packets on closed edges:
throw new EdgeClosedException(
String.Format("Trying to Receive on a Closed Edge: {0}",
this) );
}
try {
_sub.Handle(b, this);
Interlocked.Exchange(ref _last_in_packet_datetime, DateTime.UtcNow.Ticks);
}
catch(System.NullReferenceException) {
//this can happen if _sub is null
//We don't record the time of this packet. We don't
//want unhandled packets to keep edges open.
//
//This packet is going into the trash:
Console.Error.WriteLine("{0} lost packet {1}",this,b.ToBase16String());
}
}
示例2: Parse
/**
* Parse the PType starting at mb, and return all of mb <b>after</b>
* the PType.
*/
public static PType Parse(MemBlock mb, out MemBlock rest) {
PType result = null;
byte fb = mb[0];
bool is_v_n = IsValidNumeric( (int)fb );
/**
* Since ptypes must be valid UTF8 strings,
* if the second byte is null, the first byte is an ascii character
* and hence has a value less than ASCII_UPPER_BOUND
*/
bool store_in_tbl = ( is_v_n || (mb[1] == 0) );
if( store_in_tbl ) {
//This is stored in our table:
result = _table[ fb ];
if( result != null ) {
if( is_v_n ) {
//There is no null
rest = mb.Slice(1);
}
else {
//Skip the null
rest = mb.Slice(2);
}
return result;
}
}
//Otherwise we have to make it:
MemBlock raw_data = null;
result = new PType();
if( is_v_n ) {
/*
* Don't set the raw_data since it is only one byte and we may not need
* it
*/
rest = mb.Slice(1);
result._type_num = (int)fb;
}
else {
int null_pos = mb.IndexOf(0);
if( null_pos > 0 ) {
//Include the "null", but make a copy so we don't keep some data in
//scope for ever
raw_data = MemBlock.Copy( (ICopyable)mb.Slice(0, null_pos + 1) );
rest = mb.Slice(null_pos + 1);
}
else {
//There is no terminating Null, panic!!
throw new ParseException(
System.String.Format("PType not null terminated: {0}", mb.ToBase16String()));
}
result._type_num = -2;
result._raw_data = raw_data;
}
if( store_in_tbl ) {
//Make sure we don't have to create an object like this again
_table[ fb ] = result;
}
return result;
}