本文整理汇总了C#中ByteBuffer.Length方法的典型用法代码示例。如果您正苦于以下问题:C# ByteBuffer.Length方法的具体用法?C# ByteBuffer.Length怎么用?C# ByteBuffer.Length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ByteBuffer
的用法示例。
在下文中一共展示了ByteBuffer.Length方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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();
}
示例2: deserializeBinary
private static Message deserializeBinary(byte[] messageData)
{
byte type, namelen;
long datalen;
Message msg = new Message();
int cnt = 0;
ByteBuffer buf = new ByteBuffer(messageData);
while (buf.hasRemaining())
{
type = buf.get();
namelen = buf.get();
datalen = uIntToLong(buf.get(), buf.get(), buf.get(), buf.get());
if (buf.Length() < namelen + datalen)
{
throw new IOException("Buffer limit exceeded");
}
//Get the key for the map (the name)
string name = null;
if (namelen == 0)
{
name = Convert.ToString(cnt++);
}
else
{
byte[] bName = new byte[namelen];
buf.get(bName);
name = NewString(bName);
}
//Get the actual content
object obj = null;
byte[] bData = new byte[datalen];
buf.get(bData);
switch (type)
{
case HMF_STR:
{
obj = NewString(bData);
break;
}
case HMF_BIN:
{
obj = bData;
break;
}
case HMF_S64:
{
obj = toBigInteger(bData);
break;
}
case HMF_MAP:
{
obj = deserializeBinary(bData);
break;
}
case HMF_LIST:
{
obj = new List<object>(deserializeBinary(bData)._dict.Values);
break;
}
default:
throw new IOException("Unknown data type");
}
msg.putField(name, obj);
}
return msg;
}
示例3: SevenSignSky
public static void SevenSignSky(ByteBuffer buff)
{
//F5 - SKY - PERIOD
//F8 01 01 || 257 = dusk
//F8 02 01 || 258 = dawn
//F8 00 01 = none?
int b = 0;
if (buff.Length() > 1)
{
b = buff.ReadInt16();
}
if (b == 257)
{
Globals.l2net_home.Add_Text("The Dusk moon is in the sky.", Globals.Gray, TextType.SYSTEM);
}
else if (b == 258)
{
Globals.l2net_home.Add_Text("The Dawn moon is in the sky.", Globals.Gray, TextType.SYSTEM);
}
else
{
Globals.l2net_home.Add_Text("The normal moon is in the sky.", Globals.Gray, TextType.SYSTEM);
}
}
示例4: GameGuardReply
public static void GameGuardReply(ByteBuffer buffe)
{
//convert the query to a string and store it...
//then when we catch the reply we can add our new pair
//check if we are running OOG... if so... look for the pair to reply
//if not known... give an error message and dont reply
if (buffe.Length() != 17)
{
buffe.Resize(17);
}
byte[] ggq = new byte[16];
ggq[0] = buffe.ReadByte();
ggq[1] = buffe.ReadByte();
ggq[2] = buffe.ReadByte();
ggq[3] = buffe.ReadByte();
ggq[4] = buffe.ReadByte();
ggq[5] = buffe.ReadByte();
ggq[6] = buffe.ReadByte();
ggq[7] = buffe.ReadByte();
ggq[8] = buffe.ReadByte();
ggq[9] = buffe.ReadByte();
ggq[10] = buffe.ReadByte();
ggq[11] = buffe.ReadByte();
ggq[12] = buffe.ReadByte();
ggq[13] = buffe.ReadByte();
ggq[14] = buffe.ReadByte();
ggq[15] = buffe.ReadByte();
string gg = "";
for (int i = 0; i < ggq.Length; i++)
{
gg += ggq[i].ToString("X2") + " ";
}
gg = gg.Trim();
if (Globals.Script_Debugging)
{
Globals.l2net_home.Add_Debug("GameGuard Query: " + gg);
}
if (Globals.GG_Clientmode)
{
byte[] ggq2 = new byte[17];
ggq2[0] = (byte)PServer.GameGuardQuery;
Buffer.BlockCopy(ggq, 0, ggq2, 1, 16);
string gg2 = "";
for (int i = 0; i < ggq2.Length; i++)
{
gg2 += ggq2[i].ToString("X2") + " ";
}
gg2 = gg2.Trim();
//Globals.l2net_home.Add_Text("Gameguard query: " + gg2, Globals.Green, TextType.BOT);
GameGuardClient.SendGGQuery(ggq2);
}
else if (Globals.gamedata.OOG)
{
gg = gg.Replace(" ", "");
ServerPackets.Send_GameGuardVerify(gg);
}
}
示例5: Script_INJECT_CLIENT
private void Script_INJECT_CLIENT(string line)
{
string hex = Get_String(ref line);
ByteBuffer send = new ByteBuffer();
hex = hex.Replace(" ", "");
string sm;
for (int i = 0; i < hex.Length; i += 2)
{
//make the buffer larger if we need to
if (i / 2 >= send.Length())
{
send.Resize(send.Length() * 2);
}
sm = (hex[i].ToString()) + (hex[i + 1].ToString());
send.WriteByte(byte.Parse(sm, System.Globalization.NumberStyles.HexNumber));
}
send.TrimToIndex();
Globals.gamedata.SendToClient(send);
}
示例6: printData
public static string printData(ByteBuffer buf)
{
return printData(buf.Get_ByteArray(), buf.Length());
}
示例7: GameReadThread
//.........这里部分代码省略.........
Globals.gamedataout.Write(buffpacket[i].ToString("X2"));
Globals.gamedataout.Write(" ");
}
Globals.gamedataout.WriteLine("");
Globals.gamedataout.WriteLine("-data from game server to bot string-");
for (uint i = 0; i < size - 2; i++)
{
Globals.gamedataout.Write((char)buffpacket[i]);
}
Globals.gamedataout.WriteLine("");
#endif
if (Globals.DumpModeServer)
{
dumpbuilder = new System.Text.StringBuilder();
for (int i = 0; i < size - 2; i++)
{
dumpbuilder.Append(buffpacket[i].ToString("X2"));
dumpbuilder.Append(" ");
}
Globals.l2net_home.Add_Dump(dumpbuilder.ToString(), true);
}
//shift the data over by size
for (uint i = 0; i < cnt - size; i++)
{
buffread[i] = buffread[size + i];
}
cnt -= size;
if (buffpacket.Length > 0)
{
handle = true;
forward = true;
bbuffer0 = new ByteBuffer(buffpacket);
if (Globals.gamedata.CurrentScriptState == ScriptState.Running)
{
if ((PServer)buffpacket[0] == PServer.EXPacket)
{
if (ScriptEngine.Blocked_ServerPacketsEX.ContainsKey(System.Convert.ToInt32(buffpacket[1])))
{
forward = false;
}
}
else
{
if (ScriptEngine.Blocked_ServerPackets.ContainsKey(System.Convert.ToInt32(buffpacket[0])))
{
forward = false;
}
}
}
switch ((PServer)buffpacket[0])
{
case PServer.VersionCheck:
handle = false;
forward = false;
if (!Globals.gamedata.ManualGameKey)
{