示例#1
0
文件: net_http.cs 项目: dqchess/mario
    IEnumerator http(opclient_t opcode, byte[] msg)
    {
        string ip = m_ip;

        if (game_data._instance.m_channel == "web_facebook")
        {
            ip = m_ips;
        }
        if (game_data._instance.m_lang == e_language.el_english)
        {
            ip = m_en_ip;
            if (game_data._instance.m_channel == "web_facebook")
            {
                ip = m_en_ips;
            }
        }
        m_www = new WWW(ip + ((int)opcode).ToString(), msg);
        while (!m_www.isDone)
        {
            yield return(new WaitForSeconds(0.1f));
        }

        bool res = do_www(m_www, opcode);

        if (res)
        {
            m_pcks.RemoveAt(0);
            if (m_pcks.Count > 0)
            {
                net_start();
            }
        }
    }
示例#2
0
文件: net_http.cs 项目: dqchess/mario
    private void onRecMsg(opclient_t opcode, int res, byte[] msg)
    {
        s_net_message _message = new s_net_message();

        _message.m_byte   = msg;
        _message.m_opcode = opcode;
        _message.m_res    = res;
        cmessage_center._instance.add_net_message(_message);
    }
示例#3
0
文件: net_http.cs 项目: dqchess/mario
    public void send_msg <T>(opclient_t opcode, T obj, bool restart = true, string text = "", float wait = 10)
    {
        net_pck np = new net_pck();

        np.opcode  = opcode;
        np.obj     = obj;
        np.wait    = wait;
        np.text    = text;
        np.restart = restart;
        m_pcks.Add(np);

        if (m_pcks.Count > 1)
        {
            return;
        }

        net_start();
    }
示例#4
0
文件: net_http.cs 项目: dqchess/mario
    private bool do_www(WWW _www, opclient_t opcode)
    {
        if (!string.IsNullOrEmpty(_www.error))
        {
            mario._instance.wait(false);
            m_wait = 0;

            do_fail();

            Debug.Log("http error  :" + _www.error);
            return(false);
        }
        else
        {
            mario._instance.wait(false);
            m_wait = 0;

            protocol.game.msg_response response = net_http._instance.parse_packet <protocol.game.msg_response> (_www.bytes);
            if (response.res == 0)
            {
                if (mario._instance.m_self != null)
                {
                    mario._instance.m_self.m_pck_id++;
                }
                onRecMsg(opcode, response.res, response.msg);
            }
            else if (response.res == -1)
            {
                if (mario._instance.m_self != null)
                {
                    mario._instance.m_self.m_pck_id++;
                }
                onRecMsg(opcode, response.res, response.error);
            }
            else
            {
                mario._instance.show_tip(game_data._instance.get_t_error(response.res));
            }

            return(true);
        }
    }