本文整理汇总了C#中PacketReader.ReadBuffer方法的典型用法代码示例。如果您正苦于以下问题:C# PacketReader.ReadBuffer方法的具体用法?C# PacketReader.ReadBuffer怎么用?C# PacketReader.ReadBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PacketReader
的用法示例。
在下文中一共展示了PacketReader.ReadBuffer方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadAuthLogonProof
/// <summary>
///
/// </summary>
/// <param name="packetReader"></param>
/// <returns></returns>
public static AuthLogonProof ReadAuthLogonProof( PacketReader packetReader )
{
AuthLogonProof authLogonProof = new AuthLogonProof();
authLogonProof.CommandID = packetReader.ReadByte();
packetReader.ReadBuffer( ref authLogonProof.m_iA, 0, authLogonProof.m_iA.Length );
authLogonProof.m_iBigIntegerA = new BigInteger( authLogonProof.m_iA );
packetReader.ReadBuffer( ref authLogonProof.m_iProof, 0, authLogonProof.m_iProof.Length );
authLogonProof.m_iBigIntegerProof = new BigInteger( authLogonProof.m_iProof );
packetReader.ReadBuffer( ref authLogonProof.m_iCrcHash, 0, authLogonProof.m_iCrcHash.Length );
authLogonProof.NumberOfKeys = packetReader.ReadByte();
authLogonProof.Unknown = packetReader.ReadByte();
return authLogonProof;
}
示例2: InternalCallbackAuthenticate
/// <summary>
///
/// </summary>
internal static void InternalCallbackAuthenticate( NetState netState, PacketReader packetReader )
{
WorldExtendData worldExtendData = netState.GetComponent<WorldExtendData>( WorldExtendData.COMPONENT_ID );
if ( worldExtendData == null )
{
Debug.WriteLine( "World_PacketHandlers.World_HandleAuthSession(...) - worldExtendData == null error!" );
netState.Send( new Word_AuthResponseError( ResponseCodes.AUTH_FAILED ) );
return;
}
if ( worldExtendData.IsLoggedIn == true )
{
Debug.WriteLine( "World_PacketHandlers.World_HandleAuthSession(...) - worldExtendData.IsLoggedIn == true error!" );
netState.Send( new Word_AuthResponseError( ResponseCodes.AUTH_FAILED ) );
return;
}
bool isNoError = packetReader.ReadBoolean();
if ( isNoError == false )
{
netState.Send( new Word_AuthResponseError( ResponseCodes.AUTH_FAILED ) );
return;
}
// 读取数据
uint iAccountsGuid = packetReader.ReadUInt32();
AccessLevel iAccessLevel = (AccessLevel)packetReader.ReadInt32();
bool bIsTBC = packetReader.ReadBoolean();
byte[] byteSessionKey = new byte[40];
packetReader.ReadBuffer( ref byteSessionKey, 0, 40 );
// 开始鉴别
SHA1 sha1 = new SHA1CryptoServiceProvider();
byte[] byteAccountName = worldExtendData.AuthSession.AccountName.ToArrayInByte( Encoding.ASCII );
byte[] byteT = ( (uint)0 ).ToArrayInByte();
byte[] byteClientSeed = ( (uint)worldExtendData.AuthSession.ClientSeed ).ToArrayInByte();
byte[] byteSeed = ( (uint)worldExtendData.ServerSeed ).ToArrayInByte();
byte[] tempData0 = byteAccountName.Coalition( byteT );
byte[] tempData1 = tempData0.Coalition( byteClientSeed );
byte[] tempData2 = tempData1.Coalition( byteSeed );
byte[] tempData3 = tempData2.Coalition( byteSessionKey );
byte[] byteResult = sha1.ComputeHash( tempData3 );
// 是否成功
bool bIsOK = Algorithms.EqualCollections( byteResult, worldExtendData.AuthSession.Digest );
if ( bIsOK == false )
{
netState.Send( new Word_AuthResponseError( (uint)ResponseCodes.AUTH_UNKNOWN_ACCOUNT ) );
return;
}
// 初始化 加解密的Key
worldExtendData.WowCrypt.InitKey( byteSessionKey, 40 );
worldExtendData.CommonData.AccountsGuid = iAccountsGuid;
worldExtendData.CommonData.AccountName = worldExtendData.AuthSession.AccountName;
worldExtendData.CommonData.IsTBC = bIsTBC;
//WowPlayerInfo wowPlayerInfo = new WowPlayerInfo();
//wowPlayerInfo.AccessLevel = iAccessLevel;
//wowPlayerInfo.AccountName = worldExtendData.AuthSession.AccountName;
//wowPlayerInfo.Serial = iAccountsGuid;
//wowPlayerInfo.ClientBuild = worldExtendData.AuthSession.ClientBuild;
//wowPlayerInfo.LastPing = DateTime.Now;
//wowPlayerInfo.IsTBC = bIsTBC;
//wowPlayerInfo.NetState = netState;
//Program.BaseWorld.CharacterManager.AddCharacter( wowPlayerInfo.Serial, wowPlayerInfo );
if ( ProcessServer.WowZoneCluster.World.CharacterManager.Count < 600 || iAccessLevel == AccessLevel.GameMaster )
{
worldExtendData.IsLoggedIn = true;
netState.Send( new Word_AuthResponse( bIsTBC ) );
if ( worldExtendData.AuthSession.AddonInfo != null )
netState.Send( worldExtendData.AuthSession.AddonInfo );
}
else
{
// 等待玩家的减少
WaitQueueLogins.Enqueue( netState );
}
}
示例3: ReadAuthLogonChallenge
/// <summary>
///
/// </summary>
/// <param name="packetReader"></param>
/// <returns></returns>
public static AuthLogonChallenge ReadAuthLogonChallenge( PacketReader packetReader )
{
AuthLogonChallenge authLogonChallenge = new AuthLogonChallenge();
authLogonChallenge.CommandID = packetReader.ReadByte();
authLogonChallenge.ErrorInfo = packetReader.ReadByte();
authLogonChallenge.PackSize = packetReader.ReadUInt16();
packetReader.ReadBuffer( ref authLogonChallenge.m_iGameName, 0, 4 );
authLogonChallenge.GameName = authLogonChallenge.m_iGameName.ConvertToString();
authLogonChallenge.Version1 = packetReader.ReadByte();
authLogonChallenge.Version2 = packetReader.ReadByte();
authLogonChallenge.Version3 = packetReader.ReadByte();
authLogonChallenge.Build = packetReader.ReadUInt16();
packetReader.ReadBuffer( ref authLogonChallenge.m_iPlatform, 0, 4 );
authLogonChallenge.Platform = authLogonChallenge.m_iPlatform.ConvertToString();
packetReader.ReadBuffer( ref authLogonChallenge.m_iOS, 0, 4 );
authLogonChallenge.OS = authLogonChallenge.m_iOS.ConvertToString();
packetReader.ReadBuffer( ref authLogonChallenge.m_iCountry, 0, 4 );
authLogonChallenge.Country = authLogonChallenge.m_iCountry.ConvertToString();
authLogonChallenge.TimeZoneBias = packetReader.ReadUInt32();
authLogonChallenge.IP = packetReader.ReadUInt32();
authLogonChallenge.AccountNameLength = packetReader.ReadByte();
// 不用了
//packetReader.ReadBuffer( ref authLogonChallenge.m_iAccountName, 0, authLogonChallenge.AccountNameLength );
//authLogonChallenge.AccountName = Utility.ByteArrayToString( authLogonChallenge.AccountName, 0, authLogonChallenge.AccountNameLength );
authLogonChallenge.AccountName = packetReader.ReadUTF8StringSafe();
return authLogonChallenge;
}
示例4: ReadWorldAuthSession
/// <summary>
///
/// </summary>
/// <param name="packetReader"></param>
/// <returns></returns>
public static AuthSession ReadWorldAuthSession( PacketReader packetReader )
{
AuthSession worldAuthSession = new AuthSession();
worldAuthSession.m_iClientBuild = packetReader.ReadUInt32();
worldAuthSession.m_iUnknown = packetReader.ReadUInt32();
worldAuthSession.m_strAccountName = packetReader.ReadUTF8StringSafe();
worldAuthSession.m_iClientSeed = packetReader.ReadUInt32();
packetReader.ReadBuffer( ref worldAuthSession.m_byteDigest, 0, 20 );
worldAuthSession.m_RealSize = packetReader.ReadUInt32();
if ( worldAuthSession.m_RealSize <= 0 )
{
Debug.WriteLine( "AuthSession.ReadWorldAuthSession(...) - worldAuthSession.m_RealSize <= 0 error!" );
return worldAuthSession;
}
if ( packetReader.Position + 5 > packetReader.Size )
{
Debug.WriteLine( "AuthSession.ReadWorldAuthSession(...) - packetReader.Position + 5 > packetReader.Size error!" );
return worldAuthSession;
}
byte[] outBuffer = null;
bool bIsOK = MemoryZip.ZlibDecompressor( packetReader.Buffer, (int)packetReader.Position, (int)packetReader.Size - (int)packetReader.Position, out outBuffer );
if ( bIsOK == false )
{
Debug.WriteLine( "AuthSession.ReadWorldAuthSession(...) - bIsOK == false error!" );
return worldAuthSession;
}
worldAuthSession.m_AddonInfo = new Word_AddonInfo( outBuffer );
return worldAuthSession;
}