本文整理汇总了C#中DataStream.ReadBytes方法的典型用法代码示例。如果您正苦于以下问题:C# DataStream.ReadBytes方法的具体用法?C# DataStream.ReadBytes怎么用?C# DataStream.ReadBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataStream
的用法示例。
在下文中一共展示了DataStream.ReadBytes方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Deserialize
internal void Deserialize( DataStream ds )
{
ChunkGID = ds.ReadBytes( 20 );
CRC = ds.ReadBytes( 4 );
Offset = ds.ReadUInt64();
DecompressedSize = ds.ReadUInt32();
CompressedSize = ds.ReadUInt32();
}
示例2: GetAuthServerList
/// <summary>
/// Gets an auth server list for a specific username.
/// </summary>
/// <param name="userName">The username.</param>
/// <returns>A list of servers on success; otherwise, <c>null</c>.</returns>
public IPEndPoint[] GetAuthServerList( string userName )
{
userName = userName.ToLower();
byte[] userHash = CryptoHelper.JenkinsHash( Encoding.ASCII.GetBytes( userName ) );
uint userData = BitConverter.ToUInt32( userHash, 0 ) & 1;
TcpPacket packet = base.GetRawServerList( ESteam2ServerType.ProxyASClientAuthentication, NetHelpers.EndianSwap( userData ) );
if ( packet == null )
return null;
DataStream ds = new DataStream( packet.GetPayload(), true );
ushort numAddrs = ds.ReadUInt16();
IPEndPoint[] serverList = new IPEndPoint[ numAddrs ];
for ( int x = 0 ; x < numAddrs ; ++x )
{
IPAddrPort ipAddr = IPAddrPort.Deserialize( ds.ReadBytes( 6 ) );
serverList[ x ] = ipAddr;
}
return serverList;
}
示例3: Deserialize
internal void Deserialize( DataStream ds )
{
Magic = ds.ReadUInt16();
uint length = ds.ReadUInt32();
Index = ds.ReadUInt32();
Data = ds.ReadBytes( length );
}
示例4: GetContentServerList
/// <summary>
/// Gets a list of all currently active content servers.
/// </summary>
/// <returns>A list of servers on success; otherwise, <c>null</c>.</returns>
public IPEndPoint[] GetContentServerList()
{
TcpPacket packet = base.GetRawServerList( 3 ); // command 3
if ( packet == null )
return null;
DataStream ds = new DataStream( packet.GetPayload(), true );
ushort numAddrs = ds.ReadUInt16();
IPEndPoint[] serverList = new IPEndPoint[ numAddrs ];
for ( int x = 0 ; x < numAddrs ; ++x )
{
IPAddrPort ipAddr = IPAddrPort.Deserialize( ds.ReadBytes( 6 ) );
serverList[ x ] = ipAddr;
}
return serverList;
}
示例5: GetServerList
/// <summary>
/// Gets the server list for a specific server type.
/// </summary>
/// <param name="type">The server type.</param>
/// <returns>A list of servers on success; otherwise, <c>null</c>.</returns>
public IPEndPoint[] GetServerList( ESteam2ServerType type )
{
TcpPacket packet = this.GetRawServerList( ( byte )type );
if ( packet == null )
return null;
DataStream ds = new DataStream( packet.GetPayload(), true );
ushort numAddrs = ds.ReadUInt16();
IPEndPoint[] serverList = new IPEndPoint[ numAddrs ];
for ( int x = 0 ; x < numAddrs ; ++x )
{
IPAddrPort ipAddr = IPAddrPort.Deserialize( ds.ReadBytes( 6 ) );
serverList[ x ] = ipAddr;
}
return serverList;
}
示例6: HandleMulti
void HandleMulti( IPacketMsg packetMsg )
{
if ( !packetMsg.IsProto )
{
DebugLog.WriteLine( "CMClient", "HandleMulti got non-proto MsgMulti!!" );
return;
}
var msgMulti = new ClientMsgProtobuf<CMsgMulti>( packetMsg );
byte[] payload = msgMulti.Body.message_body;
if ( msgMulti.Body.size_unzipped > 0 )
{
try
{
payload = ZipUtil.Decompress( payload );
}
catch ( Exception ex )
{
DebugLog.WriteLine( "CMClient", "HandleMulti encountered an exception when decompressing.\n{0}", ex.ToString() );
return;
}
}
DataStream ds = new DataStream( payload );
while ( ds.SizeRemaining() != 0 )
{
uint subSize = ds.ReadUInt32();
byte[] subData = ds.ReadBytes( subSize );
OnClientMsgReceived( GetPacketMsg( subData ) );
}
}
示例7: GetServersFromPacket
static ContentServer[] GetServersFromPacket( TcpPacket packet )
{
DataStream ds = new DataStream( packet.GetPayload(), true );
ushort numAddrs = ds.ReadUInt16();
ContentServer[] serverList = new ContentServer[ numAddrs ];
for ( int x = 0 ; x < numAddrs ; ++x )
{
uint weighedLoad = ds.ReadUInt32();
IPAddrPort ipAddr = IPAddrPort.Deserialize( ds.ReadBytes( 6 ) );
IPAddrPort ipAddr2 = IPAddrPort.Deserialize( ds.ReadBytes( 6 ) );
serverList[ x ] = new ContentServer()
{
Load = weighedLoad,
PackageServer = ipAddr,
StorageServer = ipAddr2,
};
}
return serverList;
}