本文整理汇总了C#中ByteBuffer.WriteByte方法的典型用法代码示例。如果您正苦于以下问题:C# ByteBuffer.WriteByte方法的具体用法?C# ByteBuffer.WriteByte怎么用?C# ByteBuffer.WriteByte使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ByteBuffer
的用法示例。
在下文中一共展示了ByteBuffer.WriteByte方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendPacket
public static void SendPacket(this AsyncConnection con, IServerPacket pkt)
{
byte opcode = OpcodeManager.Instance.GetOpcode(pkt.GetType().Name);
uint packetid = OpcodeManager.Instance.GetPacketID(pkt.GetType().Name);
if (packetid == 0)
{
TORLog.Error("ERROR: No PacketID defined for " + pkt.GetType().Name);
return;
}
ByteBuffer packet = new ByteBuffer(ByteOrder.LittleEndian);
packet.WriteByte(opcode);
packet.WriteInt(0); // Length
packet.WriteByte(0); // ChkByte
packet.WriteUInt(packetid);
pkt.WritePacket(con, packet);
con.SendTORPacket(packet);
TORLog.Network("PktSend @ " + con.GetHashCode() + " >> " + pkt.GetType().Name);
}
示例2: write
public static byte[] write()
{
byte[] temp = init();
ByteBuffer buff = new ByteBuffer();
buff.WriteD(temp.Length + 4);
for (int i = 0; i < temp.Length - 1; i++)
{
buff.WriteByte(temp[i]);
}
buff.Resize(temp.Length + 4);
size = buff.Length();
return buff.Get_ByteArray();
}
示例3: write
public static byte[] write()
{
buff = new ByteBuffer(45);
buff.WriteD(45);
buff.WriteD(0x7D2);
buff.WriteD(1);
buff.WriteD(4);
buff.WriteD(3);
buff.WriteD(559993);
buff.WriteByte(0x05);
buff.WriteDD(-313054979819954861);
buff.WriteD(0);
buff.WriteD(0);
buff.WriteD(0);
return buff.Get_ByteArray();
}
示例4: Main
static void Main(string[] args)
{
Console.Title = "Nexus Shard Server";
Console.WriteLine("Nexus Shard Server\n");
Utility.WriteLegal();
Console.WriteLine("");
AsyncServer server = new AsyncServer(IPAddress.Parse("0.0.0.0"), 20063);
server.Start();
server.ConnectionAccepted += new AsyncServer.ConnectionAcceptedHandler(connection =>
{
TORLog.Network("CnxAccept => " + connection.GetHashCode());
connection.DataReceived += new AsyncConnection.ConnectionDataReceivedHandler(data =>
{
if (connection.State == 1)
{
// rsa packet
connection.SetState(2);
connection.SendPacket(new SMsg_ClientSignatureRequest("OmegaServerProxyObjectName", 0x0174F5));
return;
}
ByteBuffer buffer = new ByteBuffer(ByteOrder.LittleEndian, data);
byte opcode = (byte)buffer.ReadByte();
byte[] len_data = buffer.ReadBytes(4);
byte chk = (byte)buffer.ReadByte();
uint packetid = buffer.ReadUInt();
if (chk != (byte)(opcode ^ len_data[0] ^ len_data[1] ^ len_data[2] ^ len_data[3]))
{
TORLog.Warn("Received packet with invalid checksum!");
}
if (opcode == 1) // Client Ping Packet
{
TORLog.Network("Ping from " + connection.GetHashCode() + " Seq = " + packetid);
ByteBuffer response = new ByteBuffer(ByteOrder.LittleEndian);
response.WriteByte(2); // Pong OPC = 2
response.WriteInt(0); // Pong Len
response.WriteByte(0); // Pong Chk
response.WriteUInt(packetid); // Pong
response.WriteInt(0);
response.WriteInt(1);
response.WriteByte(0);
connection.SendTORPacket(response);
return;
}
string packetname = OpcodeManager.Instance.GetPacketName(opcode, packetid);
if (packetname == "")
{
TORLog.Warn("Received unknown packet from SWTOR client\nOpcode = 0x" + opcode.ToString("X2") + " -- PacketID = 0x" + packetid.ToString("X8"));
TORLog.Warn("--- dump ---");
TORLog.Warn(Utility.HexDump(data));
}
else
{
try
{
IClientPacket pkt = Activator.CreateInstance(Type.GetType("ShardServer.Packets.Client." + packetname)) as IClientPacket;
TORLog.Network("PktRecv @ " + connection.GetHashCode() + " << " + packetname);
pkt.ExecutePacket(connection, buffer);
}
catch (Exception ex)
{
TORLog.Error("Exception occured while processing " + packetname, ex);
}
}
});
// Send HELLO packet
connection.SendClear(new byte[] { 0x03, 0x0e, 0x00, 0x00, 0x00, 0x0d, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });
// State is 1
connection.SetState(1);
connection.EngageReading();
});
TORLog.Info("SHARD Server running, press Enter to exit ...");
Console.ReadLine();
}
示例5: SendTORPacket
public void SendTORPacket(ByteBuffer buffer)
{
// here we receive a buffer prepared for length insertion
int length = (int)buffer.Position;
buffer.Position = 1;
buffer.WriteInt(length);
byte[] data = buffer.ToArray();
byte chk = (byte)(data[0] ^ data[1] ^ data[2] ^ data[3] ^ data[4]);
buffer.WriteByte(chk);
SendRegularPacket(buffer.ToArray());
}
示例6: WriteCharacterInfo
void WriteCharacterInfo(ByteBuffer packet, Character cha, byte add)
{
packet.WriteBytes(new byte[] { (byte)(0x86 + add), 0x00, 0x00, 0x40 }); // Dynamic
packet.WriteUInt(0x4e7511aa); // Static
packet.WriteUInt(0x899);
packet.WriteByte(0x80);
packet.WriteBytes(new byte[] {
0xe8, 0x7e, 0x20, 0x9b, // E8 7E 20 9B
(byte)(0x86 + add), 0x00, 0x00, 0x40, // 4F 00 00 40
0xe8, 0x7e, 0x20, 0x9b, // E8 7E 20 9B
(byte)(0x86 + add), 0x00, 0x00, 0x40, // 4F 00 00 40
});
packet.WriteBytes(new byte[] { 0x05, 0x00, 0x02 });
long detailsLengthPlaceholder = packet.Position;
packet.WriteInt(0); // placeholder for details length
packet.WriteBytes(new byte[] {
0x14, 0x14, 0xCF, 0x40,
0x00, 0x00, 0x04, 0xE0,
0xD7, 0x68, 0xB5, 0x03,
0x01, 0xCC, 0x07, 0xD8,
0x87, 0xD6, 0x02, 0x03,
0x00, 0xCC, 0x29, 0x40,
0x56, 0x77, 0x5B, 0x03,
0x01, 0xC4, 0x30, 0x1A,
0x0D, 0x75, 0xB9, 0x15,
0xCD, 0x0B,
}); // static
packet.WriteBytes(new byte[] { 0xcc, 0xbd, 0x33, 0x9c, 0xdd }); // unk dynamic (CC BD 33 9C DD)
packet.WriteBytes(new byte[] {
0xCC, 0x07, 0x18, 0xC2,
0x55, 0x7C, 0x09, 0x04,
0x04, 0xCF, 0x40, 0x00,
0x00, 0x30, 0x5C, 0x21,
0xB1, 0x10, 0x02 }); // static
packet.WriteBytes(new byte[] {
//0x95, 0x01, 0x02,
//0xC9, 0x02, 0x8A, 0x01, 0x02,
//0xC9, 0x02, 0x8C, 0x01, 0x02, 0x9C, // C9 02 FC 01 02 8A 01 02 C9 02 F5 01 02 C9 03 08
0xC9, 0x02, 0xFC, 0x01, 0x02, 0x8A, 0x01, 0x02,
0xC9, 0x02, 0xF5, 0x01, 0x02, 0xC9, 0x03, 0x08,
0xCB, 0x91, 0xFC, 0x05,
0xB8, 0x02,
0x06, 0xCC, 0x27, 0x32, 0x2B, // static
0x0D, 0xFD, 0x02, 0xCA, // static
0x76, // static
0xc4, 0x7f, // dynamic
0xCB, 0x50, 0x5D, 0x6C, 0xC6, // static
0x04, 0x33, 0x83, 0xc5, // static
0x44, // static
0x01, // static
0x04, 0x9a, 0xdd, 0xdc, // static
0x45,
0xC4, 0x25, 0x42, 0x9A, // Static
0x25, 0xBA, 0x02, 0xCF }); // Static
packet.WriteUInt(cha.APP1);
packet.WriteUInt(cha.APP2);
packet.WriteUInt(cha.APP3);
packet.WriteUShort(cha.APP4);
packet.WriteByte(0xCF);
/*packet.WriteBytes(new byte[] {
0x56, 0xF6, 0x33, 0xF2, //0E B2 4F F8
0xDD, 0xDE, 0x74, 0x77, //51 1E 46 3C
0xCB, 0x6C, 0x9C, 0xB1, //CB 6C 9C B1
0xA7, 0x01, 0xCF,
//0xE0, 0x00, 0xFD, 0x35, 0xB1, 0x0B, 0x17, 0x60 //9B E1 60
});*/ // appearance ? from char creation
//packet.WriteBytes(BitConverter.GetBytes((ulong)CharacterClass.JediConsular));
packet.WriteULongRev((ulong)cha.Class);
packet.WriteBytes(new byte[] { 0xCC, 0x25, 0xEB, 0x85,
0x46, 0x42, 0x03, 0x01, // 0 = 1
0xC4, 0x25, 0xD0, 0x6C, 0xA1,
0x13, 0x07,
});
// Inventory
ulong[] ids = new ulong[] { 0xe000e32eacf6fe1c, 0xe00096830962E510, 0xE0002D97FFB1222D };
packet.WriteByte(1);
packet.WriteByte((byte)ids.Count());
packet.WriteByte((byte)ids.Count());
packet.WriteByte(1);
packet.WriteByte(0xcf);
int ctr = 0;
foreach (ulong id in ids)
{
//.........这里部分代码省略.........