本文整理汇总了C#中Packet.Write方法的典型用法代码示例。如果您正苦于以下问题:C# Packet.Write方法的具体用法?C# Packet.Write怎么用?C# Packet.Write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Packet
的用法示例。
在下文中一共展示了Packet.Write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MultiplayerBase
public MultiplayerBase(string address, int port, PGGI.PGGIProvider provider)
{
ISpriteBatchService spriteService = Atom.Shared.Globals.Engine.GetService<ISpriteBatchService>();
IInputService inputService = Atom.Shared.Globals.Engine.GetService<IInputService>();
contract = inputService.CreateContract();
contract.Enabled = true;
contract.SubscribedTouchEvents = TouchStates.OnDoubleTap | TouchStates.OnDrag | TouchStates.OnTap;
contract.TouchEventHandler += contract_TouchEventHandler;
spriteBatch = spriteService.SpriteBatch;
SelectionState = SelectionState.Selection;
GameState = MultiplayerGameState.Connecting;
GameCounter = 0;
client = new Client();
client.OnConnection += new EventHandler<ConnectionArgs>(ClientOnConnection);
client.OnPacketRecieved += new EventHandler<PacketRecievedArgs>(ClientOnPacket);
Packet ConnectionPacket = new Packet();
ConnectionPacket.Write(provider.PGGI);
ConnectionPacket.Write(provider.Token);
client.Connect(new System.Net.DnsEndPoint(address, port), ConnectionPacket);
Syncing = false;
FramesToSpin = int.MaxValue;
Manager = new MultiplayerGameManager();
Content = new ContentManager(Atom.Shared.Globals.Engine, "Content");
Fleet = Content.Load<Texture2D>("Graphics/Fleets/1");
}
示例2: Write
public void Write(Packet packet)
{
packet.PutBit(NoBirthAnim);
packet.PutBit(false);
packet.PutBit(false);
packet.PutBit(false);
packet.PutBit(Move != null);
packet.PutBit(false);
packet.PutBit(Stationary != null);
packet.PutBit(false);
packet.PutBit(false);
packet.PutBit(false);
packet.PutBit(false);
packet.PutBit(HasRotation);
packet.PutBit(false);
packet.PutBit(false);
packet.PutBit(ThisIsYou);
packet.PutBit(false);
packet.PutBit(false);
packet.PutBit(false);
packet.FlushBits();
packet.Write(0);
if (Move != null)
Move.Write(packet);
if (Stationary != null)
Stationary.Write(packet);
if (HasRotation)
packet.Write(Rotation);
}
示例3: WriteToPacket
public void WriteToPacket(Packet pkt)
{
pkt.Write(maskSize);
var length = maskSize << 2;
var maskArray = new byte[((Mask.Length + 8) / 8) + 1];
if (length > maskArray.Length)
maskArray = maskArray.Combine(new byte[length - maskArray.Length]);
Mask.CopyTo(maskArray, 0);
pkt.WriteBytes(maskArray, length);
for (var i = 0; i < Mask.Count; i++)
{
if (Mask.Get(i) && Data.ContainsKey(i))
{
if (Data[i] is uint)
pkt.Write((uint)Data[i]);
else if (Data[i] is float)
pkt.Write((float)Data[i]);
else
pkt.Write((int)Data[i]);
}
}
Mask.SetAll(false);
// Dynamic Descriptors...
pkt.Write<byte>(0);
}
示例4: Write
public void Write(Packet packet)
{
packet.Write(MapId);
packet.Write(Objects.Count);
Objects.ForEach(o => packet.Write(o.Guid));
}
示例5: Accept
public void Accept()
{
var socketEventargs = new SocketAsyncEventArgs();
socketEventargs.SetBuffer(dataBuffer, 0, dataBuffer.Length);
socketEventargs.Completed += OnConnection;
socketEventargs.UserToken = client;
socketEventargs.SocketFlags = SocketFlags.None;
client.ReceiveAsync(socketEventargs);
if (!isTransferInitiated[0])
{
var serverToClient = "WORLD OF WARCRAFT CONNECTION - SERVER TO CLIENT";
var transferInitiate = new Packet();
transferInitiate.Write((ushort)(serverToClient.Length + 1));
transferInitiate.Write(serverToClient, true);
Send(transferInitiate);
isTransferInitiated[0] = true;
}
}
示例6: Write
public void Write(Packet packet)
{
packet.Write(Status);
packet.PutBit(InfoProvided);
packet.PutBit(KeyProvided);
packet.PutBit(UrlProvided);
if (UrlProvided)
{
packet.PutBits(Url.Length, 8);
packet.FlushBits();
packet.WriteString(Url);
}
packet.FlushBits();
if (InfoProvided)
{
packet.Write(KeyVersion);
packet.Write(Revision);
}
if (KeyProvided)
packet.WriteBytes(KeyData);
}
示例7: Write
public void Write(Packet packet)
{
packet.Write(RealmId, 32);
packet.Write(Messages.Count, 8);
Messages.ForEach(m => packet.WriteWString(m));
}
示例8: WritePacket
public override void WritePacket()
{
m_packet = new Packet();
m_packet.PacketID = (short)LobbyPacketID.CharInfo;
m_packet.Write(InfoNumber);
m_packet.Write(Position);
m_packet.Write(Rotation);
m_packet.WriteEnd();
}
示例9: Challenge
internal static byte[] Challenge(int SessionID)
{
Packet p = new Packet();
p.Write((byte)0xFE);
p.Write((byte)0xFD);
p.Write((byte)0x09);
p.Write(SessionID);
return p.Finalize();
}
示例10: QueryInfo
internal static byte[] QueryInfo(int SessionID, int ChallengeToken)
{
Packet p = new Packet();
p.Write((byte)0xFE);
p.Write((byte)0xFD);
p.Write((byte)0x00);
p.Write(SessionID);
p.Write(ChallengeToken);
return p.Finalize();
}
示例11: Leave
public void Leave(Player plr)
{
Player tmp;
_players.TryRemove(plr.Session.Guid, out tmp);
plr.Channel = null;
if (ServerType != EServerType.Chat) return;
var ack = new Packet(EChatPacket.SChannelPlayerLeftAck);
ack.Write((uint)ID);
ack.Write(plr.AccountID);
Broadcast(ack);
}
示例12: Write
public void Write(Packet packet)
{
packet.Write(Id);
for (var i = 0; i < 4; i++)
{
packet.Write(NameMD5[i]);
packet.Write(VersionMD5[i]);
}
packet.Write(LastModified);
packet.Write(Flags);
}
示例13: WriteReadByteDataTest
public void WriteReadByteDataTest()
{
Packet writePacket = new Packet(packetOpcode);
writePacket.Write(uint32Value);
writePacket.Write(uint16Value);
writePacket.Write(byteValue);
writePacket.Write(int32Value);
writePacket.Write(int16Value);
writePacket.Write(sbyteValue);
writePacket.Write(stringValue);
writePacket.Write(byteArrayValue);
Packet readPacket = new Packet(writePacket.Data);
Assert.AreEqual(writePacket.OpcodeNumber, readPacket.OpcodeNumber);
Assert.AreEqual(uint32Value, readPacket.ReadUInt32());
Assert.AreEqual(uint16Value, readPacket.ReadUInt16());
Assert.AreEqual(byteValue, readPacket.ReadByte());
Assert.AreEqual(int32Value, readPacket.ReadInt32());
Assert.AreEqual(int16Value, readPacket.ReadInt16());
Assert.AreEqual(sbyteValue, readPacket.ReadSByte());
Assert.AreEqual(stringValue, readPacket.ReadString());
var packetBytes = readPacket.ReadBytes();
for (int i = 0; i < byteArrayValue.Length; i++)
Assert.AreEqual(byteArrayValue[i], packetBytes[i]);
readPacket.Dispose();
writePacket.Dispose();
}
示例14: HandleEnumCharactersResult
public static void HandleEnumCharactersResult(RealmSession session)
{
var enumCharactersResult = new Packet(ServerMessages.EnumCharactersResult);
enumCharactersResult.PutBit(1);
enumCharactersResult.PutBit(0);
enumCharactersResult.Flush();
enumCharactersResult.Write(0);
enumCharactersResult.Write(0);
session.Send(enumCharactersResult);
}
示例15: Write
public void Write(Packet packet)
{
packet.Write(TemplateSetID);
packet.Write(Classes.Count);
Classes.ForEach(c => c.Write(packet));
packet.PutBits(Name.Length, 7);
packet.PutBits(Description.Length, 10);
packet.FlushBits();
packet.WriteString(Name);
packet.WriteString(Description);
}