コード例 #1
0
 public override MemoryStream[] WritePacket()
 {
     m_answerTimer.StartCountDown(4000);
     // [MaxVer 1][MinVer 1][ReqPassword 1][Desc String][OwnGUID 4][ClientVersionMaj 4][ClientVersionMinor 4][ClientVersionBuild 4]
     using (BinaryWriter res = new BinaryWriter(new MemoryStream(512), Encoding.UTF8, true))
     {
         try
         {
             res.BaseStream.Position = 0 + BBProtocol.TCP_HEADERSIZE;
             res.Write(MaxSupportedVersion);
             res.Write(MinSupportedVersion);
             res.Write((byte)(RequiresPassword ? 1 : 0));
             BBProtocol.WriteString(Desc, res);
             res.Write(OwnGUID);
             res.Write(ClientVersion.Major);
             res.Write(ClientVersion.Minor);
             res.Write(ClientVersion.Build);
             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()
 {
     // [PackageName String]
     using (BinaryWriter res = new BinaryWriter(new MemoryStream(512), Encoding.UTF8, true))
     {
         try
         {
             res.BaseStream.Position = 0 + BBProtocol.TCP_HEADERSIZE;
             BBProtocol.WriteString(m_strPackageName, 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);
         }
     }
 }
コード例 #3
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);
         }
     }
 }
コード例 #4
0
 public override MemoryStream[] WritePacket()
 {
     // [FileID 4][Command 1][IsSender 1][ErrorMsg String]
     using (BinaryWriter res = new BinaryWriter(new MemoryStream(32), Encoding.UTF8, true))
     {
         try
         {
             res.BaseStream.Position = 0 + BBProtocol.TCP_HEADERSIZE;
             res.Write(FileID);
             res.Write((byte)Command);
             res.Write((byte)(IsSender ? 1 : 0));
             BBProtocol.WriteString(ErrorMessage, 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);
         }
     }
 }
コード例 #5
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);
         }
     }
 }