コード例 #1
0
        public static TcpSessionApplicationWorkerConnection CreateApplicationWorkerChannelDispatcher(this ApportionDispatcher apportionDispatcher, IDictionary <long, TcpSessionChannelDispatcher> dispatchers, ConnectionWorkType workType)
        {
            var workerConnection = new TcpSessionApplicationWorkerConnection();

            workerConnection.ConnectionWorkType = workType;
            workerConnection.SetSession(apportionDispatcher.GetCurrentSession());

            var bufferData = apportionDispatcher.ListByteBuffer.ToArray();

            if (bufferData.Length > 0)//如缓冲区有数据,则处理消息
            {
                workerConnection.ListByteBuffer.AddRange(bufferData);
            }
            return(workerConnection);
        }
コード例 #2
0
        public static TcpSessionMainConnection CreateMainServiceChannelDispatcher(this ApportionDispatcher apportionDispatcher, IDictionary <long, TcpSessionChannelDispatcher> dispatchers)
        {
            var mainServiceChannelDispatcher = new TcpSessionMainConnection(dispatchers);

            mainServiceChannelDispatcher.ACKPacketData = apportionDispatcher.GetACKPacketData();
            mainServiceChannelDispatcher.SetSession(apportionDispatcher.GetCurrentSession());
            var bufferData = apportionDispatcher.ListByteBuffer.ToArray();

            if (bufferData.Length > 0)//如缓冲区有数据,则处理消息
            {
                mainServiceChannelDispatcher.ListByteBuffer.AddRange(bufferData);
                mainServiceChannelDispatcher.OnMessage();
            }
            return(mainServiceChannelDispatcher);
        }