示例#1
0
    // Update is called once per frame
    void Update()
    {
        if (m_bReady)
        {
            LanSocket.MsgUnPack msg = null;
            m_GameNet.GetMsg(ref msg);
            if (null != msg)
            {
                print("here have one msg on client");
            }

            if (Input.GetKeyUp(KeyCode.Space))
            {
                LanSocket.MsgPack sendMsg = new LanSocket.MsgPack();
                sendMsg.SetHead((int)NetMsgID.C2S_SELECT_ANIMAL);
                sendMsg.Pack16bit(1);
                sendMsg.PackEnd();
                m_GameNet.Send(ref sendMsg);
                print("send 1");
            }
        }
        else
        {
            m_GameServerIP = m_Reciver.GetIP();
            if ("".Equals(m_GameServerIP))
            {
                m_BroadTime -= Time.deltaTime;
                if (m_BroadTime - Time.deltaTime < 0.0f)
                {
                    m_BroadTime = 5.0f;
                    m_Sender.Send();
                }
            }
            else
            {
                print("get broadcast ip:" + m_GameServerIP);
                GameStart();
            }
        }
    }
示例#2
0
    void Action_123(LanSocket.ClientMsgUnPack msg)
    {
        long   userID     = msg.GetUserID();
        ushort accountLen = msg.ReadUShort();
        string account    = msg.ReadString(accountLen);
        ushort passLen    = msg.ReadUShort();
        string pass       = msg.ReadString(passLen);

        print("Action_123 account: " + account + " pass word: " + pass + " from user: "******"test account";

        sendMsg.Pack16bit((ushort)strAccount.Length);
        sendMsg.PackString(strAccount, (ushort)strAccount.Length);
        string strPass = "******";

        sendMsg.Pack16bit((ushort)strPass.Length);
        sendMsg.PackString(strPass, (ushort)strPass.Length);
        sendMsg.PackEnd();
        m_GameNet.SendTo(ref sendMsg, msg.GetUserID());
    }