예제 #1
0
        public static TCPOutPacket MakeTCPOutPacket(TCPOutPacketPool pool, byte[] data, int offset, int length, int cmd)
        {
            TCPOutPacket tcpOutPacket = pool.Pop();

            tcpOutPacket.PacketCmdID = (ushort)cmd;
            tcpOutPacket.FinalWriteData(data, offset, length);
            return(tcpOutPacket);
        }
예제 #2
0
        /// <summary>
        /// 生成TCPOutPacket
        /// </summary>
        /// <param name="data"></param>
        /// <param name="cmd"></param>
        public static TCPOutPacket MakeTCPOutPacket(TCPOutPacketPool pool, byte[] data, int cmd)
        {
            TCPOutPacket tcpOutPacket = pool.Pop();

            tcpOutPacket.PacketCmdID = (UInt16)cmd;
            tcpOutPacket.FinalWriteData(data, 0, data.Length);
            return(tcpOutPacket);
        }
예제 #3
0
        public static TCPOutPacket MakeTCPOutPacket(TCPOutPacketPool pool, string data, int cmd)
        {
            TCPOutPacket tcpOutPacket = pool.Pop();

            tcpOutPacket.PacketCmdID = (ushort)cmd;
            byte[] bytesCmd = new UTF8Encoding().GetBytes(data);
            tcpOutPacket.FinalWriteData(bytesCmd, 0, bytesCmd.Length);
            return(tcpOutPacket);
        }
예제 #4
0
        /// <summary>
        /// 生成TCPOutPacket
        /// </summary>
        /// <param name="data"></param>
        /// <param name="cmd"></param>
        public static TCPOutPacket MakeTCPOutPacket(TCPOutPacketPool pool, string data, int cmd)
        {
            //if (pool.Count <= 0) //如果缓存为空,则打印日志,看是谁在分配
            //{
            //    //调试信息
            //    if (LogManager.LogTypeToWrite >= LogTypes.Info && LogManager.LogTypeToWrite <= LogTypes.Error)
            //    {
            //        try
            //        {
            //            System.Diagnostics.StackTrace stackTrace = new System.Diagnostics.StackTrace();
            //            string methodName1 = "", methodName2 = "";
            //            if (stackTrace.FrameCount > 1)
            //            {
            //                methodName2 = stackTrace.GetFrame(1).GetMethod().Name;
            //            }

            //            if (stackTrace.FrameCount > 2)
            //            {
            //                methodName1 = stackTrace.GetFrame(2).GetMethod().Name;
            //            }

            //            LogManager.WriteLog(LogTypes.Error, string.Format("{0}->{1}, 调用MakeTCPOutPacket", methodName1, methodName2));
            //        }
            //        catch (Exception)
            //        {
            //        }
            //    }
            //}

            //连接成功, 立即发送请求登陆的指令
            TCPOutPacket tcpOutPacket = pool.Pop();

            tcpOutPacket.PacketCmdID = (Int16)cmd;
            byte[] bytesCmd = new UTF8Encoding().GetBytes(data);
            tcpOutPacket.FinalWriteData(bytesCmd, 0, bytesCmd.Length);
            return(tcpOutPacket);
        }