コード例 #1
0
        static public NFrame.NFGUID PBToNF(NFMsg.Ident xID)
        {
            NFrame.NFGUID xIdent = new NFrame.NFGUID();
            xIdent.nHead64 = xID.svrid;
            xIdent.nData64 = xID.index;

            return xIdent;
        }
コード例 #2
0
        public static NFCoreEx.NFIDENTID PBToNF(NFMsg.Ident xID)
        {
            NFCoreEx.NFIDENTID xIdent = new NFCoreEx.NFIDENTID();
            xIdent.nHead64 = xID.svrid;
            xIdent.nData64 = xID.index;

            return xIdent;
        }
コード例 #3
0
ファイル: NFNetModule.cs プロジェクト: ketoo/NFrame
        public int SendMsgPB(int nMsgID, int nSockIndex, NFMsg.MsgBase xData)
        {
            MemoryStream body = new MemoryStream();
            Serializer.Serialize<NFMsg.MsgBase>(body, xData);

            SendMsg(nMsgID, nSockIndex, body.ToString());

            return 0;
        }
コード例 #4
0
        public bool DoDelegation(NFMsg.EGameMsgID eMsg, MsgHead head, MemoryStream stream)
        {
            if(mhtMsgDelegation.ContainsKey(eMsg))
            {
                MsgDelegation myDelegationHandler = (MsgDelegation)mhtMsgDelegation[eMsg];
                myDelegationHandler(head, stream);

                return true;
            }

            return false;
        }
コード例 #5
0
        private void ADD_ROW(NFGUID self, string strRecordName, NFMsg.RecordAddRowStruct xAddStruct)
        {
            NFIObject go = NFCKernelModule.Instance.GetObject(self);
            NFIRecordManager xRecordManager = go.GetRecordManager();


            Hashtable recordVecDesc = new Hashtable();
            Hashtable recordVecData = new Hashtable();

            for (int k = 0; k < xAddStruct.record_int_list.Count; ++k)
            {
                NFMsg.RecordInt addIntStruct = (NFMsg.RecordInt)xAddStruct.record_int_list[k];

                if (addIntStruct.col >= 0)
                {
                    recordVecDesc[addIntStruct.col] = NFIDataList.VARIANT_TYPE.VTYPE_INT;
                    recordVecData[addIntStruct.col] = addIntStruct.data;
                }
            }

            for (int k = 0; k < xAddStruct.record_float_list.Count; ++k)
            {
                NFMsg.RecordFloat addFloatStruct = (NFMsg.RecordFloat)xAddStruct.record_float_list[k];

                if (addFloatStruct.col >= 0)
                {
                    recordVecDesc[addFloatStruct.col] = NFIDataList.VARIANT_TYPE.VTYPE_FLOAT;
                    recordVecData[addFloatStruct.col] = addFloatStruct.data;

                }
            }

            for (int k = 0; k < xAddStruct.record_string_list.Count; ++k)
            {
                NFMsg.RecordString addStringStruct = (NFMsg.RecordString)xAddStruct.record_string_list[k];

                if (addStringStruct.col >= 0)
                {
                    recordVecDesc[addStringStruct.col] = NFIDataList.VARIANT_TYPE.VTYPE_STRING;
                    recordVecData[addStringStruct.col] = System.Text.Encoding.Default.GetString(addStringStruct.data);

                }
            }

            for (int k = 0; k < xAddStruct.record_object_list.Count; ++k)
            {
                NFMsg.RecordObject addObjectStruct = (NFMsg.RecordObject)xAddStruct.record_object_list[k];

                if (addObjectStruct.col >= 0)
                {
                    recordVecDesc[addObjectStruct.col] = NFIDataList.VARIANT_TYPE.VTYPE_OBJECT;
                    recordVecData[addObjectStruct.col] = PBToNF(addObjectStruct.data);

                }
            }

            NFIDataList varListDesc = new NFCDataList();
            NFIDataList varListData = new NFCDataList();
            for (int m = 0; m < recordVecDesc.Count; m++)
            {
                if (recordVecDesc.ContainsKey(m) && recordVecData.ContainsKey(m))
                {
                    NFIDataList.VARIANT_TYPE nType = (NFIDataList.VARIANT_TYPE)recordVecDesc[m];
                    switch (nType)
                    {
                        case NFIDataList.VARIANT_TYPE.VTYPE_INT:
                            {
                                varListDesc.AddInt(0);
                                varListData.AddInt((Int64)recordVecData[m]);
                            }

                            break;
                        case NFIDataList.VARIANT_TYPE.VTYPE_FLOAT:
                            {
                                varListDesc.AddFloat(0.0f);
                                varListData.AddFloat((float)recordVecData[m]);
                            }
                            break;
                        case NFIDataList.VARIANT_TYPE.VTYPE_STRING:
                            {
                                varListDesc.AddString("");
                                varListData.AddString((string)recordVecData[m]);
                            }
                            break;
                        case NFIDataList.VARIANT_TYPE.VTYPE_OBJECT:
                            {
                                varListDesc.AddObject(new NFGUID());
                                varListData.AddObject((NFGUID)recordVecData[m]);
                            }
                            break;
                        default:
                            break;

                    }
                }
                else
                {
                    //报错
                    //Debug.LogException(i);
                }
            }

            NFIRecord xRecord = xRecordManager.GetRecord(strRecordName);
            if (null == xRecord)
            {
                xRecord = xRecordManager.AddRecord(strRecordName, 512, varListDesc);
            }

            xRecord.AddRow(xAddStruct.row, varListData);
        }
コード例 #6
0
    public void SendMsg(NFCoreEx.NFIDENTID xID, NFMsg.EGameMsgID unMsgID, MemoryStream stream)
    {
        if (NFStart.Instance.bDebugMode)
        {
            return;
        }

        NFMsg.MsgBase xData = new NFMsg.MsgBase();
        xData.player_id = NFToPB(xID);
        xData.msg_data = stream.ToArray();

        MemoryStream body = new MemoryStream();
        Serializer.Serialize<NFMsg.MsgBase>(body, xData);

        MsgHead head = new MsgHead();
        head.unMsgID = (UInt16)unMsgID;
        head.unDataLen = (UInt32)body.Length + (UInt32)ConstDefine.NF_PACKET_HEAD_SIZE;

        byte[] bodyByte = body.ToArray();
        byte[] headByte = StructureTransform.StructureToByteArrayEndian(head);

        byte[] sendBytes = new byte[head.unDataLen];
        headByte.CopyTo(sendBytes, 0);
        bodyByte.CopyTo(sendBytes, headByte.Length);

        xNet.mxClient.SendBytes(sendBytes);

        string strTime = DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second;
        string strData = "S***:" + strTime + " MsgID:" + head.unMsgID + " Len:" + head.unDataLen;
        xNet.mxListener.aMsgList.Add(strData);
    }
コード例 #7
0
 private void EGEC_UNKOWN_ERROR(NFMsg.EGameEventCode eCode)
 {
 }
コード例 #8
0
 private void EGEC_ACCOUNT_SUCCESS(NFMsg.EGameEventCode eCode)
 {
     mNet.mPlayerState = NFNet.PLAYER_STATE.E_HAS_PLAYER_LOGIN;
 }
コード例 #9
0
        public bool DoResultCodeDelegation(NFMsg.EGameEventCode eCode)
        {
            if (mhtEventDelegation.ContainsKey(eCode))
            {
                ResultCodeDelegation myDelegationHandler = (ResultCodeDelegation)mhtEventDelegation[eCode];
                myDelegationHandler(eCode);

                return true;
            }

            return false;
        }
コード例 #10
0
        public bool RegisteredResultCodeDelegation(NFMsg.EGameEventCode eCode, ResultCodeDelegation msgDelegate)
        {
            if (!mhtEventDelegation.ContainsKey(eCode))
            {
                ResultCodeDelegation myDelegationHandler = new ResultCodeDelegation(msgDelegate);
                mhtEventDelegation.Add(eCode, myDelegationHandler);
            }
            else
            {
                ResultCodeDelegation myDelegationHandler = (ResultCodeDelegation)mhtMsgDelegation[eCode];
                myDelegationHandler += new ResultCodeDelegation(msgDelegate);
            }

            return true;
        }
コード例 #11
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public bool RegisteredDelegation(NFMsg.EGameMsgID eMsg, MsgDelegation msgDelegate)
        {
            if(!mhtMsgDelegation.ContainsKey(eMsg))
            {
                MsgDelegation myDelegationHandler = new MsgDelegation(msgDelegate);
                mhtMsgDelegation.Add(eMsg, myDelegationHandler);
            }
            else
            {
                MsgDelegation myDelegationHandler = (MsgDelegation)mhtMsgDelegation[eMsg];
                myDelegationHandler += new MsgDelegation(msgDelegate);
            }

            return true;
        }