Exemplo n.º 1
0
        /// <summary>
        /// 새 패킷 정보를 만들어 지정한 함수 델리게이트를 통해 처리한 뒤 전송한다.
        /// </summary>
        /// <param name="typeStr"></param>
        /// <param name="procfunc"></param>
        //protected void DoProcessSendPacket(string typeStr, Action<object> procfunc, Action<Packet> sendDel = null, Action<Packet> responseDel = null)
        protected void DoProcessSendPacket(string typeStr, Action <object> procfunc, Action <Packet> sendDel = null)
        {
            if (!started)                                               // 시작한 경우에만 실행한다.
            {
                return;
            }

            var typeInfo = LookupMessageType(typeStr);                                  // 타입 정보 가져오기
            var sendObj  = typeInfo.funcMakeSend();                                     // 타입에 맞는 ISend 오브젝트 생성

            //sendObj.responseCallback	= responseDel;				// 응답 받을 델리게이트를 지정했다면 세팅
            sendObj.header.messageType = typeStr;                                                       // 메세지 타입 헤더에 넣기

            procfunc(sendObj);                                                                          // 패킷 처리 함수 실행 (패킷 내용을 채운다)

            var packet = sendObj.packet;

            if (sendDel != null)                                                                                // 미리 지정한 전송 델리게이트가 있으면 그것을 사용
            {
                sendDel(packet);
            }
            else
            {
                m_poolCtrl.CallSend(packet);                                                            // 외부에서 지정한 콜백으로 패킷을 넘긴다
            }
        }