コード例 #1
0
        /// <summary>
        /// 将要发送的数据包存入队列
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="type">数据包类型0-Protobuf,1-Json</param>
        /// <param name="tobject"></param>
        /// <param name="channel"></param>
        internal void AddSendBuff <T>(int channel, int type, T tobject, bool OffCheckTimeOut)
        {
            byte[] tbuff = null;
            switch (type)
            {
            case 0:
                tbuff = NSocket.Serialize(tobject);
                break;

            case 1:
                tbuff = FromString.GetBytes(tobject as string, Encoding.Default);
                break;
            }
            byte[] buff = Encoder(channel, type, tbuff);
            SendBuffQue.Enqueue(new KeyValuePair <int, byte[]>(OffCheckTimeOut == false ? channel : -1, buff));
            SendBuff();
        }