本文整理汇总了C#中PacketReader类的典型用法代码示例。如果您正苦于以下问题:C# PacketReader类的具体用法?C# PacketReader怎么用?C# PacketReader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PacketReader类属于命名空间,在下文中一共展示了PacketReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoginServerConnectFromCharServer
/// <summary>
///
/// </summary>
/// <param name="netState"></param>
/// <param name="packetReader"></param>
internal static void LoginServerConnectFromCharServer( NetState netState, PacketReader packetReader )
{
// 错误 不可能有创建
if ( netState.ExtendData is CharServerExtendData == true )
return;
else
netState.ExtendData = null;
if ( packetReader.Size < 14/*6 + 8 + ?*/ )
return;
// 不检查网络是否活动
netState.IsCheckActivity = false;
long l_iCharGUID = packetReader.ReadUInt32();
long l_iCharPort = packetReader.ReadUInt32();
string l_strLoginPassword = packetReader.ReadStringSafe();
if ( l_strLoginPassword == Program.ConfigInfo.LoginPassword )
{
CharServerExtendData l_ExtendData = new CharServerExtendData();
l_ExtendData.IsLoggedIn = true;
l_ExtendData.CharGUID = l_iCharGUID;
l_ExtendData.CharHost = netState.NetAddress.ToString();
l_ExtendData.CharPort = l_iCharPort;
netState.ExtendData = l_ExtendData;
Program.CharServerList.Add(l_ExtendData);
l_ExtendData.ConnectToCharServer( l_ExtendData.CharHost, l_ExtendData.CharPort );
}
}
示例2: MultiplayerServer
public MultiplayerServer()
{
var reader = new PacketReader();
PacketReader = reader;
Clients = new List<IRemoteClient>();
EnvironmentWorker = new Timer(DoEnvironment);
PacketHandlers = new PacketHandler[0x100];
Worlds = new List<IWorld>();
EntityManagers = new List<IEntityManager>();
LogProviders = new List<ILogProvider>();
Scheduler = new EventScheduler(this);
var blockRepository = new BlockRepository();
blockRepository.DiscoverBlockProviders();
BlockRepository = blockRepository;
var itemRepository = new ItemRepository();
itemRepository.DiscoverItemProviders();
ItemRepository = itemRepository;
BlockProvider.ItemRepository = ItemRepository;
BlockProvider.BlockRepository = BlockRepository;
var craftingRepository = new CraftingRepository();
craftingRepository.DiscoverRecipes();
CraftingRepository = craftingRepository;
PendingBlockUpdates = new Queue<BlockUpdate>();
EnableClientLogging = false;
QueryProtocol = new TrueCraft.QueryProtocol(this);
WorldLighters = new List<WorldLighting>();
AccessConfiguration = Configuration.LoadConfiguration<AccessConfiguration>("access.yaml");
reader.RegisterCorePackets();
Handlers.PacketHandlers.RegisterHandlers(this);
}
示例3: CharacterDelete
//Void character delete
void CharacterDelete()
{
//Wrap our function in a catcher
try
{
//Create new packet reader
PacketReader Reader = new PacketReader(PacketInformation.buffer);
//Skip one not used byte
Reader.Skip(1);
//Get character name information
string CharacterName = Reader.Text();
//Close packet reader
Reader.Close();
//Update and set time + deletion state into the database
MsSQL.InsertData("UPDATE character SET deletedtime=dateadd(dd,7,getdate()),deleted='1' WHERE name='" + CharacterName + "'");
//Send visual state of character on screen sit down
client.Send(Packet.ScreenSuccess(3));
}
//Catch bad exception errors
catch (Exception ex)
{
//Write information to the console
Console.WriteLine("Character deletion error {0}", ex);
//Write information to debug logger
Systems.Debugger.Write(ex);
}
}
示例4: HandlePacket
public override void HandlePacket(Client context, byte flags, byte[] data, uint position, uint size)
{
var reader = new PacketReader(data, position, size);
var charId = reader.ReadUInt32();
if (context.User == null)
return;
if (context.Character == null) // On character create, this is already set.
{
using (var db = new PolarisEf())
{
var character = db.Characters.Find((int)charId);
if (character == null || character.Player.PlayerId != context.User.PlayerId)
return;
context.Character = character;
}
}
// Transition to the loading screen
context.SendPacket(new NoPayloadPacket(0x3, 0x4));
// TODO Set area, Set character, possibly more. See PolarisLegacy for more.
}
示例5: Read
public IDataObject Read(PacketReader r)
{
ObjectType = r.ReadInt16();
Status.Read(r);
return this;
}
示例6: ReadCommand
public void ReadCommand(PacketReader reader)
{
BuildingID = reader.ReadInt32();
Unknown1 = reader.ReadInt32();
Unknown2 = reader.ReadInt32();
Unknown3 = reader.ReadInt32();
}
示例7: OnFilter
public override void OnFilter( PacketReader p, PacketHandlerEventArgs args )
{
if ( args.Block )
return;
// 0, 1, 2
Serial serial = p.ReadUInt32(); // 3, 4, 5, 6
ushort body = p.ReadUInt16(); // 7, 8
MessageType type = (MessageType)p.ReadByte(); // 9
if ( type != m_Type )
return;
ushort hue = p.ReadUInt16(); // 10, 11
ushort font = p.ReadUInt16();
string name = p.ReadStringSafe( 30 );
string text = p.ReadStringSafe();
for(int i=0;i<m_Strings.Length;i++)
{
if ( text.IndexOf( m_Strings[i] ) != -1 )
{
args.Block = true;
return;
}
}
}
示例8: LogPacket
static void LogPacket(StreamWriter sw, bool ClientToServer, byte PacketID, string name, PacketReader pr, params object[] args)
{
try
{
if (sw == null)
return;
bool Suppressed = (ClientToServer && ClientDenyPackets.Contains(PacketID)) ||
(!ClientToServer && ServerDenyPackets.Contains(PacketID));
if (FilterOutput && !Filter.Contains(PacketID))
return;
if (ClientToServer && SuppressClient)
return;
if (!ClientToServer && SuppressServer)
return;
if (ClientToServer)
sw.WriteLine("{" + DateTime.Now.ToLongTimeString() + "} [CUSTOM CLIENT->SERVER" + (Suppressed ? " SUPPRESSED" : "") + "]: " +
name + " (0x" + PacketID.ToString("x") + ")");
else
sw.WriteLine("{" + DateTime.Now.ToLongTimeString() + "} [CUSTOM SERVER->CLIENT" + (Suppressed ? " SUPPRESSED" : "") + "]: " +
name + " (0x" + PacketID.ToString("x") + ")");
if (pr.Payload.Length == 0)
return;
sw.WriteLine("\t[" + DumpArray(pr.Payload) + "]");
for (int i = 0; i < args.Length; i += 2)
{
if (args[i + 1] is byte[])
sw.WriteLine("\t" + args[i].ToString() + " (Byte[]): [" + DumpArray((byte[])args[i + 1]) + "]");
else
sw.WriteLine("\t" + args[i].ToString() + " (" + args[i + 1].GetType().Name + "): " + args[i + 1]);
}
sw.Flush();
}
catch { }
}
示例9: Connect
public void Connect()
{
//Wrap our function inside a catcher
try
{
//Open our packet reader
PacketReader Reader = new PacketReader(PacketInformation.buffer);
byte type = Reader.Byte();
Reader.Skip(3);
string ID = Reader.Text();
string PW = Reader.Text();
Reader.Close();
//Set login result information
int LoginResult = LoginUser(ID, ref PW, ref Player, true);
//If the login is succesfull
if (LoginResult == 0)
{
//Send succes packet
client.Send(Packet.ConnectSuccess());
}
//If the login is wrong
else
{
//Disconnect the user
client.Disconnect(PacketInformation.Client);
}
}
catch (Exception ex)
{
Console.WriteLine("Client connect error {0}", ex);
Systems.Debugger.Write(ex);
}
}
示例10: FriendAddResponse
/////////////////////////////////////////////////////////////////////////////////
// Friend add response
/////////////////////////////////////////////////////////////////////////////////
void FriendAddResponse()
{
try
{
PacketReader reader = new PacketReader(PacketInformation.buffer);
int Inviterid = reader.Int32();
int Myid = reader.Int32();
byte State = reader.Byte();
reader.Close();
Systems sys = GetPlayer(Inviterid);
if (sys != null)
{
if (State == 0)
{
//Declined
client.Send(Packet.FriendDecline(Character.Information.Name));
sys.client.Send(Packet.FriendDecline(Character.Information.Name));
}
else
{
//Accepted
sys.client.Send(Packet.FriendData(Myid, 2, Character.Information.Name, Character, false));
client.Send(Packet.FriendData(Inviterid, 2, sys.Character.Information.Name, sys.Character, false));
MsSQL.InsertData("INSERT INTO friends (owner,friend_name,model_info) VALUES ('" + Character.Information.CharacterID + "','" + sys.Character.Information.CharacterID + "','" + sys.Character.Information.Model + "')");
MsSQL.InsertData("INSERT INTO friends (owner,friend_name,model_info) VALUES ('" + sys.Character.Information.CharacterID + "','" + Character.Information.CharacterID + "','" + Character.Information.Model + "')");
}
}
}
catch (Exception ex)
{
Console.WriteLine("Friend Add Response Error {0}", ex);
Systems.Debugger.Write(ex);
}
}
示例11: ReadPacket
public void ReadPacket(PacketReader reader)
{
UserID = reader.ReadInt64();
UserToken = reader.ReadString();
ClientMajorVersion = reader.ReadInt32();
ClientContentVersion = reader.ReadInt32();
ClientMinorVersion = reader.ReadInt32();
FingerprintHash = reader.ReadString();
Unknown1 = reader.ReadString();
OpenUDID = reader.ReadString();
MacAddress = reader.ReadString();
DeviceModel = reader.ReadString();
LocaleKey = reader.ReadInt32();
Language = reader.ReadString();
AdvertisingGUID = reader.ReadString();
OsVersion = reader.ReadString();
Unknown2 = (byte)reader.ReadByte();
Unknown3 = reader.ReadString();
AndroidDeviceID = reader.ReadString();
FacebookDistributionID = reader.ReadString();
IsAdvertisingTrackingEnabled = reader.ReadBoolean();
VendorGUID = reader.ReadString();
Seed = reader.ReadInt32();
}
示例12: FriendAdd
/////////////////////////////////////////////////////////////////////////////////
// Add new friend
/////////////////////////////////////////////////////////////////////////////////
void FriendAdd()
{
try
{
PacketReader reader = new PacketReader(PacketInformation.buffer);
short namelenght = reader.Int16();
string name = reader.String(namelenght);
reader.Close();
if (name == Character.Information.Name) return;
Systems sys = GetPlayerName(name);
if (sys != null)
{
sys.client.Send(Packet.FriendInviteTarget(sys.Character));
}
else
{
//Packet cannot find user
}
}
catch (Exception ex)
{
Console.WriteLine("Friend Add error {0}", ex);
Systems.Debugger.Write(ex);
}
}
示例13: OnCreativeInventoryAction
public void OnCreativeInventoryAction(ref PacketReader _pReader, PacketType pt, ref ClientManager _client)
{
short slot = _pReader.ReadShort();
short item_id = _pReader.ReadShort();
short Quanity = _pReader.ReadShort();
short Damage = _pReader.ReadShort();
}
示例14: IR_ARP
/// <summary>
/// Creates a new admin response packet.
/// </summary>
/// <param name="buffer">A buffer contaning the packet data.</param>
public IR_ARP(byte[] buffer) {
PacketReader reader = new PacketReader(buffer);
Size = reader.ReadByte();
Type = (PacketType)reader.ReadByte();
ReqI = reader.ReadByte();
Admin = reader.ReadBoolean();
}
示例15: unionapply
/////////////////////////////////////////////////////////////////////////
// Union Apply
/////////////////////////////////////////////////////////////////////////
void unionapply()
{
try
{
//Open our packet reader
PacketReader Reader = new PacketReader(PacketInformation.buffer);
//Get target id (Targeted).
int Target = Reader.Int32();
//Close reader
Reader.Close();
//Get target details
Systems targetplayer = GetPlayer(Target);
//Make sure the target is still there
if (targetplayer != null)
{
//If allready in union
if (targetplayer.Character.Network.Guild.UnionActive) return;
//Set bools for both players
targetplayer.Character.State.UnionApply = true;
this.Character.State.UnionApply = true;
//Set target player to us
targetplayer.Character.Network.TargetID = this.Character.Information.UniqueID;
//Send request to targeted player
targetplayer.client.Send(Packet.PartyRequest(6, this.Character.Information.UniqueID, 0));
}
}
catch (Exception ex)
{
Systems.Debugger.Write(ex);
}
}