本文整理汇总了C#中ProcessedPacket.ReadByte方法的典型用法代码示例。如果您正苦于以下问题:C# ProcessedPacket.ReadByte方法的具体用法?C# ProcessedPacket.ReadByte怎么用?C# ProcessedPacket.ReadByte使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProcessedPacket
的用法示例。
在下文中一共展示了ProcessedPacket.ReadByte方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
}
示例2: 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;
}
}
示例3: 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;
}
示例4: 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());
}
示例5: 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;
}
示例6: 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);
}
示例7: 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;
}
示例8: OnCharacterCreationStatus
/// <summary>
/// Received CharacterCreation packet from CityServer.
/// </summary>
/// <returns>The result of the character creation.</returns>
public static CharacterCreationStatus OnCharacterCreationStatus(NetworkClient Client, ProcessedPacket Packet)
{
CharacterCreationStatus CCStatus = (CharacterCreationStatus)Packet.ReadByte();
return CCStatus;
}
示例9: OnLoginFailResponse
/// <summary>
/// Occurs when the client was not authenticated by the loginserver.
/// Called by UILoginDialog.cs.
/// </summary>
/// <param name="Client">The client that received the packet.</param>
/// <param name="Packet">The packet that was received.</param>
/// <param name="Screen">A UIScreen instance on which to display a messagebox to inform the player of the
/// failure state.</param>
public static void OnLoginFailResponse(ref NetworkClient Client, ProcessedPacket Packet)
{
EventObject Event;
switch (Packet.ReadByte())
{
case 0x01:
Event = new EventObject(EventCodes.BAD_USERNAME);
EventSink.RegisterEvent(Event);
break;
case 0x02:
Event = new EventObject(EventCodes.BAD_PASSWORD);
EventSink.RegisterEvent(Event);
break;
}
Client.Disconnect();
}
示例10: 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;
}
}
示例11: 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);
}
}
}
示例12: OnCityInfoResponse
public static void OnCityInfoResponse(ProcessedPacket Packet)
{
byte NumCities = (byte)Packet.ReadByte();
if (Packet.DecryptedLength > 1)
{
lock (NetworkFacade.Cities)
{
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(false);
Info.Name = Name;
Info.Description = Description;
Info.Thumbnail = Thumbnail;
Info.UUID = UUID;
Info.Map = Map;
Info.IP = IP;
Info.Port = Port;
Info.Online = true;
Info.Status = Status;
NetworkFacade.Cities.Add(Info);
}
}
}
}
示例13: OnCityTokenResponse
/// <summary>
/// Received from the CityServer in response to a CITY_TOKEN packet.
/// </summary>
public static CityTransferStatus OnCityTokenResponse(NetworkClient Client, ProcessedPacket Packet)
{
CityTransferStatus Status = (CityTransferStatus)Packet.ReadByte();
return Status;
}
示例14: 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;
}
//.........这里部分代码省略.........
示例15: 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;
}