public NetOutgoingMessage SendMessage(Connection connection) { NetPeer peer = connection.Peer; NetOutgoingMessage sendMsg = peer.CreateMessage(); sendMsg.Write((uint)PacketId, 16); Bitstream stream = new Bitstream(sendMsg); Serialize(stream); return sendMsg; }
public static Packet Get(NetIncomingMessage message) { var packetId = message.ReadUInt16(); var pdata = PacketFactory.GetPacketType(packetId); var newPacket = (Packet)Activator .CreateInstance(pdata.PacketType); if (newPacket != null) { Bitstream stream = new Bitstream(message); newPacket.Deserialize(stream); return newPacket; } //TODO return null; }
public override void Deserialize(Bitstream msg) { State = new List<PlayerStateData>(); int count = msg.ReadUInt16(); for (int i = 0; i < count; ++i) { var o = new PlayerStateData(); o.Forward = msg.ReadBool(); o.Back = msg.ReadBool(); o.Left = msg.ReadBool(); o.Right = msg.ReadBool(); o.Position = msg.ReadVector2(); o.SimTick = (uint)msg.ReadInt32(); State.Add(o); } SnapId = msg.ReadInt32(); }
public override void Serialize(Bitstream msg) { msg.Write(Message); msg.Write(From); }
public override void Deserialize(Bitstream msg) { Message = msg.ReadString(); From = msg.ReadString(); }
public override void Serialize(Bitstream msg) { }
public override void Serialize(Bitstream msg) { msg.Write(Username); }
public override void Deserialize(Bitstream msg) { Username = msg.ReadString(); }
public abstract void Serialize(Bitstream msg);