本文整理汇总了C#中Zepheus.FiestaLib.Networking.Packet.TryReadString方法的典型用法代码示例。如果您正苦于以下问题:C# Packet.TryReadString方法的具体用法?C# Packet.TryReadString怎么用?C# Packet.TryReadString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zepheus.FiestaLib.Networking.Packet
的用法示例。
在下文中一共展示了Packet.TryReadString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ChangeFromGuildAcademyToResponse
public static void ChangeFromGuildAcademyToResponse(WorldClient client, Packet packet)
{
string GuildName;
string RequestName;
bool answer;
if (!packet.TryReadString(out GuildName, 16) || !packet.TryReadString(out RequestName, 16)|| (!packet.TryReadBool(out answer) || !client.Character.IsInGuildAcademy))
return;
if (answer)
{
GuildAcademyMember pMember = client.Character.GuildAcademy.Members.Find(m => m.Character.Character.Name == RequestName);
if (pMember == null)
return;
pMember.Character.IsInGuildAcademy = false;
pMember.Academy.RemoveMember(pMember);
pMember.Character.GuildAcademy.Guild.AddMember(pMember.Character, GuildRank.Member, Program.DatabaseManager.GetClient().GetConnection(), true, true);
pMember.Character.Guild = pMember.Character.GuildAcademy.Guild;
pMember.Character.IsInGuild = true;
using (var pack = new Packet(SH38Type.SendJoinGuildFromAcademy))
{
//this packet remove character from academy List and added to GuildList
pack.WriteString(RequestName, 16);
pack.WriteString(client.Character.Character.Name, 16);
pack.WriteByte(6);//rank
pack.WriteInt(0);//unk
pack.WriteUShort(0);//korp
pack.Fill(64, 0x00);//unk
pack.WriteByte(true ? (byte)0x95 : (byte)0x00);// (this.isOnline ? (byte)0x95 : (byte)0x00);
pack.Fill(3, 0x00);//unk
pack.WriteByte(pMember.Character.Character.Job);
pack.WriteByte(pMember.Character.Character.CharLevel);
pack.Fill(13, 0x00);//unk
client.Character.GuildAcademy.Guild.Broadcast(pack);
client.Character.GuildAcademy.Broadcast(pack);
}
}
using (var p2 = new Packet(SH4Type.CharacterGuildinfo))
{
client.Character.Guild.WriteGuildInfo(packet);
client.SendPacket(p2);
}
using (var pack = new Packet(SH29Type.GuildMemberJoined))
{
pack.WriteString(client.Character.Character.Name, 16);
client.Character.GuildAcademy.Guild.Broadcast(pack);
client.Character.GuildAcademy.Broadcast(pack);
}
using (var pack = new Packet(SH29Type.ChangeResponse))
{
pack.WriteUShort(3137);//unk
pack.WriteByte(3);
pack.Fill(2, 0x00);//unk
client.SendPacket(pack);
}
}
示例2: FriendInvite
public static void FriendInvite(WorldClient pClient, Packet pPacket)
{
string sender, receiver;
if (!pPacket.TryReadString(out sender, 16) ||
!pPacket.TryReadString(out receiver, 16))
{
Log.WriteLine(LogLevel.Warn, "Error reading friend invite.");
return;
}
WorldCharacter inviter = pClient.Character;
WorldClient invitee = ClientManager.Instance.GetClientByCharname(receiver);
if (invitee == null)
{
//character not found
using (var pack = new Packet(SH21Type.FriendInviteResponse))
{
pack.WriteString(sender, 16);
pack.WriteString(receiver, 16);
pack.WriteUShort(0x0946); // Cannot find ${Target}
pClient.SendPacket(pack);
}
}
else if (receiver == sender)
{
using (var pack = new Packet(SH21Type.FriendInviteResponse))
{
pack.WriteString(sender, 16);
pack.WriteString(receiver, 16);
pack.WriteUShort(0x0942); // You cannot add yourself to your Buddy List.
pClient.SendPacket(pack);
}
}
else if (inviter.Friends.Find(f => f.Name == receiver) != null)
{
using (var pack = new Packet(SH21Type.FriendInviteResponse))
{
pack.WriteString(sender, 16);
pack.WriteString(receiver, 16);
pack.WriteUShort(0x0945); // {Target} is already registered in the friends list.
pClient.SendPacket(pack);
}
}
else
{
using (var pack = new Packet(SH21Type.FriendInviteRequest))
{
pack.WriteString(receiver, 16);
pack.WriteString(sender, 16);
invitee.SendPacket(pack);
}
}
}
示例3: MasterRequest
public static void MasterRequest(WorldClient client, Packet packet)
{
string playername = string.Empty;
string target = string.Empty;
if (!packet.TryReadString(out playername, 16))
return;
if (!packet.TryReadString(out target, 16))
return;
MasterManager.Instance.AddMasterRequest(client, target);
}
示例4: Wisper
public static void Wisper(WorldClient client, Packet packet)
{
string toname;
byte messagelenght;
if (packet.TryReadString(out toname, 16) && packet.TryReadByte(out messagelenght))
{
string message;
if (!packet.TryReadString(out message, messagelenght))
{
return;
}
WorldClient toChar = ClientManager.Instance.GetClientByCharname(toname);
if (toChar != null)
{
using (var frompacket = new Packet(SH8Type.WisperFrom))
{
frompacket.WriteString(client.Character.Character.Name, 16);
if (!toChar.Character.BlocketUser.Contains(client.Character.Character.Name))
{
frompacket.WriteByte(0);
}
else
{
frompacket.WriteByte(12);//blocket notdisplay message
}
frompacket.WriteByte(messagelenght);
frompacket.WriteString(message, messagelenght);
toChar.SendPacket(frompacket);
}
using (var pack = new Packet(SH8Type.WisperTo))
{
pack.WriteString(toname, 16);
pack.WriteByte(messagelenght);
pack.WriteString(message, messagelenght);
client.SendPacket(pack);
}
}
else
{
//target not found
using (var pp = new Packet(SH8Type.WisperTargetNotfound))
{
pp.WriteUShort(3945);//unk
pp.WriteString(toname, 16);
client.SendPacket(pp);
}
}
}
}
示例5: MasterRemove
public static void MasterRemove(WorldClient client, Packet packet)
{
string removename;
if(!packet.TryReadString(out removename,16))
return;
MasterManager.Instance.RemoveMasterMember(client.Character, removename);
}
示例6: sendPartyMessage
public static void sendPartyMessage(WorldClient client, Packet packet)
{
string mess;
byte len;
if (!packet.TryReadByte(out len) || !packet.TryReadString(out mess, len))
{
Log.WriteLine(LogLevel.Error, "PartyChat :: Can not parse party chat from {0}", client.Character.Character.Name);
return;
}
if(Program.Entity.Parties.Where(c => c.CharNo == client.Character.Character.ID).Count() == 1)
{
Party getPartyInfo = Program.Entity.Parties.First(c => c.CharNo == client.Character.Character.ID);
foreach (Party party in Program.Entity.Parties.Where(c => c.PartyNo == getPartyInfo.PartyNo))
{
Character character = Program.Entity.Characters.First(c => c.ID == party.CharNo);
WorldClient wclient = ClientManager.Instance.GetClientByCharname(character.Name);
using (var ppacket = new Packet(SH8Type.PartyChat))
{
ppacket.WriteString(client.Character.Character.Name, 16);
ppacket.WriteByte(len);
ppacket.WriteString(mess, len);
wclient.SendPacket(ppacket);
}
}
}
else
{
using (var ppacket = new Packet(SH8Type.PartyChatErr))
{
ppacket.WriteUShort(1985);
client.SendPacket(ppacket);
}
}
}
示例7: FriendInviteResponse
public static void FriendInviteResponse(WorldClient pClient, Packet pPacket)
{
string target, sender;
bool response;
if (!pPacket.TryReadString(out target, 16) ||
!pPacket.TryReadString(out sender, 16) ||
!pPacket.TryReadBool(out response))
{
Log.WriteLine(LogLevel.Warn, "Could not reat friend invite response.");
return;
}
WorldClient sendchar = ClientManager.Instance.GetClientByCharname(sender);
if (sendchar == null)
{
Log.WriteLine(LogLevel.Warn, "Invalid friend reject received.");
return;
}
if (response)
{
Friend sendfriend = sendchar.Character.AddFriend(pClient.Character);
if (sendfriend != null)
{
using (var packet = new Packet(SH21Type.FriendInviteResponse))
{
packet.WriteString(sender, 16);
packet.WriteString(target, 16);
packet.WriteByte(0);
sendchar.SendPacket(packet);
}
using (var packet = new Packet(SH21Type.FriendExtraInformation))
{
sendfriend.WritePacket(packet);
sendchar.SendPacket(packet);
}
}
}
else
{
using (var packet = new Packet(SH21Type.FriendInviteReject))
{
packet.WriteString(target, 16);
sendchar.SendPacket(packet);
}
}
}
示例8: AcceptParty
public static void AcceptParty(WorldClient client, Packet packet)
{
string inviteChar;
if (packet.TryReadString(out inviteChar, 16))
{
GroupManager.Instance.AcceptInvite(client, inviteChar);
}
}
示例9: Login
public static void Login(LoginClient pClient, Packet pPacket)
{
string hash;
string username;
if (!pPacket.TryReadString(out username, 18) || !pPacket.TryReadString(out hash, 16))
{
Log.WriteLine(LogLevel.Warn, "Could not read user token.");
SendFailedLogin(pClient, ServerError.EXCEPTION);
return;
}
User user;
if (Program.Entity.Users.Count() > 0 && Program.Entity.Users.Count(u => u.Username == username) == 1)
{
user = Program.Entity.Users.First(u => u.Username == username);
if (user.Password.ToLower() == hash.ToLower())
{
Log.WriteLine(LogLevel.Debug, "{0} tries to login.", username);
if (ClientManager.Instance.IsLoggedIn(user.Username))
{
Log.WriteLine(LogLevel.Warn, "{0} is trying dual login. Disconnecting.", user.Username);
pClient.Disconnect();
}
else if (user.Banned)
{
SendFailedLogin(pClient, ServerError.BLOCKED);
}
else
{
pClient.IsAuthenticated = true;
pClient.Username = user.Username;
pClient.AccountID = user.ID;
pClient.Admin = user.Admin;
AllowFiles(pClient, true);
WorldList(pClient, false);
}
}
else SendFailedLogin(pClient, ServerError.INVALID_CREDENTIALS);
}
else SendFailedLogin(pClient, ServerError.INVALID_CREDENTIALS);
}
示例10: getWhisperMessage
public static void getWhisperMessage(WorldClient client, Packet packet)
{
string toChar;
byte len;
string mess;
if (!packet.TryReadString(out toChar, 16) || !packet.TryReadByte(out len) || !packet.TryReadString(out mess, len))
{
Log.WriteLine(LogLevel.Error, "WhisperChat :: Can not parse Whisper request from {0}", client.Character.Character.Name);
return;
}
WorldClient wclient = ClientManager.Instance.GetClientByCharname(toChar);
if (wclient != null)
{
using (var ppacket = new Packet(SH8Type.WhisperTo))
{
ppacket.WriteString(toChar, 16);
ppacket.WriteByte(len);
ppacket.WriteString(mess, len);
client.SendPacket(ppacket);
}
using (var ppacket = new Packet(SH8Type.WhisperFrom))
{
ppacket.WriteString(client.Character.Character.Name, 16);
ppacket.WriteByte(0); // unk
ppacket.WriteByte(len);
ppacket.WriteString(mess, len);
wclient.SendPacket(ppacket);
}
}
else
{
using (var ppacket = new Packet(SH8Type.WhisperErrAnswer))
{
ppacket.WriteUShort(3945);
ppacket.WriteString(toChar, 16);
client.SendPacket(ppacket);
}
}
}
示例11: FileHash
public static void FileHash(LoginClient pClient, Packet pPacket)
{
string hash;
if (!pPacket.TryReadString(out hash))
{
Log.WriteLine(LogLevel.Warn, "Empty filehash received.");
SendFailedLogin(pClient, ServerError.Exception);
}
else
AllowFiles(pClient, true);
}
示例12: KickPartyMember
public static void KickPartyMember(WorldClient client, Packet packet)
{
string removeName;
if (packet.TryReadString(out removeName, 16))
{
if(!client.Character.Group.HasMember(removeName))
return;
GroupManager.Instance.KickMember(client, removeName);
}
}
示例13: ChangePartyMaster
public static void ChangePartyMaster(WorldClient client, Packet packet)
{
string mastername;
if (packet.TryReadString(out mastername, 16))
{
if(client.Character.Group.Master.Name != client.Character.Character.Name)
return;
GroupManager.Instance.ChangeMaster(client, mastername);
}
}
示例14: CreateCharHandler
public static void CreateCharHandler(WorldClient client, Packet packet)
{
string name;
byte slot, jobGender, hair, color, style;
if (!packet.TryReadByte(out slot) || !packet.TryReadString(out name, 16) ||
!packet.TryReadByte(out jobGender) || !packet.TryReadByte(out hair) ||
!packet.TryReadByte(out color) || !packet.TryReadByte(out style))
{
Log.WriteLine(LogLevel.Warn, "Error reading create char for {0}", client.Username);
return;
}
if (DatabaseChecks.IsCharNameUsed(name))
{
SendCharCreationError(client, CreateCharError.NameTaken);
return;
}
else if (DataProvider.Instance.IsBadName(name))
{
SendCharCreationError(client, CreateCharError.NameInUse);
return;
}
byte isMaleByte = (byte)((jobGender >> 7) & 0x01);
byte classIDByte = (byte)((jobGender >> 2) & 0x1F);
Job job = (Job)classIDByte;
switch (job)
{
case Job.Archer:
case Job.Cleric:
case Job.Fighter:
case Job.Mage:
case Job.Trickster:
case Job.Crusader:
//create character here
try
{
WorldCharacter wchar = client.CreateCharacter(name, slot, hair, color, style, job, Convert.ToBoolean(isMaleByte));
SendCharOKResponse(client, wchar);
}
catch (Exception ex)
{
Log.WriteLine(LogLevel.Exception, "Error creating character for {0}: {1}", client.Username, ex.InnerException.ToString());
SendCharCreationError(client, CreateCharError.FailedToCreate);
return;
}
break;
default:
SendCharCreationError(client, CreateCharError.WrongClass);
Log.WriteLine(LogLevel.Warn, "Invalid job ID at char creation from {0}", client.Username);
break;
}
}
示例15: MasterRequestResponse
public static void MasterRequestResponse(WorldClient client, Packet packet)
{
string requester = string.Empty;
string target = string.Empty;
byte response;
if (!packet.TryReadString(out requester, 16))
return;
if (!packet.TryReadString(out target, 16))
return;
if (!packet.TryReadByte(out response))
return;
if (response == 0)
{
MasterManager.Instance.RemoveMasterRequest(client);
}
else if(response == 1)
{
MasterManager.Instance.MasterRequestAccept(requester, target);
}
}