コード例 #1
0
 /// <summary>
 /// 添加一个输出包
 /// <remark>abu 2008-03-03 </remark>
 /// </summary>
 /// <param name="outPacket">The out packet.</param>
 /// <param name="monitor">The monitor. true为同步发送,false为异步发送</param>
 public void Send(QQ.NET.Packets.OutPacket outPacket, bool monitor)
 {
     //记录发送历史
     policy.PutSent(outPacket);
     //outPacketQueue.Enqueue(outPacket);
     if (monitor)
     {
         SendData(this.socket, outPacket);
     }
     else
     {
         BeginSendData(this.socket, outPacket);
     }
 }
コード例 #2
0
        /// <summary> 把ByteBuffer中的内容解析成一个InPacket子类,从buf的当前位置开始解析,直到limit为止
        /// * 不论解析成功或者失败,要把buf的position置于length后
        ///     <remark>abu 2008-03-07 </remark>
        /// </summary>
        /// <param name="parser">The parser.</param>
        /// <param name="buf">The buf.</param>
        /// <param name="length">The length.</param>
        /// <param name="user">The user.</param>
        /// <returns></returns>
        private OutPacket ParseOut(IParser parser, ByteBuffer buf, int length, QQUser user)
        {
            int pos = buf.Position;

            try
            {
                OutPacket ret = parser.ParseOutcoming(buf, length, user);
                return(ret);
            }
            finally
            {
                buf.Position = pos + length;
            }
        }
コード例 #3
0
 /// <summary>
 /// 这个方法检查包是否已收到,要注意的是检查是针对这个包的hash值进行的,
 /// * 并不是对packet这个对象,hash值的计算是在packet的hashCode中完成的,
 /// * 如果两个packet的序号或者命令有不同,则hash值肯定不同。
 ///     <remark>abu 2008-03-07 </remark>
 /// </summary>
 /// <param name="packet">The packet.</param>
 /// <param name="add">if set to <c>true</c> [add].如果为true,则当这个包不存在时,添加这个包的hash,否则不添加</param>
 /// <returns>true如果这个包已经收到,否则false</returns>
 public bool IsReplied(OutPacket packet, bool add)
 {
     if (parsers[packet.GetFamily()] != null)
     {
         PacketHistory history = parsers[packet.GetFamily()].GetHistory();
         if (history != null)
         {
             return(history.Check(packet, add));
         }
         else
         {
             return(false);
         }
     }
     return(false);
 }