public BulletinBoardSendPostSummaryPacket(BulletinBoard Board, BulletinBoardPost Post) : base(0x71) { // Set the maximum size EnsureCapacity(1024); // Fill the packet data UnderlyingStream.Write((byte)BulletinPacket.PacketSubType.SendPostSummary); int BoardSerial = Board.Serial; if ((Post.RootParent != null) && (Post.RootParent is BulletinBoard)) { BoardSerial = (((Item)(Post.RootParent)).Serial); } UnderlyingStream.Write((int)BoardSerial); // Bulletin Board Serial UnderlyingStream.Write((int)Post.Serial); // Post Serial int ParentSerial = Board.Serial; if ((Post.Parent != null) && ((Post.Parent is BulletinBoard) || (Post.Parent is BulletinBoardPost))) { ParentSerial = (((Item)(Post.Parent)).Serial); } UnderlyingStream.Write((int)(ParentSerial == BoardSerial ? 0 : ParentSerial)); // Parent Serial (if it is a reply) UnderlyingStream.Write((byte)(Post.Author.Length + 1)); UnderlyingStream.WriteAsciiNull(Post.Author); UnderlyingStream.Write((byte)(Post.Subject.Length + 1)); UnderlyingStream.WriteAsciiNull(Post.Subject); UnderlyingStream.Write((byte)(Post.Date.Length + 1)); UnderlyingStream.WriteAsciiNull(Post.Date); // Log the raw packet info BulletinPacket.LogPacket("BulletinBoardSendPostSummaryPacket", UnderlyingStream.ToArray()); }
public BulletinBoardOpenPacket(BulletinBoard Board) : base(0x71) { // Don't need much room here (just enough to take into account a // non-default bulletin board name) EnsureCapacity(256); // Get the name of the bulletin board string BoardName = Board.Name == null ? "Bulletin Board" : Board.Name; // Fill the packet data UnderlyingStream.Write((byte)BulletinPacket.PacketSubType.DisplayBoard); UnderlyingStream.Write((int)Board.Serial); UnderlyingStream.WriteAsciiNull(BoardName); // Log the raw packet info BulletinPacket.LogPacket("BulletinBoardOpenPacket", UnderlyingStream.ToArray()); }
public BulletinBoardPostPacket(BulletinBoardPost Post) : base(0x71) { // Set the maximum size EnsureCapacity(65535); // Fill the packet data UnderlyingStream.Write((byte)BulletinPacket.PacketSubType.SendPostMessage); int BoardSerial = 0; if ((Post.RootParent != null) && (Post.RootParent is BulletinBoard)) { BoardSerial = (((Item)(Post.RootParent)).Serial); } UnderlyingStream.Write((int)BoardSerial); // Bulletin Board Serial UnderlyingStream.Write((int)Post.Serial); // Post Serial UnderlyingStream.Write((byte)(Post.Author.Length + 1)); UnderlyingStream.WriteAsciiNull(Post.Author); UnderlyingStream.Write((byte)(Post.Subject.Length + 1)); UnderlyingStream.WriteAsciiNull(Post.Subject); UnderlyingStream.Write((byte)(Post.Date.Length + 1)); UnderlyingStream.WriteAsciiNull(Post.Date); #region Unknown Constant // Some constant that is needed (DON'T Change Anything in here unless // you've figured out what the contents of the packet do) //"\x01\x90\x83\xea\x06\x15\x2e\x07\x1d\x17\x0f\x07\x37\x1f\x7b // \x05\xeb\x20\x3d\x04\x66\x20\x4d\x04\x66\x0e\x75\x00\x00" UnderlyingStream.Write((byte)0x01); UnderlyingStream.Write((byte)0x90); UnderlyingStream.Write((byte)0x83); UnderlyingStream.Write((byte)0xEA); UnderlyingStream.Write((byte)0x06); UnderlyingStream.Write((byte)0x15); UnderlyingStream.Write((byte)0x2E); UnderlyingStream.Write((byte)0x07); UnderlyingStream.Write((byte)0x1D); UnderlyingStream.Write((byte)0x17); UnderlyingStream.Write((byte)0x0F); UnderlyingStream.Write((byte)0x07); UnderlyingStream.Write((byte)0x37); UnderlyingStream.Write((byte)0x1F); UnderlyingStream.Write((byte)0x7B); UnderlyingStream.Write((byte)0x05); UnderlyingStream.Write((byte)0xEB); UnderlyingStream.Write((byte)0x20); UnderlyingStream.Write((byte)0x3D); UnderlyingStream.Write((byte)0x04); UnderlyingStream.Write((byte)0x66); UnderlyingStream.Write((byte)0x20); UnderlyingStream.Write((byte)0x4D); UnderlyingStream.Write((byte)0x04); UnderlyingStream.Write((byte)0x66); UnderlyingStream.Write((byte)0x0E); UnderlyingStream.Write((byte)0x75); UnderlyingStream.Write((byte)0x00); UnderlyingStream.Write((byte)0x00); #endregion // Lets assume that all of the previous data that is of varying size // was completely full (255 characters for Author, Subject, and Date) // The total size of the packet so far would then be (in bytes): // 1+2+1+4+4+1+255+1+255+1+255+29 = 809 Bytes // That leaves 65535-809 = 64726 Bytes for the remaining lines of the // message. Each line can contain a maximum of 255 characters (including the terminating null) // And there can only be a total of 255 lines so, to be safe we are only // going to allow 250 lines max! That will result in a total of // 250x256 = 64000 Bytes total for a complete message (way under the 64766 limit) // Set the maximum number of lines int MaxLines = (Post.Message.Length < 250 ? Post.Message.Length : 250); UnderlyingStream.Write((byte)MaxLines); // Add each line (up to the maximum number of lines) for (int x = 0; ((x < Post.Message.Length) && (x < 250)); x++) { UnderlyingStream.Write((byte)(Post.Message[x].Length + 1)); UnderlyingStream.WriteAsciiNull(Post.Message[x]); } // Log the raw packet info BulletinPacket.LogPacket("BulletinBoardPostPacket", UnderlyingStream.ToArray()); }