本文整理汇总了C#中NetworkClient.SendEncrypted方法的典型用法代码示例。如果您正苦于以下问题:C# NetworkClient.SendEncrypted方法的具体用法?C# NetworkClient.SendEncrypted怎么用?C# NetworkClient.SendEncrypted使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetworkClient
的用法示例。
在下文中一共展示了NetworkClient.SendEncrypted方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RequestCityToken
/// <summary>
/// Requests a token from the LoginServer, that can be used to log into a CityServer.
/// </summary>
/// <param name="Client">A NetworkClient instance.</param>
public static void RequestCityToken(NetworkClient Client, Sim SelectedCharacter)
{
PacketStream Packet = new PacketStream((byte)PacketType.REQUEST_CITY_TOKEN, 0);
Packet.WritePascalString(Client.ClientEncryptor.Username);
Packet.WritePascalString(SelectedCharacter.ResidingCity.UUID);
Packet.WritePascalString(SelectedCharacter.GUID.ToString());
Client.SendEncrypted((byte)PacketType.REQUEST_CITY_TOKEN, Packet.ToArray());
}
示例2: RequestCityToken
/// <summary>
/// Requests a token from the LoginServer, that can be used to log into a CityServer.
/// </summary>
/// <param name="Client">A NetworkClient instance.</param>
public static void RequestCityToken(NetworkClient Client)
{
PacketStream Packet = new PacketStream((byte)PacketType.REQUEST_CITY_TOKEN, 0);
Packet.WriteHeader();
Packet.WriteByte((byte)PacketHeaders.ENCRYPTED + 2);
Packet.WriteByte(0x01); //Dummy
Client.SendEncrypted((byte)PacketType.CITY_TOKEN, Packet.ToArray());
}
示例3: OnCharacterInfoResponse
/// <summary>
/// LoginServer sent information about the player's characters.
/// </summary>
/// <param name="Packet">The packet that was received.</param>
public static void OnCharacterInfoResponse(ProcessedPacket Packet, NetworkClient Client)
{
//If the decrypted length == 1, it means that there were 0
//characters that needed to be updated, or that the user
//hasn't created any characters on his/her account yet.
//Since the Packet.Length property is equal to the length
//of the encrypted data, it cannot be used to get the length
//of the decrypted data.
if (Packet.DecryptedLength > 1)
{
byte NumCharacters = (byte)Packet.ReadByte();
List<Sim> FreshSims = new List<Sim>();
for (int i = 0; i < NumCharacters; i++)
{
int CharacterID = Packet.ReadInt32();
Sim FreshSim = new Sim(Packet.ReadString());
FreshSim.CharacterID = CharacterID;
FreshSim.Timestamp = Packet.ReadString();
FreshSim.Name = Packet.ReadString();
FreshSim.Sex = Packet.ReadString();
FreshSim.Description = Packet.ReadString();
FreshSim.HeadOutfitID = Packet.ReadUInt64();
FreshSim.BodyOutfitID = Packet.ReadUInt64();
FreshSim.AppearanceType = (SimsLib.ThreeD.AppearanceType)Packet.ReadByte();
FreshSim.ResidingCity = new CityInfo(Packet.ReadString(), "", Packet.ReadUInt64(), Packet.ReadString(),
Packet.ReadUInt64(), Packet.ReadString(), Packet.ReadInt32());
FreshSims.Add(FreshSim);
}
NetworkFacade.Avatars = FreshSims;
Cache.CacheSims(FreshSims);
}
PacketStream CityInfoRequest = new PacketStream(0x06, 0);
CityInfoRequest.WriteByte(0x00); //Dummy
Client.SendEncrypted((byte)PacketType.CITY_LIST, CityInfoRequest.ToArray());
}
示例4: OnLoginNotifyCity
/// <summary>
/// Received initial packet from CityServer.
/// </summary>
public static void OnLoginNotifyCity(NetworkClient Client, ProcessedPacket Packet)
{
LogThis.Log.LogThis("Received OnLoginNotifyCity!", LogThis.eloglevel.info);
//Should this be stored for permanent access?
byte[] ServerPublicKey = Packet.ReadBytes(Packet.ReadByte());
byte[] EncryptedData = Packet.ReadBytes(Packet.ReadByte());
lock (Client.ClientEncryptor)
{
AESEncryptor Enc = (AESEncryptor)Client.ClientEncryptor;
Enc.PublicKey = ServerPublicKey;
Client.ClientEncryptor = Enc;
lock (NetworkFacade.Client)
NetworkFacade.Client.ClientEncryptor = Enc;
}
ECDiffieHellmanCng PrivateKey = Client.ClientEncryptor.GetDecryptionArgsContainer().AESDecryptArgs.PrivateKey;
byte[] NOnce = Client.ClientEncryptor.GetDecryptionArgsContainer().AESDecryptArgs.NOnce;
byte[] ChallengeResponse = StaticStaticDiffieHellman.Decrypt(PrivateKey,
ECDiffieHellmanCngPublicKey.FromByteArray(ServerPublicKey, CngKeyBlobFormat.EccPublicBlob),
NOnce, EncryptedData);
MemoryStream StreamToEncrypt = new MemoryStream();
BinaryWriter Writer = new BinaryWriter(StreamToEncrypt);
Writer.Write((byte)ChallengeResponse.Length);
Writer.Write(ChallengeResponse, 0, ChallengeResponse.Length);
Writer.Flush();
//Encrypt data using key and IV from server, hoping that it'll be decrypted correctly at the other end...
Client.SendEncrypted((byte)PacketType.CHALLENGE_RESPONSE, StreamToEncrypt.ToArray());
}
示例5: OnCharacterInfoResponse
/// <summary>
/// LoginServer sent information about the player's characters.
/// </summary>
/// <param name="Packet">The packet that was received.</param>
public static void OnCharacterInfoResponse(ProcessedPacket Packet, NetworkClient Client)
{
byte NumCharacters = (byte)Packet.ReadByte();
byte NewCharacters = (byte)Packet.ReadByte();
List<UISim> FreshSims = new List<UISim>();
for (int i = 0; i < NewCharacters; i++)
{
int CharacterID = Packet.ReadInt32();
UISim FreshSim = new UISim(Packet.ReadString(), false);
FreshSim.CharacterID = CharacterID;
FreshSim.Timestamp = Packet.ReadString();
FreshSim.Name = Packet.ReadString();
FreshSim.Sex = Packet.ReadString();
FreshSim.Description = Packet.ReadString();
FreshSim.HeadOutfitID = Packet.ReadUInt64();
FreshSim.BodyOutfitID = Packet.ReadUInt64();
FreshSim.Avatar.Appearance = (AppearanceType)Packet.ReadByte();
FreshSim.ResidingCity = new CityInfo(false);
FreshSim.ResidingCity.Name = Packet.ReadString();
FreshSim.ResidingCity.Thumbnail = Packet.ReadUInt64();
FreshSim.ResidingCity.UUID = Packet.ReadString();
FreshSim.ResidingCity.Map = Packet.ReadUInt64();
FreshSim.ResidingCity.IP = Packet.ReadString();
FreshSim.ResidingCity.Port = Packet.ReadInt32();
FreshSims.Add(FreshSim);
}
lock (NetworkFacade.Avatars)
{
if ((NumCharacters < 3) && (NewCharacters > 0))
{
FreshSims = Cache.LoadCachedSims(FreshSims);
NetworkFacade.Avatars = FreshSims;
Cache.CacheSims(FreshSims);
}
if (NewCharacters == 0 && NumCharacters > 0)
NetworkFacade.Avatars = Cache.LoadAllSims();
else if (NewCharacters == 3 && NumCharacters == 3)
{
NetworkFacade.Avatars = FreshSims;
Cache.CacheSims(FreshSims);
}
else if (NewCharacters == 0 && NumCharacters == 0)
{
//Make sure if sims existed in the cache, they are deleted (because they didn't exist in DB).
Cache.DeleteCache();
}
else if (NumCharacters == 3 && NewCharacters == 3)
{
NetworkFacade.Avatars = FreshSims;
}
}
PacketStream CityInfoRequest = new PacketStream(0x06, 0);
CityInfoRequest.WriteByte(0x00); //Dummy
Client.SendEncrypted((byte)PacketType.CITY_LIST, CityInfoRequest.ToArray());
}
示例6: SendCharacterCreateCity
/// <summary>
/// Sends a CharacterCreate packet to a CityServer.
/// </summary>
/// <param name="LoginArgs">Arguments used to log onto the CityServer.</param>
/// <param name="Character">The character to create on the CityServer.</param>
public static void SendCharacterCreateCity(NetworkClient Client, UISim Character)
{
PacketStream Packet = new PacketStream((byte)PacketType.CHARACTER_CREATE_CITY, 0);
MemoryStream PacketData = new MemoryStream();
BinaryWriter Writer = new BinaryWriter(PacketData);
Writer.Write((byte)Client.ClientEncryptor.Username.Length);
Writer.Write(Encoding.ASCII.GetBytes(Client.ClientEncryptor.Username), 0,
Encoding.ASCII.GetBytes(Client.ClientEncryptor.Username).Length);
Writer.Write(PlayerAccount.CityToken);
Writer.Write(Character.Timestamp);
Writer.Write(Character.Name);
Writer.Write(Character.Sex);
Writer.Write(Character.Description);
Writer.Write((ulong)Character.HeadOutfitID);
Writer.Write((ulong)Character.BodyOutfitID);
Writer.Write((byte)Character.Avatar.Appearance);
Packet.WriteBytes(PacketData.ToArray());
Writer.Close();
Client.SendEncrypted((byte)PacketType.CHARACTER_CREATE_CITY, Packet.ToArray());
}
示例7: SendLotPurchaseRequest
/// <summary>
/// Sends a request to purchase a lot.
/// </summary>
/// <param name="Client">NetworkClient instance connected to city server.</param>
/// <param name="X">X-coordinate of lot.</param>
/// <param name="Y">Y-coordinate of lot.</param>
public static void SendLotPurchaseRequest(NetworkClient Client, short X, short Y)
{
PacketStream Packet = new PacketStream((byte)PacketType.LOT_PURCHASE_REQUEST, 0);
Packet.WriteUInt16((ushort)X);
Packet.WriteUInt16((ushort)Y);
Client.SendEncrypted((byte)PacketType.LOT_PURCHASE_REQUEST, Packet.ToArray());
}
示例8: SendLetter
public static void SendLetter(NetworkClient Client, string Msg, string Subject, string GUID)
{
PacketStream Packet = new PacketStream((byte)PacketType.PLAYER_SENT_LETTER, 0);
Packet.WriteString(GUID);
Packet.WriteString(Subject);
Packet.WriteString(Msg);
Client.SendEncrypted((byte)PacketType.PLAYER_SENT_LETTER, Packet.ToArray());
}
示例9: SendCityToken
/// <summary>
/// Sends a token to a CityServer, as received by a LoginServer.
/// </summary>
/// <param name="Client">A NetworkClient instance.</param>
public static void SendCityToken(NetworkClient Client)
{
PacketStream Packet = new PacketStream((byte)PacketType.CITY_TOKEN, 0);
MemoryStream PacketData = new MemoryStream();
BinaryWriter Writer = new BinaryWriter(PacketData);
Writer.Write(PlayerAccount.CityToken);
Packet.WriteBytes(PacketData.ToArray());
Writer.Close();
Client.SendEncrypted((byte)PacketType.CITY_TOKEN, Packet.ToArray());
}