本文整理汇总了C#中PacketReader类的典型用法代码示例。如果您正苦于以下问题:C# PacketReader类的具体用法?C# PacketReader怎么用?C# PacketReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PacketReader类属于命名空间,在下文中一共展示了PacketReader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 );
}
}
开发者ID:andyhebear,项目名称:HappyQ-WowServer,代码行数:39,代码来源:LoginPacketHandlers.cs
示例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);
}
开发者ID:ac682,项目名称:TrueCraft,代码行数:32,代码来源:MultiplayerServer.cs
示例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);
}
}
开发者ID:CarlosX,项目名称:DarkEmu,代码行数:28,代码来源:Deletion.cs
示例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.
}
开发者ID:Zenohate,项目名称:PolarisServer,代码行数:27,代码来源:StartGame.cs
示例5: Read
public IDataObject Read(PacketReader r)
{
ObjectType = r.ReadInt16();
Status.Read(r);
return this;
}
开发者ID:JuixGames,项目名称:K_Relay,代码行数:7,代码来源:Entity.cs
示例6: ReadCommand
public void ReadCommand(PacketReader reader)
{
BuildingID = reader.ReadInt32();
Unknown1 = reader.ReadInt32();
Unknown2 = reader.ReadInt32();
Unknown3 = reader.ReadInt32();
}
开发者ID:jibinthomas007,项目名称:CoCSharp,代码行数:7,代码来源:UpgradeUnitCommand.cs
示例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;
}
}
}
开发者ID:herculesjr,项目名称:razor,代码行数:27,代码来源:MessageFilter.cs
示例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 { }
}
开发者ID:TheScience,项目名称:SMProxy,代码行数:34,代码来源:Program_Helpers.cs
示例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);
}
}
开发者ID:CarlosX,项目名称:DarkEmu,代码行数:33,代码来源:CharacterLogin.cs
示例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);
}
}
开发者ID:CarlosX,项目名称:DarkEmu,代码行数:38,代码来源:Friends.cs
示例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();
}
开发者ID:jibinthomas007,项目名称:CoCSharp,代码行数:28,代码来源:LoginRequestPacket.cs
示例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);
}
}
开发者ID:CarlosX,项目名称:DarkEmu,代码行数:28,代码来源:Friends.cs
示例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();
}
开发者ID:ultimakaz,项目名称:lib-open-craft,代码行数:7,代码来源:CreativeInventoryAction.cs
示例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();
}
开发者ID:Kristoffeh,项目名称:InSim.NET_Library,代码行数:11,代码来源:IR_ARP.cs
示例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);
}
}
开发者ID:CarlosX,项目名称:DarkEmu,代码行数:35,代码来源:Union.cs
示例16: ReadCommand
public void ReadCommand(PacketReader reader)
{
X = reader.ReadInt32();
Y = reader.ReadInt32();
UnitID = reader.ReadInt32();
Unknown1 = reader.ReadInt32();
}
开发者ID:maithanhtan,项目名称:CoCSharp,代码行数:7,代码来源:PlaceAttackerCommand.cs
示例17: Read
public override void Read(PacketReader r)
{
Time = r.ReadInt32();
BulletId = r.ReadByte();
ObjectId = r.ReadInt32();
TargetId = r.ReadInt32();
}
开发者ID:Zeroeh,项目名称:K_Relay,代码行数:7,代码来源:OtherHitPacket.cs
示例18: CharServerConnected
/// <summary>
///
/// </summary>
/// <param name="netState"></param>
/// <param name="packetReader"></param>
internal static void CharServerConnected( NetState netState, PacketReader packetReader )
{
// 错误 不可能有创建
if ( netState.ExtendData is CharServerExtendData == true )
return;
else
netState.ExtendData = null;
if ( packetReader.Size < 6/*( 6 + 0 )*/ )
return;
// 不检查网络是否活动
netState.IsCheckActivity = false;
string l_strWorldPassword = packetReader.ReadStringSafe();
if ( l_strWorldPassword == Program.ConfigInfo.WorldPassword )
{
CharServerExtendData l_ExtendData = new CharServerExtendData();
l_ExtendData.IsLoggedIn = true;
netState.ExtendData = l_ExtendData;
}
}
开发者ID:andyhebear,项目名称:HappyQ-WowServer,代码行数:30,代码来源:WorldPacketHandlers.cs
示例19: ReadPacket
public void ReadPacket(PacketReader reader)
{
RankList = new List<MemberInfo>();
var count = reader.ReadInt32();
for (int i = 0; i < count; i++)
{
var memberInfo = new MemberInfo();
memberInfo.Unknown1 = reader.ReadInt64();
memberInfo.Name = reader.ReadString();
memberInfo.Rank = reader.ReadInt32();
memberInfo.Trophies = reader.ReadInt32();
memberInfo.Unknown2 = reader.ReadInt32();
memberInfo.Level = reader.ReadInt32();
memberInfo.AttacksWon = reader.ReadInt32();
memberInfo.AttacksLost = reader.ReadInt32();
memberInfo.DefencesWon = reader.ReadInt32();
memberInfo.DefencesLost = reader.ReadInt32();
memberInfo.Unknown3 = reader.ReadInt32();
memberInfo.CountryCode = reader.ReadString();
memberInfo.Unknown4 = reader.ReadInt64();
memberInfo.Unknown5 = reader.ReadInt64();
if (reader.ReadBoolean())
{
memberInfo.Clan = new Clan();
memberInfo.Clan.ID = reader.ReadInt64();
memberInfo.Clan.Name = reader.ReadString();
memberInfo.Clan.Badge = reader.ReadInt32();
}
RankList.Add(memberInfo);
}
}
开发者ID:Baghe,项目名称:CoCSharp,代码行数:31,代码来源:AvatarLocalRankListResponsePacket.cs
示例20: IR_ERR
/// <summary>
/// Creates a new InSim Relay error packet.
/// </summary>
/// <param name="buffer">A buffer contaning the packet data.</param>
public IR_ERR(byte[] buffer) {
PacketReader reader = new PacketReader(buffer);
Size = reader.ReadByte();
Type = (PacketType)reader.ReadByte();
ReqI = reader.ReadByte();
ErrNo = (RelayError)reader.ReadByte();
}
开发者ID:maindefine,项目名称:insimdotnet,代码行数:11,代码来源:IR_ERR.cs
注:本文中的PacketReader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论