本文整理汇总了C#中ProcessedPacket类的典型用法代码示例。如果您正苦于以下问题:C# ProcessedPacket类的具体用法?C# ProcessedPacket怎么用?C# ProcessedPacket使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProcessedPacket类属于命名空间,在下文中一共展示了ProcessedPacket类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: OnCharacterCreationStatus
public static void OnCharacterCreationStatus(NetworkClient Client, ProcessedPacket Packet)
{
CharacterCreationStatus CCStatus = (CharacterCreationStatus)Packet.ReadByte();
switch (CCStatus)
{
case CharacterCreationStatus.Success:
Guid CharacterGUID = new Guid();
//CityToken didn't exist, so transition to CityServer hasn't happened yet.
if (PlayerAccount.CityToken == "")
{
CharacterGUID = new Guid(Packet.ReadPascalString());
PlayerAccount.CityToken = Packet.ReadPascalString();
}
NetworkFacade.Controller._OnCharacterCreationStatus(CCStatus);
if(PlayerAccount.CityToken == "")
PlayerAccount.CurrentlyActiveSim.AssignGUID(CharacterGUID.ToString());
break;
case CharacterCreationStatus.ExceededCharacterLimit:
NetworkFacade.Controller._OnCharacterCreationStatus(CCStatus);
break;
case CharacterCreationStatus.NameAlreadyExisted:
NetworkFacade.Controller._OnCharacterCreationStatus(CCStatus);
break;
case CharacterCreationStatus.GeneralError:
NetworkFacade.Controller._OnCharacterCreationStatus(CCStatus);
break;
default:
break;
}
}
开发者ID:Tranquill6,项目名称:Project-Dollhouse,代码行数:35,代码来源:UIPacketHandlers.cs
示例2: HandleKeyFetch
/// <summary>
/// A cityserver requested a decryptionkey for a client!
/// </summary>
public static void HandleKeyFetch(NetworkClient Client, ProcessedPacket P)
{
string AccountName = P.ReadString();
byte[] EncKey = new byte[1];
foreach (NetworkClient Cl in NetworkFacade.CServerListener.Clients)
{
if (Cl.ClientEncryptor.Username == AccountName)
{
EncKey = Cl.ClientEncryptor.GetDecryptionArgsContainer().ARC4DecryptArgs.EncryptionKey;
//TODO: Figure out what to do about CurrentlyActiveSim...
//if (Cl.CurrentlyActiveSim.CreatedThisSession)
{
//TODO: Update the DB to reflect the city that
// this sim resides in.
//Database.UpdateCityForCharacter(Cl.CurrentlyActiveSim.Name, Client.ServerInfo.Name);
}
}
}
PacketStream OutPacket = new PacketStream(0x01, 0x00);
OutPacket.WriteByte((byte)0x01);
OutPacket.WriteByte((byte)(EncKey.Length + 2));
OutPacket.WriteByte((byte)EncKey.Length);
OutPacket.Write(EncKey, 0, EncKey.Length);
Client.Send(OutPacket.ToArray());
//For now, assume client has already disconnected and doesn't need to be disconnected manually.
NetworkFacade.CServerListener.TransferringClients.Remove(Client);
}
开发者ID:Blayer98,项目名称:Project-Dollhouse,代码行数:35,代码来源:CityServerPacketHandlers.cs
示例3: HandlePlayerOnlineResponse
public static void HandlePlayerOnlineResponse(NetworkClient Client, ProcessedPacket P)
{
byte Result = (byte)P.ReadByte();
string Token = P.ReadString();
//NOTE: Might have to find another way to identify a client, since two people
// can be on the same account from the same IP.
string RemoteIP = P.ReadString();
int RemotePort = P.ReadInt32();
PacketStream Packet;
NetworkClient FoundClient;
switch(Result)
{
case 0x01:
Packet = new PacketStream((byte)PacketType.REQUEST_CITY_TOKEN, 0);
Packet.WriteString(Token);
FoundClient = NetworkFacade.ClientListener.GetClient(RemoteIP, RemotePort);
if(FoundClient != null)
FoundClient.SendEncrypted((byte)PacketType.REQUEST_CITY_TOKEN, Packet.ToArray());
break;
case 0x02: //Write player was already online packet!
Packet = new PacketStream((byte)PacketType.PLAYER_ALREADY_ONLINE, 0);
Packet.WriteByte(0x00); //Dummy
FoundClient = NetworkFacade.ClientListener.GetClient(RemoteIP, RemotePort);
if (FoundClient != null)
FoundClient.SendEncrypted((byte)PacketType.PLAYER_ALREADY_ONLINE, Packet.ToArray());
break;
}
}
开发者ID:ddfczm,项目名称:Project-Dollhouse,代码行数:34,代码来源:CityServerPacketHandlers.cs
示例4: OnCharacterCreationProgress
/// <summary>
/// Received CharacterCreation packet from LoginServer.
/// </summary>
/// <returns>The result of the character creation.</returns>
public static CharacterCreationStatus OnCharacterCreationProgress(NetworkClient Client, ProcessedPacket Packet)
{
CharacterCreationStatus CCStatus = (CharacterCreationStatus)Packet.ReadByte();
if (CCStatus == CharacterCreationStatus.Success)
{
Guid CharacterGUID = new Guid();
CharacterGUID = new Guid(Packet.ReadPascalString());
PlayerAccount.CityToken = Packet.ReadPascalString();
PlayerAccount.CurrentlyActiveSim.AssignGUID(CharacterGUID.ToString());
}
return CCStatus;
}
开发者ID:Blayer98,项目名称:Project-Dollhouse,代码行数:19,代码来源:UIPacketHandlers.cs
示例5: HandleCityServerLogin
/// <summary>
/// A cityserver logged in!
/// </summary>
public static void HandleCityServerLogin(NetworkClient Client, ProcessedPacket P)
{
Logger.LogInfo("CityServer logged in!\r\n");
string Name = P.ReadString();
string Description = P.ReadString();
string IP = P.ReadString();
int Port = P.ReadInt32();
CityInfoStatus Status = (CityInfoStatus)P.ReadByte();
ulong Thumbnail = P.ReadUInt64();
string UUID = P.ReadString();
ulong Map = P.ReadUInt64();
CityInfo Info = new CityInfo(true);
Info.Name = Name;
Info.Description = Description;
Info.IP = IP;
Info.Port = Port;
Info.Status = Status;
Info.Thumbnail = Thumbnail;
Info.UUID = UUID;
Info.Map = Map;
Info.Client = Client;
Info.Online = true;
NetworkFacade.CServerListener.CityServers.Add(Info);
NetworkFacade.CServerListener.PotentialLogins.TryTake(out Client);
NetworkClient[] Clients = new NetworkClient[NetworkFacade.ClientListener.Clients.Count];
NetworkFacade.ClientListener.Clients.CopyTo(Clients, 0);
PacketStream ClientPacket = new PacketStream((byte)PacketType.NEW_CITY_SERVER, 0);
ClientPacket.WriteString(Name);
ClientPacket.WriteString(Description);
ClientPacket.WriteString(IP);
ClientPacket.WriteInt32(Port);
ClientPacket.WriteByte((byte)Status);
ClientPacket.WriteUInt64(Thumbnail);
ClientPacket.WriteString(UUID);
ClientPacket.WriteUInt64(Map);
foreach(NetworkClient Receiver in Clients)
Receiver.SendEncrypted((byte)PacketType.NEW_CITY_SERVER, ClientPacket.ToArray());
}
开发者ID:ddfczm,项目名称:Project-Dollhouse,代码行数:47,代码来源:CityServerPacketHandlers.cs
示例6: OnCharacterCreationProgress
/// <summary>
/// Received CharacterCreation packet from LoginServer.
/// </summary>
/// <returns>The result of the character creation.</returns>
public static CharacterCreationStatus OnCharacterCreationProgress(NetworkClient Client, ProcessedPacket Packet)
{
CharacterCreationStatus CCStatus = (CharacterCreationStatus)Packet.ReadByte();
if (CCStatus == CharacterCreationStatus.Success)
{
Guid CharacterGUID = Guid.NewGuid();
CharacterGUID = new Guid(Packet.ReadString());
PlayerAccount.CityToken = Packet.ReadString();
PlayerAccount.CurrentlyActiveSim.AssignGUID(CharacterGUID.ToString());
//This previously happened when clicking the accept button in CAS, causing
//all chars to be cached even if the new char wasn't successfully created.
lock(NetworkFacade.Avatars)
Cache.CacheSims(NetworkFacade.Avatars);
}
return CCStatus;
}
开发者ID:gamedev1337,项目名称:Project-Dollhouse,代码行数:24,代码来源:UIPacketHandlers.cs
示例7: 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());
}
开发者ID:Tranquill6,项目名称:Project-Dollhouse,代码行数:45,代码来源:UIPacketHandlers.cs
示例8: HandleCityServerLogin
/// <summary>
/// A cityserver logged in!
/// </summary>
public static void HandleCityServerLogin(NetworkClient Client, ProcessedPacket P)
{
CityServerClient CityClient = (CityServerClient)Client;
Logger.LogInfo("CityServer logged in!\r\n");
string Name = P.ReadString();
string Description = P.ReadString();
string IP = P.ReadString();
int Port = P.ReadInt32();
CityInfoStatus Status = (CityInfoStatus)P.ReadByte();
ulong Thumbnail = P.ReadUInt64();
string UUID = P.ReadString();
ulong Map = P.ReadUInt64();
CityInfo Info = new CityInfo(Name, Description, Thumbnail, UUID, Map, IP, Port);
Info.Status = Status;
CityClient.ServerInfo = Info;
//Client instance changed, so update it...
NetworkFacade.CServerListener.UpdateClient(CityClient);
}
开发者ID:Blayer98,项目名称:Project-Dollhouse,代码行数:25,代码来源:CityServerPacketHandlers.cs
示例9: OnCharacterCreationStatus
/// <summary>
/// Received CharacterCreation packet from CityServer.
/// </summary>
/// <returns>The result of the character creation.</returns>
public static CharacterCreationStatus OnCharacterCreationStatus(NetworkClient Client, ProcessedPacket Packet)
{
LogThis.Log.LogThis("Received OnCharacterCreationStatus!", LogThis.eloglevel.info);
CharacterCreationStatus CCStatus = (CharacterCreationStatus)Packet.ReadByte();
ushort NumHouses = Packet.ReadUInt16();
LotTileEntry[] TileEntries = new LotTileEntry[NumHouses];
if (NumHouses > 0)
{
for (int i = 0; i < NumHouses; i++)
{
TileEntries[i] = new LotTileEntry(Packet.ReadInt32(), Packet.ReadString(), (short)Packet.ReadUInt16(),
(short)Packet.ReadUInt16(), (byte)Packet.ReadByte(), Packet.ReadInt32());
}
}
lock(TSOClient.Code.GameFacade.CDataRetriever.LotTileData)
TSOClient.Code.GameFacade.CDataRetriever.LotTileData = TileEntries;
return CCStatus;
}
开发者ID:gamedev1337,项目名称:Project-Dollhouse,代码行数:27,代码来源:UIPacketHandlers.cs
示例10: HandleCharacterInfoRequest
/// <summary>
/// Client requested information about its characters.
/// </summary>
public static void HandleCharacterInfoRequest(NetworkClient Client, ProcessedPacket P)
{
Logger.LogInfo("Received CharacterInfoRequest!");
string DateTimeStr = P.ReadString();
DateTime Timestamp;
if (DateTimeStr != string.Empty)
Timestamp = DateTime.Parse(DateTimeStr);
else
{
//Unix epoch
Timestamp = new DateTime(1970, 1, 1, 0, 0, 1);
}
Character[] Characters = new Character[] { };
using (var db = DataAccess.Get())
{
var account = db.Accounts.GetByUsername(Client.ClientEncryptor.Username);
Characters = db.Characters.GetForAccount((int)account.AccountID).ToArray();
}
int NumChars = 0, NewChars = 0;
if (Characters != null)
{
PacketStream Packet = new PacketStream((byte)PacketType.CHARACTER_LIST, 0);
MemoryStream PacketData = new MemoryStream();
BinaryWriter PacketWriter = new BinaryWriter(PacketData);
NumChars = Characters.Length;
foreach (Character avatar in Characters)
{
//Zero means same, less than zero means T1 is earlier than T2, more than zero means T1 is later.
if (DateTime.Compare(Timestamp, avatar.LastCached) < 0)
{
NewChars++;
PacketWriter.Write((int)avatar.CharacterID);
PacketWriter.Write(avatar.GUID.ToString());
PacketWriter.Write(avatar.LastCached.ToString("yyyy.MM.dd hh:mm:ss",
CultureInfo.InvariantCulture));
PacketWriter.Write(avatar.Name);
PacketWriter.Write(avatar.Sex);
PacketWriter.Write(avatar.Description);
PacketWriter.Write((ulong)avatar.HeadOutfitID);
PacketWriter.Write((ulong)avatar.BodyOutfitID);
PacketWriter.Write((byte)avatar.AppearanceType);
PacketWriter.Write((string)avatar.CityName);
PacketWriter.Write((ulong)avatar.CityThumb);
PacketWriter.Write((string)avatar.City);
PacketWriter.Write((ulong)avatar.CityMap);
PacketWriter.Write((string)avatar.CityIp);
PacketWriter.Write((int)avatar.CityPort);
PacketWriter.Write((int)avatar.Money);
}
}
//NOTE: If Characters != null, but no chars were new, NumChars will be however many characters,
// and NewChars will be 0.
Packet.WriteByte((byte)NumChars);
Packet.WriteByte((byte)NewChars);
Packet.Write(PacketData.ToArray(), 0, (int)PacketData.Length);
PacketWriter.Close();
Client.SendEncrypted((byte)PacketType.CHARACTER_LIST, Packet.ToArray());
}
else //No characters existed for the account.
{
PacketStream Packet = new PacketStream(0x05, 0);
Packet.WriteByte((byte)NumChars); //0 characters.
Packet.WriteByte((byte)NewChars); //0 new characters.
Client.SendEncrypted((byte)PacketType.CHARACTER_LIST, Packet.ToArray());
}
}
开发者ID:RHY3756547,项目名称:FreeSO,代码行数:81,代码来源:LoginPacketHandlers.cs
示例11: HandleChallengeResponse
/// <summary>
/// Client sent a response to our challenge, as well as account name and password.
/// </summary>
public static void HandleChallengeResponse(NetworkClient Client, ProcessedPacket P)
{
PacketStream OutPacket;
if (P.BufferLength <= 1)
{
OutPacket = new PacketStream((byte)PacketType.LOGIN_FAILURE, 0);
OutPacket.WriteByte(0x03); //Bad challenge response.
Client.Send(OutPacket.ToArray());
Logger.LogInfo("Bad challenge response - sent SLoginFailResponse!\r\n");
return; //How does this even happen?!
}
int Length = P.ReadByte();
byte[] CResponse;
if (P.BufferLength >= Length)
CResponse = P.ReadBytes(Length);
else
return;
AESDecryptionArgs DecryptionArgs = Client.ClientEncryptor.GetDecryptionArgsContainer().AESDecryptArgs;
if (DecryptionArgs.Challenge.SequenceEqual(CResponse))
{
string AccountName = SanitizeAccount(P.ReadString());
Length = P.ReadByte();
byte[] PasswordHash;
if (P.BufferLength >= Length)
PasswordHash = P.ReadBytes(Length);
else
return;
// Check whether the accountname is empty or is/contains "username"
if (AccountName == string.Empty || AccountName.ToLower().Equals("username") || AccountName.ToLower().Contains("username"))
{
OutPacket = new PacketStream((byte)PacketType.LOGIN_FAILURE, 0);
OutPacket.WriteHeader();
OutPacket.WriteUInt16((ushort)(PacketHeaders.UNENCRYPTED + 1));
OutPacket.WriteByte(0x01);
Client.Send(OutPacket.ToArray());
Logger.LogInfo(@"Bad accountname (""" + AccountName + @""") - sent SLoginFailResponse!\r\n");
Client.Disconnect();
return;
}
using (var db = DataAccess.Get())
{
var account = db.Accounts.GetByUsername(AccountName);
if (!GlobalSettings.Default.CreateAccountsOnLogin)
{
Logger.LogInfo("Done reading LoginRequest, checking account...\r\n");
if (account == null)
{
OutPacket = new PacketStream((byte)PacketType.LOGIN_FAILURE, 0);
OutPacket.WriteHeader();
OutPacket.WriteUInt16((ushort)(PacketHeaders.UNENCRYPTED + 1));
OutPacket.WriteByte(0x01);
Client.Send(OutPacket.ToArray());
Logger.LogInfo(@"Bad accountname (""" + AccountName + @""") - sent SLoginFailResponse!\r\n");
Client.Disconnect();
return;
}
}
else
{
if (account == null)
{
try
{
if (!AccountName.ToLower().Equals("username") || !AccountName.ToLower().Contains("username"))
db.Accounts.Create(new Account
{
AccountName = AccountName.ToLower(),
Password = Convert.ToBase64String(PasswordHash)
});
}
catch (Exception)
{
OutPacket = new PacketStream((byte)PacketType.LOGIN_FAILURE, 0);
OutPacket.WriteHeader();
OutPacket.WriteUInt16((ushort)(PacketHeaders.UNENCRYPTED + 1));
OutPacket.WriteByte(0x01);
Client.Send(OutPacket.ToArray());
Logger.LogInfo(@"Bad accountname (""" + AccountName + @""") - sent SLoginFailResponse!\r\n");
Client.Disconnect();
return;
}
//.........这里部分代码省略.........
开发者ID:RHY3756547,项目名称:FreeSO,代码行数:101,代码来源:LoginPacketHandlers.cs
示例12: HandleCharacterCreate
/// <summary>
/// Client created a character!
/// </summary>
public static void HandleCharacterCreate(NetworkClient Client, ProcessedPacket P)
{
Logger.LogInfo("Received CharacterCreate!");
string AccountName = SanitizeAccount(P.ReadString());
//Need to be variable length, because the success packet contains a token.
PacketStream CCStatusPacket = new PacketStream((byte)PacketType.CHARACTER_CREATION_STATUS, 0);
using (var db = DataAccess.Get())
{
Account Acc = db.Accounts.GetByUsername(AccountName);
if (Acc.NumCharacters >= 3)
{
CCStatusPacket.WriteByte((int)LoginDataModel.Entities.CharacterCreationStatus.ExceededCharacterLimit);
Client.SendEncrypted(CCStatusPacket.PacketID, CCStatusPacket.ToArray());
return;
}
//TODO: Send GUID to client...
var Char = new Character();
string LastCached = P.ReadString();
if (LastCached == string.Empty)
{
//TODO: Proper error...
CCStatusPacket.WriteByte((int)LoginDataModel.Entities.CharacterCreationStatus.NameAlreadyExisted);
Client.SendEncrypted(CCStatusPacket.PacketID, CCStatusPacket.ToArray());
return;
}
Char.LastCached = ProtoHelpers.ParseDateTime(LastCached);
Char.Name = P.ReadString();
Char.Sex = P.ReadString();
Char.Description = P.ReadString();
Char.GUID = Guid.NewGuid();
Char.HeadOutfitID = (long)P.ReadUInt64();
Char.BodyOutfitID = (long)P.ReadUInt64();
Char.AccountID = Acc.AccountID;
Char.AppearanceType = P.ReadByte();
Char.CityName = P.ReadString();
Char.CityThumb = (long)P.ReadUInt64();
Char.City = P.ReadString();
Char.CityMap = (long)P.ReadUInt64();
Char.CityIp = P.ReadString();
Char.CityPort = P.ReadInt32();
Char.Money = NetworkFacade.INITIAL_MONEY;
//These are going into DB, so be nazi. Sieg heil!
if (Char.Name == string.Empty || Char.Sex == string.Empty ||
Char.Description == string.Empty)
{
CCStatusPacket.WriteByte((int)LoginDataModel.Entities.CharacterCreationStatus.NameAlreadyExisted);
Client.SendEncrypted(CCStatusPacket.PacketID, CCStatusPacket.ToArray());
return;
}
var status = db.Characters.CreateCharacter(Char);
switch (status)
{
case LoginDataModel.Entities.CharacterCreationStatus.NameAlreadyExisted:
CCStatusPacket.WriteByte((int)LoginDataModel.Entities.CharacterCreationStatus.NameAlreadyExisted);
Client.SendEncrypted(CCStatusPacket.PacketID, CCStatusPacket.ToArray());
break;
case LoginDataModel.Entities.CharacterCreationStatus.NameTooLong:
CCStatusPacket.WriteByte((int)LoginDataModel.Entities.CharacterCreationStatus.NameTooLong);
Client.SendEncrypted(CCStatusPacket.PacketID, CCStatusPacket.ToArray());
break;
case LoginDataModel.Entities.CharacterCreationStatus.Success:
Guid Token = Guid.NewGuid();
//This actually updates the record, not sure how.
Acc.NumCharacters++;
//THIS NEEDS TO HAPPEN FIRST FOR CITY SERVER AUTHENTICATION TO WORK!
CityInfo CServer = NetworkFacade.CServerListener.GetCityServer(Char.City);
//Just in case...
if (CServer != null)
{
PacketStream CServerPacket = new PacketStream(0x01, 0);
CServerPacket.WriteHeader();
ushort PacketLength = (ushort)(PacketHeaders.UNENCRYPTED + 1 + 4 + (Client.RemoteIP.Length + 1)
+ 4 + (Char.GUID.ToString().Length + 1) + (Token.ToString().Length + 1));
CServerPacket.WriteUInt16(PacketLength);
CServerPacket.WriteByte(1); //CharacterCreate = true
CServerPacket.WriteInt32(Acc.AccountID);
CServerPacket.WriteString(Client.RemoteIP);
CServerPacket.WriteInt32(Client.RemotePort);
CServerPacket.WriteString(Char.GUID.ToString());
CServerPacket.WriteString(Token.ToString(""));
CServer.Client.Send(CServerPacket.ToArray());
}
//.........这里部分代码省略.........
开发者ID:RHY3756547,项目名称:FreeSO,代码行数:101,代码来源:LoginPacketHandlers.cs
示例13: OnPlayerJoinedSession
/// <summary>
/// A player joined a session (game) in progress.
/// </summary>
public static LotTileEntry OnPlayerJoinedSession(NetworkClient Client, ProcessedPacket Packet)
{
LotTileEntry TileEntry = new LotTileEntry(0, "", 0, 0, 0, 0);
UISim Avatar = new UISim(Packet.ReadString());
Avatar.Name = Packet.ReadString();
Avatar.Sex = Packet.ReadString();
Avatar.Description = Packet.ReadString();
Avatar.HeadOutfitID = Packet.ReadUInt64();
Avatar.BodyOutfitID = Packet.ReadUInt64();
Avatar.Avatar.Appearance = (AppearanceType)Packet.ReadInt32();
byte HasHouse = (byte)Packet.ReadByte();
if (HasHouse != 0)
{
TileEntry = new LotTileEntry(Packet.ReadInt32(), Packet.ReadString(), (short)Packet.ReadUInt16(),
(short)Packet.ReadUInt16(), (byte)Packet.ReadByte(), Packet.ReadInt32());
Avatar.LotID = TileEntry.lotid;
Avatar.HouseX = TileEntry.x;
Avatar.HouseY = TileEntry.y;
LotTileEntry[] TileEntries = new LotTileEntry[TSOClient.Code.GameFacade.CDataRetriever.LotTileData.Length + 1];
TileEntries[0] = TileEntry;
TSOClient.Code.GameFacade.CDataRetriever.LotTileData.CopyTo(TileEntries, 1);
}
lock (NetworkFacade.AvatarsInSession)
{
NetworkFacade.AvatarsInSession.Add(Avatar);
}
return TileEntry;
}
开发者ID:gamedev1337,项目名称:Project-Dollhouse,代码行数:38,代码来源:UIPacketHandlers.cs
示例14: HandleCharacterInfoRequest
public static void HandleCharacterInfoRequest(NetworkClient Client, ProcessedPacket P)
{
Logger.LogInfo("Received CharacterInfoRequest!");
DateTime Timestamp = DateTime.Parse(P.ReadPascalString());
//Database.CheckCharacterTimestamp(Client.Username, Client, TimeStamp);
Character[] Characters = new Character[] { };
using (var db = DataAccess.Get())
{
var account = db.Accounts.GetByUsername(Client.ClientEncryptor.Username);
Characters = db.Characters.GetForAccount((int)account.AccountID).ToArray();
}
if (Characters != null)
{
PacketStream Packet = new PacketStream((byte)PacketType.CHARACTER_LIST, 0);
MemoryStream PacketData = new MemoryStream();
BinaryWriter PacketWriter = new BinaryWriter(PacketData);
/**
* Whats the point of checking a timestamp here? It saves a few bytes on a packet
* sent once per user session. Premature optimization.
*/
PacketWriter.Write((byte)Characters.Length);
foreach (Character avatar in Characters)
{
PacketWriter.Write((int)avatar.CharacterID);
PacketWriter.Write(avatar.GUID.ToString());
PacketWriter.Write(avatar.LastCached);
PacketWriter.Write(avatar.Name);
PacketWriter.Write(avatar.Sex);
PacketWriter.Write(avatar.Description);
PacketWriter.Write((ulong)avatar.HeadOutfitID);
PacketWriter.Write((ulong)avatar.BodyOutfitID);
PacketWriter.Write((byte)avatar.AppearanceType);
PacketWriter.Write((string)avatar.CityName);
PacketWriter.Write((ulong)avatar.CityThumb);
PacketWriter.Write((string)avatar.City);
PacketWriter.Write((ulong)avatar.CityMap);
PacketWriter.Write((string)avatar.CityIp);
PacketWriter.Write((int)avatar.CityPort);
}
Packet.Write(PacketData.ToArray(), 0, (int)PacketData.Length);
PacketWriter.Close();
Client.SendEncrypted(0x05, Packet.ToArray());
}
else //No characters existed for the account.
{
PacketStream Packet = new PacketStream(0x05, 0);
Packet.WriteByte(0x00); //0 characters.
Client.SendEncrypted((byte)PacketType.CHARACTER_LIST, Packet.ToArray());
}
}
开发者ID:Blayer98,项目名称:Project-Dollhouse,代码行数:58,代码来源:LoginPacketHandlers.cs
示例15: OnNewTimeOfDay
public static DateTime OnNewTimeOfDay(NetworkClient Client, ProcessedPacket Packet)
{
return new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day,
Packet.ReadInt32(), Packet.ReadInt32(), Packet.ReadInt32());
}
开发者ID:gamedev1337,项目名称:Project-Dollhouse,代码行数:5,代码来源:UIPacketHandlers.cs
示例16: HandleCityTokenRequest
/// <summary>
/// Client wanted to transfer to a city server.
/// </summary>
public static void HandleCityTokenRequest(NetworkClient Client, ProcessedPacket P)
{
string AccountName = P.ReadString();
string CityGUID = P.ReadString();
string CharGUID = P.ReadString();
if (AccountName == string.Empty || CityGUID == string.Empty || CharGUID == string.Empty)
return;
Guid Token = Guid.NewGuid();
CityInfo CServer = NetworkFacade.CServerListener.GetCityServer(CityGUID);
using (var db = DataAccess.Get())
{
Account Acc = db.Accounts.GetByUsername(AccountName);
PacketStream CServerPacket = new PacketStream(0x01, 0);
CServerPacket.WriteHeader();
ushort PacketLength = (ushort)(PacketHeaders.UNENCRYPTED + 1 + 4 + (Client.RemoteIP.Length + 1)
+ 4 + (CharGUID.ToString().Length + 1) + (Token.ToString().Length + 1));
CServerPacket.WriteUInt16(PacketLength);
CServerPacket.WriteByte(0); //CharacterCreate = false.
CServerPacket.WriteInt32(Acc.AccountID);
CServerPacket.WriteString(Client.RemoteIP);
CServerPacket.WriteInt32(Client.RemotePort);
CServerPacket.WriteString(CharGUID.ToString());
CServerPacket.WriteString(Token.ToString(""));
CServer.Client.Send(CServerPacket.ToArray());
}
}
开发者ID:RHY3756547,项目名称:FreeSO,代码行数:35,代码来源:LoginPacketHandlers.cs
示例17: OnCityTokenResponse
public static void OnCityTokenResponse(NetworkClient Client, ProcessedPacket Packet)
{
CityTransferStatus Status = (CityTransferStatus)Packet.ReadByte();
switch (Status)
{
case CityTransferStatus.Success:
NetworkFacade.Controller._OnCityTokenResponse(Status);
break;
case CityTransferStatus.GeneralError:
NetworkFacade.Controller._OnCityTokenResponse(Status);
break;
}
}
开发者ID:Tranquill6,项目名称:Project-Dollhouse,代码行数:14,代码来源:UIPacketHandlers.cs
示例18: OnPlayerReceivedLetter
/// <summary>
/// Received a letter from another player in a session.
/// </summary>
public static void OnPlayerReceivedLetter(NetworkClient Client, ProcessedPacket Packet)
{
string From = Packet.ReadString();
string Subject = Packet.ReadString();
string Message = Packet.ReadString();
string GUID = string.Empty;
lock (NetworkFacade.AvatarsInSession)
{
foreach (UISim Sim in NetworkFacade.AvatarsInSession)
{
if (Sim.Name.Equals(From, StringComparison.CurrentCultureIgnoreCase))
GUID = Sim.GUID.ToString();
}
}
Code.UI.Panels.MessageAuthor Author = new TSOClient.Code.UI.Panels.MessageAuthor();
Author.Author = From;
if (GUID != string.Empty)
Author.GUID = GUID;
//Ignore this for now...
/*if (!Code.GameFacade.MessageController.ConversationExisted(Author))
Code.GameFacade.MessageController.PassEmail(Author, Subject, Message);
else*/
Code.GameFacade.MessageController.PassMessage(Author, Message);
//MessagesCache.CacheLetter(From, Subject, Message);
}
开发者ID:gamedev1337,项目名称:Project-Dollhouse,代码行数:33,代码来源:UIPacketHandlers.cs
示例19: OnCityInfoResponse
public static void OnCityInfoResponse(ProcessedPacket Packet)
{
byte NumCities = (byte)Packet.ReadByte();
if (Packet.DecryptedLength > 1)
{
for (int i = 0; i < NumCities; i++)
{
string Name = Packet.ReadString();
string Description = Packet.ReadString();
string IP = Packet.ReadString();
int Port = Packet.ReadInt32();
byte StatusByte = (byte)Packet.ReadByte();
CityInfoStatus Status = (CityInfoStatus)StatusByte;
ulong Thumbnail = Packet.ReadUInt64();
string UUID = Packet.ReadString();
ulong Map = Packet.ReadUInt64();
CityInfo Info = new CityInfo(Name, Description, Thumbnail, UUID, Map, IP, Port);
Info.Online = true;
Info.Status = Status;
NetworkFacade.Cities.Add(Info);
}
}
}
开发者ID:Tranquill6,项目名称:Project-Dollhouse,代码行数:25,代码来源:UIPacketHandlers.cs
示例20: HandleLoginRequest
/**
* Actual packet handlers
*/
public static void HandleLoginRequest(NetworkClient Client, ProcessedPacket P)
{
Logger.LogInfo("Received LoginRequest!\r\n");
byte AccountStrLength = (byte)P.ReadByte();
byte[] AccountNameBuf = new byte[AccountStrLength];
P.Read(AccountNameBuf, 0, AccountStrLength);
string AccountName = SanitizeAccount(Encoding.ASCII.GetString(AccountNameBuf));
Logger.LogInfo("Accountname: " + AccountName + "\r\n");
byte HashLength = (byte)P.ReadB
|
请发表评论