本文整理汇总了C#中PacketWriter类的典型用法代码示例。如果您正苦于以下问题:C# PacketWriter类的具体用法?C# PacketWriter怎么用?C# PacketWriter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PacketWriter类属于命名空间,在下文中一共展示了PacketWriter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Session
public Session( World _world, TcpClient _client ) {
world = _world;
loginTime = DateTime.Now;
canReceive = true;
canQueue = true;
canSend = false;
canDispose = false;
outputQueue = new Queue<Packet>();
priorityOutputQueue = new Queue<Packet>();
queueLock = new object();
priorityQueueLock = new object();
client = _client;
client.SendTimeout = 10000;
client.ReceiveTimeout = 10000;
reader = new BinaryReader( client.GetStream() );
writer = new PacketWriter( new BinaryWriter( client.GetStream() ) );
world.log.Log( "Session: {0}", LogType.Debug, ToString() );
ioThread = new Thread( IoLoop );
ioThread.IsBackground = true;
ioThread.Start();
}
示例2: ForceLeave
public static void ForceLeave(Client pClient)
{
if (pClient.mStage == null)
return;
MMatchStage stage = pClient.mStage;
pClient.mStage = null;
pClient.mClientFlags = PacketFlags.Character;
pClient.mPlace = MMatchPlace.Lobby;
PacketWriter pPacket = new PacketWriter(Operation.StageLeave, CryptFlags.Encrypt);
pPacket.Write(pClient.mClientUID);
foreach (Client c in stage.Clients)
{
if (pClient == c) continue;
c.Send(pPacket);
}
lock (stage)
{
stage.Clients.Remove(pClient);
if (stage.Clients.Count == 0)
{
lock (pClient.mChannel.lStages)
pClient.mChannel.lStages.Remove(stage);
StageList(pClient);
return;
}
}
UpdateStageCache(stage, pClient, ObjectCache.New);
stage.stageMaster = stage.Clients[0];
UpdateMaster(stage);
}
示例3: News
public static byte[] News()
{
PacketWriter Writer = new PacketWriter();
Writer.Create(SERVER.SERVER_MAIN);
Writer.Byte(0);
Writer.Byte((byte)Systems.News_List.Count);
foreach (NewsList n in Systems.News_List)
{
Writer.Text(n.Head);
Writer.Text(n.Msg);
Writer.Word(0);
Writer.Word(n.Month);
Writer.Word(n.Day);
Writer.Word(0);
Writer.LWord(0);
}
Writer.Word(0);
return Writer.GetBytes();
}
示例4: TeleportOtherStart
public static byte[] TeleportOtherStart()
{
PacketWriter Writer = new PacketWriter();
Writer.Create(Systems.SERVER_TELEPORTOTHERSTART);
Writer.DWord(0);
return Writer.GetBytes();
}
示例5: UpdatePlace
public static byte[] UpdatePlace()
{
PacketWriter Writer = new PacketWriter();
Writer.Create(Systems.SERVER_SAVE_PLACE);
Writer.Byte(1);
return Writer.GetBytes();
}
示例6: Create
/// <summary>
/// </summary>
/// <param name="username">
/// </param>
/// <returns>
/// </returns>
public static byte[] Create(string username)
{
PacketWriter writer = new PacketWriter(0x07);
IEnumerable<DBCharacter> chars = CharacterDao.Instance.GetAllForUser(username);
byte[] numberOfCharacters = BitConverter.GetBytes(IPAddress.HostToNetworkOrder((Int16)chars.Count()));
writer.WriteBytes(numberOfCharacters);
foreach (DBCharacter character in chars)
{
writer.WriteUInt32((UInt32)character.Id);
}
writer.WriteBytes(numberOfCharacters);
foreach (DBCharacter character in chars)
{
writer.WriteString(character.Name);
}
writer.WriteBytes(numberOfCharacters);
foreach (DBCharacter character in chars)
{
writer.WriteUInt32((UInt32)StatDao.Instance.GetById(50000, character.Id, 54).StatValue);
}
writer.WriteBytes(numberOfCharacters);
foreach (DBCharacter character in chars)
{
writer.WriteUInt32((uint)CharacterDao.Instance.IsOnline(character.Id));
}
return writer.Finish();
}
示例7: FriendGroupManage
public static byte[] FriendGroupManage(string type,string groupname, short groupid, int targetid)
{
PacketWriter Writer = new PacketWriter();
switch (type)
{
case "ADD":
Writer.Create(Systems.SERVER_FRIEND_GROUP);
Writer.Byte(1);
Writer.Text(groupname);
Writer.Word(groupid);
break;
case "REMOVE":
Writer.Create(Systems.SERVER_FRIEND_GROUP_REMOVE);
Writer.Byte(1);
Writer.Word(groupid);
break;
case "MOVE":
Writer.Create(Systems.SERVER_FRIEND_GROUP_MANAGE_FRIEND);
Writer.Byte(1);
Writer.DWord(targetid);
Writer.Word(groupid);
break;
}
return Writer.GetBytes();
}
示例8: ProcessLiveCheck
public static void ProcessLiveCheck(Client pClient, PacketReader pPacket)
{
var timeStamp = pPacket.ReadInt32();
PacketWriter pResponseLiveCheck = new PacketWriter(Operation.MatchAgentResponseLiveCheck, CryptFlags.Encrypt);
pResponseLiveCheck.Write(timeStamp);
pClient.Send(pResponseLiveCheck);
}
示例9: Write
public override void Write(PacketWriter w)
{
w.Write(Time);
w.Write(BulletId);
w.Write(ObjectId);
w.Write(TargetId);
}
示例10: ResponseCharacterItemList
public static void ResponseCharacterItemList(Client client)
{
using (var packet = new PacketWriter(Operation.MatchResponseCharacterItemList, CryptFlags.Decrypt))
{
packet.Write(client.GetCharacter().Bp);
packet.Write(17, 8);
for (var i = 0; i < 17; ++i)
{
packet.Write(0);
packet.Write(client.GetCharacter().EquippedItems[i].ItemCid);
}
packet.Write(client.GetCharacter().Items.Count, 24);
foreach (var i in client.GetCharacter().Items)
{
packet.Write(0);
packet.Write(i.ItemCid);
packet.Write(i.ItemId);
packet.Write(i.RentHour);
packet.Write(0);
packet.Write(i.Quantity);
}
packet.Write(0, 12);
client.Send(packet);
}
}
示例11: Packet
//constructors
public Packet(Packet rhs)
{
lock (rhs.m_lock)
{
m_lock = new object();
m_opcode = rhs.m_opcode;
m_encrypted = rhs.m_encrypted;
m_massive = rhs.m_massive;
m_locked = rhs.m_locked;
if (!m_locked)
{
m_writer = new PacketWriter();
m_reader = null;
m_reader_bytes = null;
m_writer.Write(rhs.m_writer.GetBytes());
}
else
{
m_writer = null;
m_reader_bytes = rhs.m_reader_bytes;
m_reader = new PacketReader(m_reader_bytes);
}
}
}
示例12: Exchange_Approve
public static byte[] Exchange_Approve()
{
PacketWriter Writer = new PacketWriter();
Writer.Create(Systems.SERVER_EXCHANGE_APPROVE);
Writer.Byte(1);
return Writer.GetBytes();
}
示例13: Exchange_Accept
public static byte[] Exchange_Accept()
{
PacketWriter Writer = new PacketWriter();
Writer.Create(Systems.SERVER_EXCHANGE_ACCEPT);
Writer.Byte(1);
return Writer.GetBytes();
}
示例14: CloseExhangeWindow
public static byte[] CloseExhangeWindow()
{
PacketWriter Writer = new PacketWriter();
Writer.Create(Systems.SERVER_EXCHANGE_CLOSE);
Writer.Bool(true);
return Writer.GetBytes();
}
示例15: AlchemyResponse
public static byte[] AlchemyResponse(bool isSuccess, Global.slotItem sItem, byte type, byte totalblue)
{
PacketWriter Writer = new PacketWriter();
Writer.Create(Systems.SERVER_ALCHEMY);
Writer.Byte(1);
Writer.Byte(2);
Writer.Bool(isSuccess);
Writer.Byte(sItem.Slot);
if (!isSuccess) { Writer.Byte(0); }
Writer.DWord(0);
Writer.DWord(sItem.ID);
Writer.Byte(sItem.PlusValue);
Writer.LWord(0);
Writer.DWord(sItem.Durability);
Writer.Byte(Data.ItemBlue[sItem.dbID].totalblue);
for (int i = 0; i <= Data.ItemBlue[sItem.dbID].totalblue - 1; i++)
{
Writer.DWord(Data.MagicOptions.Find(mg => (mg.Name == Convert.ToString(Data.ItemBlue[sItem.dbID].blue[i]))).ID);
Writer.DWord(Data.ItemBlue[sItem.dbID].blueamount[i]);
}
Writer.Word(1);
Writer.Word(2);
Writer.Word(3);
return Writer.GetBytes();
}