Beispiel #1
0
        //此任务根据设置可能在其它任务处理线上执行
        void SendedTask(object data)
        {
            Packet    packet    = (Packet)data;
            NetSocket socketCtx = packet.socketCtx;
            Server    server    = GetServer();

            if (CheckingPacketVaild(packet) == 0)
            {
                return;
            }

            SocketError socketError = System.Net.Sockets.SocketError.Success;

            packet.transferedBytes = socketCtx.sock.EndSend(packet.ar, out socketError);
            if (socketError != System.Net.Sockets.SocketError.Success)
            {
                SocketError(socketCtx);
                return;
            }


            if (useSendedEvent)
            {
                if (useSingleSendDataTaskProcesser)
                {
                    PostTask(ProcessSendedMsgTask, packet.socketID);
                }
                else
                {
                    socketCtx.dePacketor.UnPack(SocketEvent.EV_SOCKET_SEND, socketCtx);
                }
            }


            List <Packet> sendList = socketCtx.sendList;

            if (sendList.Count == 0)
            {
                return;
            }

            packet = sendList[0];
            sendList.RemoveAt(0);
            server.IocpPostSend(packet);
        }
Beispiel #2
0
        //此任务根据设置可能在其它任务处理线上执行
        void SendTask(object data)
        {
            Packet    packet    = (Packet)data;
            NetSocket socketCtx = packet.socketCtx;
            Server    server    = GetServer();

            if (CheckingPacketVaild(packet) == 0)
            {
                return;
            }

            List <Packet> sendList = socketCtx.sendList;

            if (sendList.Count == 0)
            {
                server.IocpPostSend(packet);
            }
            else
            {
                sendList.Add(packet);
            }
        }