Пример #1
0
 public override MemoryStream[] WritePacket()
 {
     // [ContentPlainText String][ContentHTMLText String]
     using (BinaryWriter res = new BinaryWriter(new MemoryStream(64 + BBProtocol.GetMaxEncodedBytes(ContentPlainText)
                                                                 + BBProtocol.GetMaxEncodedBytes(ContentHtmlText)), Encoding.UTF8, true))
     {
         try
         {
             res.BaseStream.Position = 0 + BBProtocol.TCP_HEADERSIZE;
             BBProtocol.WriteString(ContentPlainText, res);
             BBProtocol.WriteString(ContentHtmlText, res);
             return(CreateFragments(res, Opcode));
         }
         catch (Exception e) when(e is IOException || e is IOException)
         {
             ParseError = "Error while writing packet - " + e.Message;
             Log.e(BbTcpPacket.TAG, ParseError);
             return(null);
         }
     }
 }
Пример #2
0
 public override MemoryStream[] WritePacket()
 {
     // [InputID 4] [Text String] [Offset 4] [TextAfterCursor 4]
     using (BinaryWriter res = new BinaryWriter(new MemoryStream(64 + BBProtocol.GetMaxEncodedBytes(m_strText)), Encoding.UTF8, true))
     {
         try
         {
             res.BaseStream.Position = 0 + BBProtocol.TCP_HEADERSIZE;
             res.Write(m_nInputID);
             BBProtocol.WriteString(m_strText, res);
             res.Write(m_nOffset);
             res.Write(m_nTextAfterCursor);
             return(CreateFragments(res, Opcode));
         }
         catch (Exception e) when(e is IOException || e is IOException)
         {
             ParseError = "Error while writing packet - " + e.Message;
             Log.e(BbTcpPacket.TAG, ParseError);
             return(null);
         }
     }
 }