/// <summary> /// Wrap all contents into a byte array for sending /// </summary> public override byte[] Pack() { int size = SizeOf // Base + 1 // Byte - what + 1 // Byte - context + 2 // UInt16 - key value pairs count + 2 // Int16 - stack level + 4 // Int32 - index + 2 + Encoding.UTF32.GetBytes(Value).Length // string length + string + 2; // Int16 - value type foreach (var kv in LookUp.NamesAndTypes) { var bytes = Encoding.UTF8.GetBytes(kv.Name); size += 2; // UInt16 - length of string that follows size += bytes.Length; // UInt16 - string size += 2; // UInt16 - name lua_t<type> } var buffer = new byte[size]; base.Pack(ref buffer, buffer.Length); var packer = new SledNetworkBufferPacker(ref buffer, SizeOf); packer.PackByte((Byte)(int)LookUp.Scope); packer.PackByte((Byte)(int)LookUp.Context); packer.PackUInt16((UInt16)LookUp.NamesAndTypes.Count); packer.PackInt16((Int16)LookUp.StackLevel); packer.PackInt32(LookUp.Index); packer.PackString(Value); packer.PackInt16(ValueType); foreach (var kv in LookUp.NamesAndTypes) { packer.PackString(kv.Name); packer.PackUInt16((UInt16)kv.NameType); } return buffer; }
/// <summary> /// Wrap all contents into a byte array for sending /// </summary> /// <returns>Packed data</returns> public override byte[] Pack() { var buffer = new byte[SizeOf + 2 + 2 + 2]; base.Pack(ref buffer, buffer.Length); var packer = new SledNetworkBufferPacker(ref buffer, SizeOf); packer.PackUInt16(Major); packer.PackUInt16(Minor); packer.PackUInt16(Revision); return buffer; }
/// <summary> /// Wrap all base SLED Control Message Protocol (SCMP) contents into a new byte array for sending /// </summary> /// <returns>Packed data</returns> public virtual byte[] Pack() { var buffer = new byte[4 + 2 + 2]; var packer = new SledNetworkBufferPacker(ref buffer); packer.PackInt32(m_length); packer.PackUInt16(m_typeCode); packer.PackUInt16(m_pluginId); return buffer; }
/// <summary> /// Wrap all contents into a byte array for sending /// </summary> /// <returns>Packed data</returns> public override byte[] Pack() { var buffer = new byte[SizeOf + 2 + (2 + Encoding.UTF8.GetBytes(RelFilePath).Length) + 4]; base.Pack(ref buffer, buffer.Length); var packer = new SledNetworkBufferPacker(ref buffer, SizeOf); packer.PackUInt16(BreakPluginId); packer.PackString(RelFilePath); packer.PackInt32(Line); return buffer; }
/// <summary> /// Pack an already existing buffer with the base SLED Control Message Protocol (SCMP) information /// </summary> /// <param name="buffer">Buffer to pack data into</param> /// <param name="iRealLength">Real length of the class (includes derived members)</param> protected virtual void Pack(ref byte[] buffer, Int32 iRealLength) { var packer = new SledNetworkBufferPacker(ref buffer); m_length = iRealLength; // This is the real length wrt all the members of the derived class packer.PackInt32(m_length); packer.PackUInt16(m_typeCode); packer.PackUInt16(m_pluginId); }