int IfAuthResp.RespAuthenticate(int _nResult,ulong _uId)
 {
     int nLength =TypeMarshaller.GetLength( _nResult)+TypeMarshaller.GetLength( _uId);
     CMessage pMsg = new CMessage((uint)IfAuthRespMethodId.IfAuthRespRespAuthenticateMethodId, nLength);
     if (null == pMsg.m_pBuffers)
     {
         return MacrosAndDef.OUT_OF_MEM;
     }
     int nBufferLen = pMsg.m_pBuffers.Length;
     int nUsed = TypeMarshaller.Marshall(pMsg.m_pBuffers, nBufferLen, 0, nLength);
     nUsed += TypeMarshaller.Marshall(pMsg.m_pBuffers, nBufferLen, nUsed,pMsg.m_uMsgId);
     int nLen = TypeMarshaller.Marshall(pMsg.m_pBuffers, nBufferLen, nUsed, _nResult);
     if (nLen < MacrosAndDef.SUCCESS)
     {
         return nLen;
     }
     nUsed += nLen;
     nLen = TypeMarshaller.Marshall(pMsg.m_pBuffers, nBufferLen, nUsed, _uId);
     if (nLen < MacrosAndDef.SUCCESS)
     {
         return nLen;
     }
     nUsed += nLen;
     if (nUsed != nBufferLen)
     {
         Debug.Log("the nUsed is:"+nUsed);
         TypeMarshaller.Marshall(pMsg.m_pBuffers, nBufferLen, sizeof(uint), nUsed);
     }
     CMessage.sm_pSocket.SendMsg(pMsg);
     return nUsed;
 }
 int IfUserSession.ReqGetUserInfo(uint _uUserId)
 {
     int nLength =TypeMarshaller.GetLength( _uUserId);
     CMessage pMsg = new CMessage((uint)IfUserSessionMethodId.IfUserSessionReqGetUserInfoMethodId, nLength);
     if (null == pMsg.m_pBuffers)
     {
         return MacrosAndDef.OUT_OF_MEM;
     }
     int nBufferLen = pMsg.m_pBuffers.Length;
     int nUsed = TypeMarshaller.Marshall(pMsg.m_pBuffers, nBufferLen, 0, nLength);
     nUsed += TypeMarshaller.Marshall(pMsg.m_pBuffers, nBufferLen, nUsed,pMsg.m_uMsgId);
     int nLen = TypeMarshaller.Marshall(pMsg.m_pBuffers, nBufferLen, nUsed, _uUserId);
     if (nLen < MacrosAndDef.SUCCESS)
     {
         return nLen;
     }
     nUsed += nLen;
     if (nUsed != nBufferLen)
     {
         Debug.Log("the nUsed is:"+nUsed);
         TypeMarshaller.Marshall(pMsg.m_pBuffers, nBufferLen, sizeof(uint), nUsed);
     }
     CMessage.sm_pSocket.SendMsg(pMsg);
     return nUsed;
 }
 int IfLogic.Test(ulong _uParm1,int _n2)
 {
     int nLength =TypeMarshaller.GetLength( _uParm1)+TypeMarshaller.GetLength( _n2);
     CMessage pMsg = new CMessage((uint)IfLogicMethodId.IfLogicTestMethodId, nLength);
     if (null == pMsg.m_pBuffers)
     {
         return MacrosAndDef.OUT_OF_MEM;
     }
     int nBufferLen = pMsg.m_pBuffers.Length;
     int nUsed = TypeMarshaller.Marshall(pMsg.m_pBuffers, nBufferLen, 0, nLength);
     nUsed += TypeMarshaller.Marshall(pMsg.m_pBuffers, nBufferLen, nUsed,pMsg.m_uMsgId);
     int nLen = TypeMarshaller.Marshall(pMsg.m_pBuffers, nBufferLen, nUsed, _uParm1);
     if (nLen < MacrosAndDef.SUCCESS)
     {
         return nLen;
     }
     nUsed += nLen;
     nLen = TypeMarshaller.Marshall(pMsg.m_pBuffers, nBufferLen, nUsed, _n2);
     if (nLen < MacrosAndDef.SUCCESS)
     {
         return nLen;
     }
     nUsed += nLen;
     if (nUsed != nBufferLen)
     {
         Debug.Log("the nUsed is:"+nUsed);
         TypeMarshaller.Marshall(pMsg.m_pBuffers, nBufferLen, sizeof(uint), nUsed);
     }
     CMessage.sm_pSocket.SendMsg(pMsg);
     return nUsed;
 }
 int IfAuthResp.ConfirmDisconneted(CDoid _tMyDoid)
 {
     int nLength =CDoid.GetLength(_tMyDoid);
     CMessage pMsg = new CMessage((uint)IfAuthRespMethodId.IfAuthRespConfirmDisconnetedMethodId, nLength);
     if (null == pMsg.m_pBuffers)
     {
         return MacrosAndDef.OUT_OF_MEM;
     }
     int nBufferLen = pMsg.m_pBuffers.Length;
     int nUsed = TypeMarshaller.Marshall(pMsg.m_pBuffers, nBufferLen, 0, nLength);
     nUsed += TypeMarshaller.Marshall(pMsg.m_pBuffers, nBufferLen, nUsed,pMsg.m_uMsgId);
     int nLen = CDoid.Marshall(pMsg.m_pBuffers, nBufferLen, nUsed, _tMyDoid);
     if (nLen < MacrosAndDef.SUCCESS)
     {
         return nLen;
     }
     nUsed += nLen;
     if (nUsed != nBufferLen)
     {
         Debug.Log("the nUsed is:"+nUsed);
         TypeMarshaller.Marshall(pMsg.m_pBuffers, nBufferLen, sizeof(uint), nUsed);
     }
     CMessage.sm_pSocket.SendMsg(pMsg);
     return nUsed;
 }
Beispiel #5
0
        public override void Reply(CChatMaster chatMaster, CWindow window, CMessage message)
        {
            if (!(bool)window.PermaVariables.GetVariable("AcceptInput")) {
                return;
            }
            if (string.IsNullOrWhiteSpace(message.Message)) {
                return;
            }
            string sSwitch = "";
            string[] sTokens;

            if (!message.Message.Contains(" ")) {
                sSwitch = message.Message;
            } else {
                sTokens = message.Message.Split(' ');
                sSwitch = sTokens[0];
            }

            switch (sSwitch.ToLower()) {
                case "start":
                    Start(chatMaster, window);
                    break;

                case "restart":
                    Restart(chatMaster, window);
                    break;

                case "stop":
                    Close(chatMaster, window);
                    break;

                default:
                    if (!(bool)window.PermaVariables.GetVariable("InGame")) {
                        chatMaster.SendMessageToWindow(window, "Hi, " + window.ChatName + ". I'm not available, but would you like a game of hangman?"
                            + " If so, type 'start' to play!");
                    } else {
                        if (message.Message.Length > 1) {
                            if (sSwitch == new string((char[])window.PermaVariables.GetVariable("CurrentWord"))) {
                                Win(chatMaster, window);
                            } else {
                                chatMaster.SendMessageToWindow(window, "I don't know what \"" + message.Message + "\" means. If you're trying to play the game, "
                                + "please remember you can only try one letter at a time!");
                            }
                        } else {
                            TryLetter(chatMaster, window, sSwitch.ToLower()[0]);
                        }
                    }
                    return;
            }

            base.Reply(chatMaster, window, message);
        }
 public override int HandleMsg(CMessage pMsg)
 {
     pMsg.UnmarshallHeader();
     switch (pMsg.m_uMsgId)
     {
         case (uint)IfLogicRespMethodId.IfLogicRespRespTestMethodId:
             {
                 return RespTest_TInt32(pMsg);
             }
             break;
     }
     return MacrosAndDef.MSG_NOT_HANDLED;
 }
 int RespTest_TInt32(CMessage pMsg)
 {
     int nUsed = MacrosAndDef.MSG_HEADER_LEN;
     int nBufferLen = pMsg.m_pBuffers.Length;
     int nLen = 0;
     int _nRslt;
     nLen = TypeUnmarshaller.Unmarshall(pMsg.m_pBuffers, nBufferLen, nUsed, out _nRslt);
     if (nLen < MacrosAndDef.SUCCESS)
     {
         return MacrosAndDef.OUT_OF_MEM;
     }
     nUsed += nLen;
     return m_pImplementObj.RespTest(_nRslt);
 }
 int ConfirmDisconneted_CDoid(CMessage pMsg)
 {
     int nUsed = MacrosAndDef.MSG_HEADER_LEN;
     int nBufferLen = pMsg.m_pBuffers.Length;
     int nLen = 0;
     CDoid _tMyDoid;
     nLen = CDoid.Unmarshall(pMsg.m_pBuffers, nBufferLen, nUsed, out _tMyDoid);
     if (nLen < MacrosAndDef.SUCCESS)
     {
         return MacrosAndDef.OUT_OF_MEM;
     }
     nUsed += nLen;
     return m_pImplementObj.ConfirmDisconneted(_tMyDoid);
 }
 public override int HandleMsg(CMessage pMsg)
 {
     pMsg.UnmarshallHeader();
     switch (pMsg.m_uMsgId)
     {
         case (uint)IfUsersessionRespMethodId.IfUsersessionRespOnPwdChangedMethodId:
             {
                 return OnPwdChanged_TInt32(pMsg);
             }
             break;
         case (uint)IfUsersessionRespMethodId.IfUsersessionRespRespGetMyInfoMethodId:
             {
                 return RespGetMyInfo_TUInt32_TChar_pt_TChar_pt_TUInt32_TUInt32(pMsg);
             }
             break;
         case (uint)IfUsersessionRespMethodId.IfUsersessionRespRespGetUserInfoMethodId:
             {
                 return RespGetUserInfo_TUInt32_TChar_pt_TChar_pt_TUInt32_TUInt32(pMsg);
             }
             break;
         case (uint)IfUsersessionRespMethodId.IfUsersessionRespRespGetDepartInfoMethodId:
             {
                 return RespGetDepartInfo_TUInt32_TChar_pt_TUInt32(pMsg);
             }
             break;
         case (uint)IfUsersessionRespMethodId.IfUsersessionRespSendJobListMethodId:
             {
                 return SendJobList_list_tpl_begin_TJobInfos_tpl_end__ref_list_tpl_begin_TJobInfos_tpl_end__ref(pMsg);
             }
             break;
         case (uint)IfUsersessionRespMethodId.IfUsersessionRespSendActiveWorkMethodId:
             {
                 return SendActiveWork_TJobInfos_TUInt32_const_TChar_pt(pMsg);
             }
             break;
         case (uint)IfUsersessionRespMethodId.IfUsersessionRespRespMenuListMethodId:
             {
                 return RespMenuList_list_tpl_begin_TJobInfos_tpl_end_(pMsg);
             }
             break;
         case (uint)IfUsersessionRespMethodId.IfUsersessionRespRespGetMenuInfoMethodId:
             {
                 return RespGetMenuInfo_TJobInfos_ref(pMsg);
             }
             break;
     }
     return MacrosAndDef.MSG_NOT_HANDLED;
 }
 public override int HandleMsg(CMessage pMsg)
 {
     pMsg.UnmarshallHeader();
     switch (pMsg.m_uMsgId)
     {
         case (uint)IfAuthRespMethodId.IfAuthRespRespAuthenticateMethodId:
             {
                 return RespAuthenticate_TInt32_TUInt64(pMsg);
             }
             break;
         case (uint)IfAuthRespMethodId.IfAuthRespConfirmDisconnetedMethodId:
             {
                 return ConfirmDisconneted_CDoid(pMsg);
             }
             break;
     }
     return MacrosAndDef.MSG_NOT_HANDLED;
 }
 int RespGetMyInfo_TUInt32_TChar_pt_TChar_pt_TUInt32_TUInt32(CMessage pMsg)
 {
     int nUsed = MacrosAndDef.MSG_HEADER_LEN;
     int nBufferLen = pMsg.m_pBuffers.Length;
     int nLen = 0;
     uint _uUpdateTime;
     nLen = TypeUnmarshaller.Unmarshall(pMsg.m_pBuffers, nBufferLen, nUsed, out _uUpdateTime);
     if (nLen < MacrosAndDef.SUCCESS)
     {
         return MacrosAndDef.OUT_OF_MEM;
     }
     nUsed += nLen;
     char _pszName;
     nLen = TypeUnmarshaller.Unmarshall(pMsg.m_pBuffers, nBufferLen, nUsed, out _pszName);
     if (nLen < MacrosAndDef.SUCCESS)
     {
         return MacrosAndDef.OUT_OF_MEM;
     }
     nUsed += nLen;
     char _pszApartName;
     nLen = TypeUnmarshaller.Unmarshall(pMsg.m_pBuffers, nBufferLen, nUsed, out _pszApartName);
     if (nLen < MacrosAndDef.SUCCESS)
     {
         return MacrosAndDef.OUT_OF_MEM;
     }
     nUsed += nLen;
     uint _uMyId;
     nLen = TypeUnmarshaller.Unmarshall(pMsg.m_pBuffers, nBufferLen, nUsed, out _uMyId);
     if (nLen < MacrosAndDef.SUCCESS)
     {
         return MacrosAndDef.OUT_OF_MEM;
     }
     nUsed += nLen;
     uint _uApartId;
     nLen = TypeUnmarshaller.Unmarshall(pMsg.m_pBuffers, nBufferLen, nUsed, out _uApartId);
     if (nLen < MacrosAndDef.SUCCESS)
     {
         return MacrosAndDef.OUT_OF_MEM;
     }
     nUsed += nLen;
     return m_pImplementObj.RespGetMyInfo(_uUpdateTime,_pszName,_pszApartName,_uMyId,_uApartId);
 }
 int RespAuthenticate_TInt32_TUInt64(CMessage pMsg)
 {
     int nUsed = MacrosAndDef.MSG_HEADER_LEN;
     int nBufferLen = pMsg.m_pBuffers.Length;
     int nLen = 0;
     int _nResult;
     nLen = TypeUnmarshaller.Unmarshall(pMsg.m_pBuffers, nBufferLen, nUsed, out _nResult);
     if (nLen < MacrosAndDef.SUCCESS)
     {
         return MacrosAndDef.OUT_OF_MEM;
     }
     nUsed += nLen;
     ulong _uId;
     nLen = TypeUnmarshaller.Unmarshall(pMsg.m_pBuffers, nBufferLen, nUsed, out _uId);
     if (nLen < MacrosAndDef.SUCCESS)
     {
         return MacrosAndDef.OUT_OF_MEM;
     }
     nUsed += nLen;
     return m_pImplementObj.RespAuthenticate(_nResult,_uId);
 }
 int IfAuthService.Authenticate(uint _uDyncNr,char _pszName,char _pszPwd)
 {
     int nLength =TypeMarshaller.GetLength( _uDyncNr)+TypeMarshaller.GetLength( _pszName)+TypeMarshaller.GetLength( _pszPwd);
     CMessage pMsg = new CMessage((uint)IfAuthServiceMethodId.IfAuthServiceAuthenticateMethodId, nLength);
     if (null == pMsg.m_pBuffers)
     {
         return MacrosAndDef.OUT_OF_MEM;
     }
     int nBufferLen = pMsg.m_pBuffers.Length;
     int nUsed = TypeMarshaller.Marshall(pMsg.m_pBuffers, nBufferLen, 0, nLength);
     nUsed += TypeMarshaller.Marshall(pMsg.m_pBuffers, nBufferLen, nUsed,pMsg.m_uMsgId);
     int nLen = TypeMarshaller.Marshall(pMsg.m_pBuffers, nBufferLen, nUsed, _uDyncNr);
     if (nLen < MacrosAndDef.SUCCESS)
     {
         return nLen;
     }
     nUsed += nLen;
     nLen = TypeMarshaller.Marshall(pMsg.m_pBuffers, nBufferLen, nUsed, _pszName);
     if (nLen < MacrosAndDef.SUCCESS)
     {
         return nLen;
     }
     nUsed += nLen;
     nLen = TypeMarshaller.Marshall(pMsg.m_pBuffers, nBufferLen, nUsed, _pszPwd);
     if (nLen < MacrosAndDef.SUCCESS)
     {
         return nLen;
     }
     nUsed += nLen;
     if (nUsed != nBufferLen)
     {
         Debug.Log("the nUsed is:"+nUsed);
         TypeMarshaller.Marshall(pMsg.m_pBuffers, nBufferLen, sizeof(uint), nUsed);
     }
     CMessage.sm_pSocket.SendMsg(pMsg);
     return nUsed;
 }
Beispiel #14
0
        public string GetById(string id, ref CMessage cMessage, ref DialogueJoueur dialogueJoueur)
        {
            foreach (CMessage message in this.ListeMessage)
            {
                if (message.Id == id)
                {
                    cMessage = message;
                    return("CMessage");
                }
            }
            foreach (DialogueJoueur dial in this.ListeDialogueJoueurs)
            {
                if (dial.Id == id)
                {
                    dialogueJoueur = dial;
                    return("DialogueJoueur");
                }
            }
            foreach (Jour j in this.ListeJours)
            {
                if (id == "fin")
                {
                    console.text = "Fin du jeu";
                    GameObject.Find("UI_Bouton_Send").GetComponent <Button>().enabled = false;
                }
                if (j.Id == id)
                {
                    return(GetById(j.getBranchID(points), ref cMessage, ref dialogueJoueur));
                }
            }

            /*if (nbGetById < 2)
             * {
             *
             *  string[] tmpId2tab = id.Split('-');
             *  string tmpId2 = id;
             *  if (tmpId2tab.Length == 2)
             *  {
             *      tmpId2 = tmpId2tab[0] + (int.Parse(tmpId2tab[1]) + 1).ToString();
             *      tmpId2 = GetById(tmpId2, ref cMessage, ref dialogueJoueur);
             *  }
             *  if (tmpId2 != "")
             *  {
             *      nbGetById = 0;
             *      return tmpId2;
             *  }
             *  else
             *  {
             *      string tmpId = id.Substring(0, 2);
             *      tmpId = id[0] + (int.Parse(id[1].ToString()) + 1).ToString();
             *      tmpId = GetById(tmpId, ref cMessage, ref dialogueJoueur);
             *      if (tmpId != "")
             *      {
             *          nbGetById = 0;
             *          return tmpId;
             *      }
             *      nbGetById++;
             *  }
             * }*/
            return("");
        }
Beispiel #15
0
 virtual public int  HandleMsg(CMessage pMsg)
 {
     return MacrosAndDef.MSG_NOT_HANDLED; 
 }
Beispiel #16
0
        // 더이상사용안함
        //public void Send(ZNet.CPacket pk)
        //{
        //    m_client.DoSend(pk);
        //}

        public override bool Send(RemoteID remote, CMessage msg, CPackOption op)
        {
            PreparePacket(remote, RemoteID.Remote_Client, msg, op);
            m_client.DoSend(CPacket.create(msg));
            return(true);
        }
Beispiel #17
0
 private static void msg_SC_GIFT_SIGN_NTF(int iMsgID, ref CMessage msg)
 {
     CliProto.SC_GIFT_SIGN_NTF netMsg = (CliProto.SC_GIFT_SIGN_NTF)msg;
     EverydayAwardWnd.Instance.UpdateSignList(netMsg);
 }
Beispiel #18
0
 public override int HandleMsg(CMessage pMsg)
 {
     pMsg.UnmarshallHeader();
     switch (pMsg.m_uMsgId)
     {
         case IfTestMethodId.IfTestTestMethondId:
             {
                 return IfTestTest_int(pMsg);
             }
             break;
     }
     return MacrosAndDef.MSG_NOT_HANDLED;
 }
Beispiel #19
0
 internal void Write(CMessage obj)
 {
     Write(obj._buffer);
 }
 int RespMenuList_list_tpl_begin_TJobInfos_tpl_end_(CMessage pMsg)
 {
     int nUsed = MacrosAndDef.MSG_HEADER_LEN;
     int nBufferLen = pMsg.m_pBuffers.Length;
     int nLen = 0;
     list<TJobInfos> _tList;
     nLen = list<TJobInfos>.Unmarshall(pMsg.m_pBuffers, nBufferLen, nUsed, out _tList);
     if (nLen < MacrosAndDef.SUCCESS)
     {
         return MacrosAndDef.OUT_OF_MEM;
     }
     nUsed += nLen;
     return m_pImplementObj.RespMenuList(_tList);
 }
Beispiel #21
0
 /// <summary>
 /// 接收数据
 /// </summary>
 /// <param name="message">消息</param>
 public override void OnReceive(CMessage message)
 {
     base.OnReceive(message);
     SendToListener(message);
 }
Beispiel #22
0
    private static void msg_SCID_VIP_RMBINFO_NTF(int iMsgID, ref CMessage msg)
    {
        CliProto.SC_VIP_RMBINFO_NTF netMsg = (CliProto.SC_VIP_RMBINFO_NTF)msg;

        sdMallManager.Instance.UpdateRMBInfo(netMsg.m_RMBCount, netMsg.m_RMBSum);
    }
Beispiel #23
0
 public void SendToClient(RemoteID remote, IRemoteClient client, CMessage msg, CPackOption op)
 {
     PreparePacket(remote, RemoteID.Remote_Server, msg, op);
     client.SendToRemote(CPacket.create(msg));
 }
Beispiel #24
0
        public override bool WriteVar(CVar Var, String Value, AutoResetEvent objectNotify)
        {
            //写变量
            int RawValue = 0;

            if (Var.Table)
            {
                //查表
                bool ValidValue = false;
                for (int TableIndex = 0; TableIndex < Var.Tables.Count; TableIndex++)
                {
                    CTable table = Var.Tables[TableIndex];
                    if (table.Value.ToString() == (Value.ToString()))
                    {
                        RawValue   = table.Index;
                        ValidValue = true;
                        break;
                    }
                }

                if (!ValidValue)
                {
                    return(false);
                }
            }
            else
            {
                //根据数据类型分别处理
                switch (Var.DataType)
                {
                case 1:
                    RawValue = Convert.ToInt32(Convert.ToDouble(Value.ToString()) / Var.Multiple);
                    break;

                case 5:
                    double DoubleValue = Convert.ToDouble(Value.ToString());

                    RawValue = Convert.ToInt32(DoubleValue / Var.Multiple);

                    if (Var.Memo == ("最高位为1扩大100倍,为0扩大10倍"))
                    {
                        if (DoubleValue < 10)
                        {
                            RawValue = Convert.ToInt32(DoubleValue * 100 + 32768);
                        }
                        else
                        {
                            RawValue = Convert.ToInt32(DoubleValue * 10);
                        }
                    }
                    break;

                case 9:
                    RawValue = (Value.ToString() == ("否") || Value.ToString().ToLower() == ("false")) ? 0 : 1;
                    break;

                //case 10 : break;
                default: return(false);
                }
            }

            CMessage message      = (CMessage)Var.OwnerMessage;
            CMessage WriteMessage = message.Clone();

            WriteMessage.Schema[0] = (byte)this.Address;
            WriteMessage.Schema[1] = 0x06;

            int VarAddress = CommonUtility.ByteToInt(WriteMessage.Schema[2]) * 256 + CommonUtility.ByteToInt(WriteMessage.Schema[3]) + Var.ByteOffset / 2;

            WriteMessage.Schema[2] = (byte)((VarAddress & 0xFF00) >> 8);
            WriteMessage.Schema[3] = (byte)(VarAddress & 0x00FF);

            if (Var.BitOffset < 0)
            {
                if (Var.Length == 16)
                {
                    WriteMessage.Schema[4] = (byte)((RawValue & 0xFF00) >> 8);
                    WriteMessage.Schema[5] = (byte)(RawValue & 0x00FF);
                }
            }
            else
            {
                int TotalWord = message.Response[Var.ByteOffset + 3] * 256 + message.Response[Var.ByteOffset + 4];
                int W         = 0xFFFF;
                W         = W << (16 - Var.Length - Var.BitOffset);
                W         = W & 0x0000FFFF;
                W         = W >> (16 - Var.Length);
                W         = W & 0x0000FFFF;
                W         = W << Var.BitOffset;
                W         = W & 0x0000FFFF;
                W         = ~W;
                W         = W & 0x0000FFFF;
                TotalWord = TotalWord & W;
                RawValue  = RawValue << Var.BitOffset;
                RawValue  = TotalWord | RawValue;
                RawValue  = RawValue & 0x0000FFFF;

                WriteMessage.Schema[4] = (byte)((RawValue & 0xFF00) >> 8);
                WriteMessage.Schema[5] = (byte)(RawValue & 0x00FF);
            }

            if (objectNotify != null)
            {
                return(this.ExchangeMessage(WriteMessage, objectNotify));
            }
            else
            {
                this.AddUpdateMessage(WriteMessage);
                return(true);
            }
        }
Beispiel #25
0
        public void OnRecv(T remoteClient, byte[] buffer, int len)
        {
            IRemoteClient client = (IRemoteClient)remoteClient;

            if (client.GetRemoteID() == RemoteID.Remote_None)
            {
                // Connect스레드가 다를경우 조금 기다려주도록 하자
                for (int i = 0; i < WaitDelayRecvThreadCount; i++)    // 20일경우 100 * 20 즉 2000밀리세컨드 -> 최대 2초까지 기다려준다
                {
                    System.Threading.Thread.Sleep(100);
                    if (client.GetRemoteID() != RemoteID.Remote_None)
                    {
                        break;
                    }
                }

                // 그래도 할당안됬다면?
                if (client.GetRemoteID() == RemoteID.Remote_None)
                {
                    // 이경우는 연결이벤트 처리가 아직안된경우임
                    if (message_handler != null)
                    {
                        message_handler(MsgType.Error, "remoteID 할당이 안되었음.");
                    }
                }
            }

            CRecvedMsg recved_msg = new CRecvedMsg();

            try
            {
                CPackOption packOption = new CPackOption();
                CMessage    MsgBuffer  = new CMessage(buffer, 0, len);
                recved_msg.From(
                    client.GetRemoteID(),
                    MsgBuffer,
                    MsgBuffer.ReadStart(out packOption),
                    packOption
                    );

                // 예외발생 test
                //string a = "aa";
                //int.Parse(a);
            }
            catch (Exception e)
            {
                if (message_handler != null)
                {
                    message_handler(MsgType.Warning, string.Format("{0} OnPackException: {1}",
                                                                   client.Address().ToString(),
                                                                   e.Message));
                }
                client.Disconnect();
                return;
            }

            string msg = OnPacket(recved_msg);

            if (msg != string.Empty)
            {
                if (message_handler != null)
                {
                    message_handler(MsgType.Warning, string.Format("{0} {1}", client.Address().ToString(), msg));
                }
                client.Disconnect();
            }
        }
Beispiel #26
0
 public void SendMsg(CMessage pMsg)
 {
     Debug.Log("SendMsg is called!");
     m_tSendQueue.Enqueue(pMsg);
     StartSend();
 }
 int SendActiveWork_TJobInfos_TUInt32_const_TChar_pt(CMessage pMsg)
 {
     int nUsed = MacrosAndDef.MSG_HEADER_LEN;
     int nBufferLen = pMsg.m_pBuffers.Length;
     int nLen = 0;
     TJobInfos _tJobs;
     nLen = TJobInfos.Unmarshall(pMsg.m_pBuffers, nBufferLen, nUsed, out _tJobs);
     if (nLen < MacrosAndDef.SUCCESS)
     {
         return MacrosAndDef.OUT_OF_MEM;
     }
     nUsed += nLen;
     uint _uRcdId;
     nLen = TypeUnmarshaller.Unmarshall(pMsg.m_pBuffers, nBufferLen, nUsed, out _uRcdId);
     if (nLen < MacrosAndDef.SUCCESS)
     {
         return MacrosAndDef.OUT_OF_MEM;
     }
     nUsed += nLen;
     char _pszTitle;
     nLen = TypeUnmarshaller.Unmarshall(pMsg.m_pBuffers, nBufferLen, nUsed, out _pszTitle);
     if (nLen < MacrosAndDef.SUCCESS)
     {
         return MacrosAndDef.OUT_OF_MEM;
     }
     nUsed += nLen;
     return m_pImplementObj.SendActiveWork(_tJobs,_uRcdId,_pszTitle);
 }
Beispiel #28
0
 /// <summary>
 /// 登录数据回调
 /// </summary>
 /// <param name="message">消息</param>
 private void LoginDataCallBack(CMessage message)
 {
     OnLoginDataCallBack(message);
 }
Beispiel #29
0
 public void Add(CMessage m)
 {
     Messages.Add(m);
 }
Beispiel #30
0
 //宠物升级..
 private static void msg_SCID_PET_LEVEL_NTF(int iMsgID, ref CMessage msg)
 {
     CliProto.SC_PET_LEVEL_NTF refMsg = (CliProto.SC_PET_LEVEL_NTF)msg;
     sdNewPetMgr.Instance.UpdatePetLevel((UInt64)refMsg.m_DBID, refMsg.m_Level);
 }
Beispiel #31
0
 private static void msg_SC_GIFT_EP_INFO_ACK(int iMsgId, ref CMessage msg)
 {
     CliProto.SC_GIFT_EP_INFO_ACK netMsg = (CliProto.SC_GIFT_EP_INFO_ACK)msg;
     EverydayFoodsWnd.Instance.UpdateEverydayFoods(netMsg);
 }
Beispiel #32
0
        /// <summary>
        /// 接收消息方法
        /// </summary>
        /// <param name="message">消息</param>
        public override void OnReceive(CMessage message)
        {
            if (message.m_functionID != FUNCTIONID_INDICATOR_GETINDICATORS)
            {
                message.m_requestID = m_operatorRequestID;
            }
            List <Indicator> indicators = new List <Indicator>();

            GetIndicators(indicators, message.m_body, message.m_bodyLength);
            int indicatorsSize = indicators.Count;

            switch (message.m_functionID)
            {
            case FUNCTIONID_INDICATOR_GETINDICATORS:
            {
                m_indicators = indicators;
                m_loaded     = true;
                break;
            }

            case FUNCTIONID_INDICATOR_ADDINDICATORS:
            {
                bool add = false;
                for (int i = 0; i < indicatorsSize; i++)
                {
                    Indicator indicator = null;
                    if (!GetIndicatorByID(indicators[i].m_indicatorID, ref indicator))
                    {
                        m_indicators.Add(indicators[i]);
                        add = true;
                    }
                }
                if (!add)
                {
                    return;
                }
                break;
            }

            case FUNCTIONID_INDICATOR_DELETEINDICATORS:
            {
                for (int i = 0; i < indicatorsSize; i++)
                {
                    Indicator indicator = null;
                    if (GetIndicatorByID(indicators[i].m_indicatorID, ref indicator))
                    {
                        m_indicators.Remove(indicator);
                    }
                }
                break;
            }

            case FUNCTIONID_INDICATOR_UPDATEINDICATORS:
            {
                for (int i = 0; i < indicatorsSize; i++)
                {
                    Indicator updateIndicator   = indicators[i];
                    int       curIndicatorsSize = m_indicators.Count;
                    for (int j = 0; j < curIndicatorsSize; j++)
                    {
                        Indicator indicator = m_indicators[j];
                        if (indicator.m_indicatorID == updateIndicator.m_indicatorID)
                        {
                            m_indicators[j] = updateIndicator;
                            break;
                        }
                    }
                }
                break;
            }
            }
            base.OnReceive(message);
        }
 int RespGetMenuInfo_TJobInfos_ref(CMessage pMsg)
 {
     int nUsed = MacrosAndDef.MSG_HEADER_LEN;
     int nBufferLen = pMsg.m_pBuffers.Length;
     int nLen = 0;
     TJobInfos _tJobInfo;
     nLen = TJobInfos.Unmarshall(pMsg.m_pBuffers, nBufferLen, nUsed, out _tJobInfo);
     if (nLen < MacrosAndDef.SUCCESS)
     {
         return MacrosAndDef.OUT_OF_MEM;
     }
     nUsed += nLen;
     return m_pImplementObj.RespGetMenuInfo(_tJobInfo);
 }
Beispiel #34
0
        protected override bool RecvInternalMessage(RemoteID remote, PackInternal pkID, CMessage msgData, CPackOption op)
        {
            switch (pkID)
            {
            case PackInternal.ePID_CS_Test:
            {
                int    aa;
                string ss;
                Marshaler.Read(msgData, out aa);
                Marshaler.Read(msgData, out ss);
                if (message_handler != null)
                {
                    message_handler(MsgType.Debug, op.m_pack_mode + ", InterPkt: " + pkID + ", " + aa + ", " + ss);
                }
            }
            break;

            default:
            {
                // test
            }
                return(false);
            }
            return(true);
        }
Beispiel #35
0
        /// <summary>
        /// 调用控件线程方法
        /// </summary>
        /// <param name="args">参数</param>
        public void OnInvoke(object args)
        {
            CMessage message = (CMessage)args;

            if (message.m_serviceID == m_quoteService.ServiceID)
            {
                LatestDataInfo            dataInfo = new LatestDataInfo();
                List <SecurityLatestData> datas    = new List <SecurityLatestData>();
                QuoteService.GetLatestDatas(ref dataInfo, datas, message.m_body, message.m_bodyLength);
                int datasSize = datas.Count;
                for (int i = 0; i < datasSize; i++)
                {
                    m_latestDatas[datas[i].m_securityCode] = datas[i];
                }
                datas.Clear();
            }
            else
            {
                List <UserSecurityCategory> categories = new List <UserSecurityCategory>();
                UserSecurityService.GetCategories(categories, message.m_body, message.m_bodyLength);
                UserSecurityCategory category = categories[0];
                switch (message.m_functionID)
                {
                case UserSecurityService.FUNCTIONID_USERSECURITY_ADDCATEGORIES:
                    AddCategoriesToCategoryGrid(categories);
                    break;

                case UserSecurityService.FUNCTIONID_USERSECURITY_DELETECATEGORIES:
                    RemoveCategoriesFromCategoryGrid(categories);
                    break;

                case UserSecurityService.FUNCTIONID_USERSECURITY_UPDATECATEGORIES:
                    UpdateCategoriesToCategoryGrid(categories);
                    break;

                case UserSecurityService.FUNCTIONID_USERSECURITY_ADDSECURITIES:
                case UserSecurityService.FUNCTIONID_USERSECURITY_DELETESECURITIES:
                {
                    String         categoryID       = "";
                    List <GridRow> selectedRows     = m_gridCategory.SelectedRows;
                    int            selectedRowsSize = selectedRows.Count;
                    if (selectedRowsSize > 0)
                    {
                        categoryID = selectedRows[0].GetCell(0).Text;
                    }
                    if (categoryID != null && categoryID == category.m_categoryID)
                    {
                        List <Security> securities = new List <Security>();
                        m_securityService.GetSecuritiesByCodes(category.m_codes, securities);
                        if (message.m_functionID == UserSecurityService.FUNCTIONID_USERSECURITY_ADDSECURITIES)
                        {
                            AddSecuritiesToSecuritiesGrid(securities);
                        }
                        else if (message.m_functionID == UserSecurityService.FUNCTIONID_USERSECURITY_DELETESECURITIES)
                        {
                            RemoveSecuritiesFromSecuritiesGrid(securities);
                        }
                    }
                    break;
                }
                }
            }
            m_window.Invalidate();
        }
Beispiel #36
0
        public override int Parse(byte[] _Data, int Count, CMessage message, byte[] SendData)
        {
            //报文解析
            if (Count > 256)
            {
                return(1);   //报文太长
            }
            //首先查看地址和功能码是否正确
            if (_Data[0] != (byte)this.Address || _Data[1] != message.Schema[1])
            {
                if (message.Schema[1] == 0x14 && _Data[1] == (byte)0x94 && _Data[2] == 0x05)
                {
                    //录波文件读取时需要等待并重试
                    return(-1);
                }
                else
                {
                    return(2);   //地址或者功能码错误
                }
            }

            //然后查看CRC是否正确
            int  crc      = CRC16.calcCrc16(_Data, 0, Count - 2);
            byte crclow   = (byte)(crc & 0x00FF);
            byte crchight = (byte)((crc & 0xFF00) >> 8);

            if (_Data[Count - 2] != crclow || _Data[Count - 1] != crchight)
            {
                return(3);   //CRC错误
            }
            for (int i = 0; i < Count; i++)
            {
                message.Response[i] = CommonUtility.ByteToInt(_Data[i]);
            }

            if (message.Response[1] != 3 && message.Response[1] != 4)
            {
                return(0);   //非03或者04功能码,不需要继续处理
            }
            int StartOffSet = 3;

            for (int i = 0; i < message.Vars.Count; i++)
            {
                CVar var = message.Vars[i];

                int RawValue = 0;
                if (var.BitOffset < 0)
                {
                    if (var.Length == 16)
                    {
                        RawValue = message.Response[var.ByteOffset + StartOffSet] * 256 + message.Response[var.ByteOffset + 1 + StartOffSet];
                    }
                    else if (var.Length == 32)
                    {
                        if (this.DoubleWordMode == "LH")
                        {
                            RawValue = message.Response[var.ByteOffset + StartOffSet] * 256 + message.Response[var.ByteOffset + 1 + StartOffSet] + 65536 * (message.Response[var.ByteOffset + 2 + StartOffSet] * 256 + message.Response[var.ByteOffset + 3 + StartOffSet]);
                        }
                        else
                        {
                            RawValue = 65536 * (message.Response[var.ByteOffset + StartOffSet] * 256 + message.Response[var.ByteOffset + 1 + StartOffSet]) + message.Response[var.ByteOffset + 2 + StartOffSet] * 256 + message.Response[var.ByteOffset + 3 + StartOffSet];
                        }
                    }
                }
                else
                {
                    RawValue = message.Response[var.ByteOffset + StartOffSet] * 256 + message.Response[var.ByteOffset + 1 + StartOffSet];
                    RawValue = RawValue << (16 - var.Length - var.BitOffset);
                    RawValue = RawValue & 0x0000FFFF;
                    RawValue = RawValue >> (16 - var.Length);
                }

                double value = RawValue * var.Multiple;
                if (var.Memo == ("最高位为1扩大100倍,为0扩大10倍"))
                {
                    if (RawValue < 32768)
                    {
                        value = RawValue * 0.1;
                    }
                    else
                    {
                        value = (RawValue - 32768) * 0.01;
                    }
                }

                String VarName = var.Name;
                if (message.Type == 2)
                {
                    int MessageAddress = CommonUtility.ByteToInt(SendData[3]);
                    int OriginAddress  = CommonUtility.ByteToInt(this.GetMessage(message.Index).Schema[3]);
                    int IndexV         = (MessageAddress - OriginAddress) / 0x08;
                    if (message.Index == 35)
                    {
                        IndexV = (MessageAddress - OriginAddress) / 0x10;
                    }
                    VarName = VarName + IndexV;
                }

                if (var.Table)
                {
                    //查表
                    Object TableValue = var.SearchTableValue(RawValue);
                    if (TableValue != null)
                    {
                        RTDB.SetVarValue(this.Name, VarName, TableValue);
                    }
                    else
                    {
                        RTDB.SetVarValue(this.Name, VarName, "#Error#");
                    }

                    continue;
                }

                if (var.Desc.IndexOf("年月日") >= 0)
                {
                    byte[] Date = new byte[3];
                    Date[0] = (byte)(RawValue >> 16);
                    Date[1] = (byte)((RawValue << 16) >> 24);
                    Date[2] = (byte)((RawValue << 24) >> 24);

                    String DateStr   = CommonUtility.Bcd2Str(Date);
                    String DateValue = "20" + DateStr.Substring(0, 2) + "-" + DateStr.Substring(2, 2) + "-" + DateStr.Substring(4, 2);
                    RTDB.SetVarValue(this.Name, VarName, DateValue);
                }
                else if (var.Desc.IndexOf("时分秒") >= 0)
                {
                    byte[] Date = new byte[3];
                    Date[0] = (byte)(RawValue >> 16);
                    Date[1] = (byte)((RawValue << 16) >> 24);
                    Date[2] = (byte)((RawValue << 24) >> 24);

                    String DateStr   = CommonUtility.Bcd2Str(Date);
                    String DateValue = DateStr.Substring(0, 2) + ":" + DateStr.Substring(2, 2) + ":" + DateStr.Substring(4, 2);
                    RTDB.SetVarValue(this.Name, VarName, DateValue);
                }
                else if (var.Desc.IndexOf("版本") >= 0)
                {
                    byte[] Version = new byte[4];
                    Version[0] = (byte)(RawValue >> 24);
                    Version[1] = (byte)(RawValue >> 16);
                    Version[2] = (byte)((RawValue << 16) >> 24);
                    Version[3] = (byte)((RawValue << 24) >> 24);

                    String VersionStr   = CommonUtility.Bcd2Str(Version);
                    String VersionValue = VersionStr.Substring(0, 2) + "." + VersionStr.Substring(2, 2) + "." + VersionStr.Substring(4, 2) + "." + VersionStr.Substring(6, 2);
                    RTDB.SetVarValue(this.Name, VarName, VersionValue);
                }
                else if (var.Memo == ("有符号整型"))
                {
                    short ShortRawValue = (short)(CommonUtility.ByteToShort(_Data[var.ByteOffset + StartOffSet]) * 256 + CommonUtility.ByteToShort(_Data[var.ByteOffset + 1 + StartOffSet]));
                    value = ShortRawValue * var.Multiple;
                    RTDB.SetVarValue(this.Name, VarName, value);
                }
                else if (var.Name == ("PScale"))
                {
                    if (RawValue == 0)
                    {
                        this.GetVar("P").Unit = "kW";
                    }
                    else
                    {
                        this.GetVar("P").Unit = "W";
                    }
                    RTDB.SetVarValue(this.Name, VarName, value);
                }
                else if (var.Name == ("QScale"))
                {
                    if (RawValue == 0)
                    {
                        this.GetVar("Q").Unit = "kVar";
                    }
                    else
                    {
                        this.GetVar("Q").Unit = "Var";
                    }
                    RTDB.SetVarValue(this.Name, VarName, value);
                }
                else if (var.DataType == 9)
                {
                    String BoolStr = RawValue == 0 ? "否" : "是";
                    RTDB.SetVarValue(this.Name, VarName, BoolStr);
                }
                else
                {
                    RTDB.SetVarValue(this.Name, VarName, value);
                }
            }

            return(0);       //成功
        }
Beispiel #37
0
 abstract public int Parse(byte[] Data, int Count, CMessage message, byte[] SendData);
Beispiel #38
0
        /// <summary>
        /// 发送POST数据
        /// </summary>
        /// <param name="message">消息</param>
        /// <returns>返回消息</returns>
        public int SendRequest(CMessage message)
        {
            Binary bw = new Binary();

            byte[] body          = message.m_body;
            int    bodyLength    = message.m_bodyLength;
            int    uncBodyLength = bodyLength;

            if (message.m_compressType == COMPRESSTYPE_GZIP)
            {
                using (MemoryStream cms = new MemoryStream())
                {
                    using (GZipStream gzip = new GZipStream(cms, CompressionMode.Compress))
                    {
                        gzip.Write(body, 0, body.Length);
                    }
                    body       = cms.ToArray();
                    bodyLength = body.Length;
                }
            }
            int len = sizeof(int) * 4 + bodyLength + sizeof(short) * 3 + sizeof(byte) * 2;

            bw.WriteInt(len);
            bw.WriteShort((short)message.m_groupID);
            bw.WriteShort((short)message.m_serviceID);
            bw.WriteShort((short)message.m_functionID);
            bw.WriteInt(message.m_sessionID);
            bw.WriteInt(message.m_requestID);
            bw.WriteByte((byte)message.m_state);
            bw.WriteByte((byte)message.m_compressType);
            bw.WriteInt(uncBodyLength);
            bw.WriteBytes(body);
            byte[]         bytes  = bw.GetBytes();
            int            length = bytes.Length;
            HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create(m_url);

            webReq.Method        = "POST";
            webReq.ContentType   = "application/x-www-form-urlencoded";
            webReq.ContentLength = bytes.Length;
            if (bytes != null)
            {
                Stream writer = webReq.GetRequestStream();
                writer.Write(bytes, 0, bytes.Length);
                writer.Close();
            }
            HttpWebResponse response      = (HttpWebResponse)webReq.GetResponse();
            Stream          reader        = response.GetResponseStream();
            long            contentLength = response.ContentLength;

            byte[] dataArray = new byte[contentLength];
            for (int i = 0; i < contentLength; i++)
            {
                dataArray[i] = (byte)reader.ReadByte();
            }
            response.Close();
            reader.Dispose();
            bw.Close();
            int ret = dataArray.Length;

            UpFlow += ret;
            IntPtr ptr = Marshal.AllocHGlobal(sizeof(byte) * ret);

            for (int i = 0; i < ret; i++)
            {
                IntPtr iptr = (IntPtr)((int)ptr + i);
                Marshal.WriteByte(iptr, dataArray[i]);
            }
            BaseService.CallBack(message.m_socketID, 0, ptr, ret);
            Marshal.FreeHGlobal(ptr);
            return(ret);
        }
Beispiel #39
0
 abstract public byte[] GetSchema(CMessage message);
Beispiel #40
0
 private static void msg_SCID_SHOP_GET_GOODSLIST_ACK(int iMsgID, ref CMessage msg)
 {
     CliProto.SC_SHOP_GET_GOODSLIST_ACK refMsg = (CliProto.SC_SHOP_GET_GOODSLIST_ACK)msg;
     sdMallManager.Instance.OnMsgGoodsList(refMsg);
 }
Beispiel #41
0
 abstract public CMessage GetRecordMessage(CMessage message, int Index);
Beispiel #42
0
 private static void msg_SCID_SHOP_BUY_ACTION_POINT_ACK(int iMsgID, ref CMessage msg)
 {
     CliProto.SC_SHOP_BUY_ACTION_POINT_ACK refMsg = (CliProto.SC_SHOP_BUY_ACTION_POINT_ACK)msg;
 }
Beispiel #43
0
        public void ParseDeviceFromXml(string IEDType)
        {
            //读取XML
            try
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\IED\\" + IEDType + ".xml");
                XmlNode root = doc.SelectSingleNode("Device");
                this.Name           = root.Attributes["Name"].Value;
                this.DoubleWordMode = root.Attributes["DoubleWordMode"].Value;
                this.Address        = Convert.ToInt32(root.Attributes["Address"].Value);

                XmlNodeList messageList = root.SelectNodes("Message");
                foreach (XmlNode messageNode in messageList)
                {
                    CMessage message = new CMessage();
                    message.Index = Convert.ToInt32(messageNode.Attributes["Index"].Value);
                    message.Name  = messageNode.Attributes["Name"].Value;
                    message.Type  = Convert.ToInt32(messageNode.Attributes["Type"].Value);
                    message.Desc  = messageNode.Attributes["Desc"].Value;
                    String   schema = messageNode.Attributes["Schema"].Value;
                    String[] Bytes  = schema.Split(' ');
                    message.Schema = new byte[Bytes.Length];
                    for (int i = 0; i < Bytes.Length; i++)
                    {
                        message.Schema[i] = (byte)Convert.ToInt16(Bytes[i], 16);
                    }
                    message.Vars = new List <CVar>();

                    //如果类型是记录则获取其数量
                    if (messageNode.Attributes["Count"] != null)
                    {
                        message.Count = Convert.ToInt32(messageNode.Attributes["Count"].Value);
                    }

                    message.Memo = messageNode.Attributes["Memo"].Value;

                    this.Messages.Add(message);

                    XmlNodeList varList = messageNode.SelectNodes("Var");
                    foreach (XmlNode varNode in varList)
                    {
                        CVar var = new CVar();
                        var.Name       = varNode.Attributes["Name"].Value;
                        var.Desc       = varNode.Attributes["Desc"].Value;
                        var.Length     = Convert.ToInt32(varNode.Attributes["Length"].Value);
                        var.ByteOffset = Convert.ToInt32(varNode.Attributes["ByteOffset"].Value);
                        var.BitOffset  = Convert.ToInt32(varNode.Attributes["BitOffset"].Value);
                        var.Unit       = varNode.Attributes["Unit"].Value;
                        var.DataType   = Convert.ToInt32(varNode.Attributes["DataType"].Value);
                        var.Default    = varNode.Attributes["Default"].Value;
                        var.Multiple   = Convert.ToDouble(varNode.Attributes["Multiple"].Value);
                        var.Table      = Convert.ToBoolean(varNode.Attributes["Table"].Value);
                        var.Memo       = varNode.Attributes["Memo"].Value;

                        if (varNode.Attributes["Min"] != null)
                        {
                            var.MinValue = Convert.ToDouble(varNode.Attributes["Min"].Value);
                            var.MaxValue = Convert.ToDouble(varNode.Attributes["Max"].Value);
                        }

                        if (var.Table)
                        {
                            var.Tables = new List <CTable>();
                        }

                        var.OwnerMessage = message;
                        message.Vars.Add(var);

                        XmlNodeList tableList = varNode.SelectNodes("T");
                        foreach (XmlNode tableNode in tableList)
                        {
                            CTable table = new CTable();
                            table.Index = Convert.ToInt32(tableNode.Attributes["Index"].Value);
                            table.Value = tableNode.Attributes["Value"].Value;

                            var.Tables.Add(table);
                        }
                    }
                }
            }
            catch (Exception e)
            {
            }
        }
Beispiel #44
0
 private static void msg_SC_GIFT_RECEIVE_EP_ACK(int sdItemMsg, ref CMessage msg)
 {
     CliProto.SC_GIFT_RECEIVE_EP_ACK netMsg = (CliProto.SC_GIFT_RECEIVE_EP_ACK)msg;
     EverydayFoodsWnd.Instance.OnReceiveEpAck(netMsg);
 }
Beispiel #45
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Id = Convert.ToInt32(Request["id"]);

            if (!IsPostBack)
            {
                var cUser = new CUser();
                RadComboBoxUserName.DataSource     = cUser.GetAllUserList();
                RadComboBoxUserName.DataTextField  = "Name";
                RadComboBoxUserName.DataValueField = "Value";
                RadComboBoxUserName.DataBind();

                // new
                if (Request["createOrListType"] == "0")
                {
                    foreach (RadToolBarItem item in RadToolBar1.Items)
                    {
                        if (item.Text == "Reply")
                        {
                            item.Visible = false;
                            break;
                        }
                    }
                }
                // view
                else if (Request["createOrListType"] == "1")
                {
                    var cMessage = new CMessage();
                    var message  = cMessage.Get(Id);

                    if (message != null)
                    {
                        string userId = string.Empty;

                        // recieved
                        if (Request["recievedOrSent"] == "0")
                        {
                            foreach (RadToolBarItem item in RadToolBar1.Items)
                            {
                                if (item.Text == "Send")
                                {
                                    item.Visible = false;
                                    break;
                                }
                            }
                            userId = message.CreatedId.ToString();

                            // set read
                            message.IsRead = true;
                            cMessage.Update(message);
                        }
                        // sent
                        else
                        {
                            foreach (RadToolBarItem item in RadToolBar1.Items)
                            {
                                if (item.Text == "Send" || item.Text == "Reply")
                                {
                                    item.Visible = false;
                                }
                            }
                            userId = message.UserId.ToString();
                        }

                        foreach (RadComboBoxItem item in RadComboBoxUserName.Items)
                        {
                            if (item.Value == userId)
                            {
                                item.Selected = true;
                                break;
                            }
                        }

                        RadEditorContent.Content = message.Content;
                        RadTextBoxDate.Text      = CGlobal.GetDateFormat(message.CreatedDate);
                        RadTextBoxIsRead.Text    = message.IsRead.ToString();
                    }

                    RadComboBoxUserName.Enabled = false;
                    RadEditorContent.EditModes  = EditModes.Preview;
                }
                // reply
                else
                {
                    foreach (RadToolBarItem item in RadToolBar1.Items)
                    {
                        if (item.Text == "Reply")
                        {
                            item.Visible = false;
                            break;
                        }
                    }

                    foreach (RadComboBoxItem item in RadComboBoxUserName.Items)
                    {
                        if (item.Value == Id.ToString())
                        {
                            item.Selected = true;
                            break;
                        }
                    }
                    RadComboBoxUserName.Enabled = false;
                }
            }
        }
Beispiel #46
0
 private static void msg_SC_GIFT_LEVEL_NTF(int iMsgID, ref CMessage msg)
 {
     CliProto.SC_GIFT_LEVEL_NTF netMsg = (CliProto.SC_GIFT_LEVEL_NTF)msg;
     LevelAwardWnd.Instance.UpdateLevelList(netMsg);
 }
Beispiel #47
0
 public int SendMsg(CMessage pMsg)
 {
     Debug.Log("SendMsg is called!");
     m_pWorker.SendMsg(pMsg);
     return 0;
 }
Beispiel #48
0
 private static void msg_SC_GIFT_DAY_NTF(int iMsgID, ref CMessage msg)
 {
     CliProto.SC_GIFT_DAY_NTF netMsg = (CliProto.SC_GIFT_DAY_NTF)msg;
     EverydayQuestWnd.Instance.UpdateQuestList(netMsg);
 }
Beispiel #49
0
        void SocketThread()
        {
            // ipv4로 먼저 접속 시도
            string err = SocketConnect(AddressFamily.InterNetwork);

            if (m_client.socket.Connected == false)
            {
                // ipv4로 접속 실패시 ipv6로 즉시 재시도한다 : ios경우 ipv6 only환경에서 작동되야 하므로..
                //  -> 즉시 시도해도 되는 이유는 addressfamily가 다르면 즉각 피드백오므로 문제없다
                string err2 = SocketConnect(AddressFamily.InterNetworkV6);

                if (m_client.socket.Connected == false)
                {
                    if (err != string.Empty && message_handler != null)
                    {
                        message_handler(MsgType.Info, err);
                    }

                    if (err2 != string.Empty && message_handler != null)
                    {
                        message_handler(MsgType.Info, err2);
                    }
                }
            }

            if (m_client.socket.Connected == false)
            {
                this.event_manager.enqueue_network_event(NETWORK_EVENT.connect_fail);
                thr = null;
                return;
            }

            this.event_manager.enqueue_network_event(NETWORK_EVENT.connected);

            // 여기서부터 연결이 끊길때까지 Recv무한루프가 시작된다
            bSocketThread = true;

            byte[] buf;
            int    bufsize;

            while (bSocketThread)
            {
                if (RecvLong(out buf, out bufsize) == false)
                {
                    event_manager.enqueue_network_event(NETWORK_EVENT.disconnected);
                    thr = null;
                    return;
                }

                if (bufsize - m_headsize < 0)
                {
                    if (this.message_handler != null)
                    {
                        this.message_handler(MsgType.Warning, string.Format("pksize error : {0}", bufsize));
                    }

                    event_manager.enqueue_network_event(NETWORK_EVENT.disconnected);
                    thr = null;
                    return;
                }

                bufsize -= ECore.CoreParam.HEADER_SIZE_LEN;

                try
                {
                    CRecvedMsg  recved_msg = new CRecvedMsg();
                    CPackOption packOption = new CPackOption();
                    CMessage    MsgBuffer  = new CMessage(buf, 4, bufsize);
                    recved_msg.From(
                        RemoteID.Remote_Server,
                        MsgBuffer,
                        MsgBuffer.ReadStart(out packOption),
                        packOption
                        );

                    event_manager.enqueue_network_message(recved_msg);
                }
                catch (Exception e)
                {
                    if (this.message_handler != null)
                    {
                        this.message_handler(MsgType.Warning, string.Format("recvMsgException : {0}", e.Message));
                    }

                    event_manager.enqueue_network_event(NETWORK_EVENT.disconnected);
                    thr = null;
                    return;
                }
            }
            thr = null;
        }
Beispiel #50
0
    public static void OnMessage_SC_LEVEL_INFO(int iMsgID, ref CMessage msg)
    {
        CliProto.SC_LEVEL_INFO refMSG = (CliProto.SC_LEVEL_INFO)msg;

        if (refMSG.m_Count > 0)
        {
            for (int i = 0; i < refMSG.m_Count; i++)
            {
                int    levelID   = (int)refMSG.m_Info[i].m_LevelID;
                int    crystal   = (int)refMSG.m_Info[i].m_Crystal;
                ushort usedTimes = refMSG.m_Info[i].m_UsedTimes;

                for (int j = 0; j < levelInfos.Length; j++)
                {
                    if (levelID == levelInfos[j].levelID)
                    {
                        levelInfos[j].crystal   = crystal;
                        levelInfos[j].usedTimes = usedTimes;
                        levelInfos[j].valid     = true;
                        break;
                    }
                }
            }

            // 更新已开启的战役ID.
            int level = 11011;
            for (int j = 0; j < levelInfos.Length; j++)
            {
                if (levelInfos[j].valid && levelInfos[j].levelID <100000 && levelInfos[j].levelID> level)
                {
                    level = levelInfos[j].levelID;
                }
            }
            sdWorldMapPath.SetLevel(level / 1000, false);
        }

        if (refMSG.m_BattleCount > 0)
        {
            for (int i = 0; i < refMSG.m_BattleCount; i++)
            {
                int bid = (int)refMSG.m_BtInfo[i].m_BattleID;
                if (bid > 0 && bid <= 16)
                {
                    battleInfos[bid].starCount = refMSG.m_BtInfo[i].m_GetStars;
                }
            }
        }

        if (refMSG.m_BoxCount > 0)
        {
            for (int i = 0; i < refMSG.m_BoxCount; i++)
            {
                uint bid = refMSG.m_GotBattleBox[i];
                for (int j = 1; j <= 16; j++)
                {
                    for (int i1 = 0; i1 < 3; i1++)
                    {
                        for (int i2 = 0; i2 < 5; i2++)
                        {
                            BattleBoxItem box = battleInfos[j].rewardBox[i1, i2];
                            if (box != null && box.BoxID == bid)
                            {
                                box.IsTake = true;
                                j          = i1 = i2 = 100;
                            }
                        }
                    }
                }
            }
        }
    }
Beispiel #51
0
    int IfTest.Test(int nType)
    {
        Debug.Log("IfTest.Test(int nType)");
        int nLength = TypeMarshaller.GetLength(nType);
        CMessage pMsg = new CMessage(IfTestMethodId.IfTestTestMethondId, nLength);
        if (null == pMsg.m_pBuffers)
        {
            return MacrosAndDef.OUT_OF_MEM;
        }
        int nBufferLen = pMsg.m_pBuffers.Length;
        int nUsed = 0;

        nUsed = TypeMarshaller.Marshall(pMsg.m_pBuffers, nBufferLen, nUsed, nLength);
        nUsed += TypeMarshaller.Marshall(pMsg.m_pBuffers, nBufferLen, nUsed, pMsg.m_uMsgId);
        int nLen = TypeMarshaller.Marshall(pMsg.m_pBuffers, nBufferLen, nUsed, nType);
        if (nLen < MacrosAndDef.SUCCESS)
        {
            return nLen;
        }
        nUsed += nLen;
        if (nUsed != nBufferLen)
        {
            Debug.LogError("the nUsed is:"+nUsed);
            TypeMarshaller.Marshall(pMsg.m_pBuffers, nBufferLen, sizeof(uint), nUsed);
        }
        //send on net.
        CMessage.sm_pSocket.SendMsg(pMsg);
        return nUsed;
    }