Пример #1
0
    /// <summary>
    /// Sends the message.
    /// 用消息ID 获取信息;
    /// </summary>
    /// <param name="msgID">Message I.</param>
    /// <param name="URL">UR.</param>
    public void SendMsg(GameMessage msgID, string URL, bool isNeedTipWaite = false)
    {
        bool isNeed = MsgSet.IsNeedTipByMsgID((int)msgID);

        if (isNeedTipWaite || isNeed)
        {
            GTSenceManage.Instance().StartLoadData();
        }

        NetPacket pack = new NetPacket((int)msgID, 0);

        GameObject  oneObj  = new GameObject("http_" + msgID);
        HttpDataCmp httpCmp = oneObj.AddComponent <HttpDataCmp> ();

        httpCmp.isNeedTipWaite   = isNeedTipWaite;
        httpCmp.transform.parent = transform;

        httpCmp.GET(msgID, URL, GetDataCallFun, pack);
    }
Пример #2
0
    /// <summary>
    /// Sends the message.
    /// 带参数l
    /// </summary>
    /// <param name="msgID">Message I.</param>
    /// <param name="URL">UR.</param>
    /// <param name="values">Values.</param>
    public void SendMsgJson(GameMessage msgID, string URL, bool isNeedTipWaite, params HttpPbj[] values)
    {
        bool isNeed = MsgSet.IsNeedTipByMsgID((int)msgID);

        if (isNeedTipWaite || isNeed)
        {
            GTSenceManage.Instance().StartLoadData();
        }
        //		if(catchePool.countInactive > 0)
        //		{
        //
        //		}
        //		catchePool
        //		catchePool.Get ();
        GameObject  oneObj  = new GameObject("http_" + msgID);
        HttpDataCmp httpCmp = oneObj.AddComponent <HttpDataCmp> ();

        httpCmp.isNeedTipWaite   = isNeedTipWaite;
        httpCmp.transform.parent = transform;
        httpCmp.GET(msgID, URL, GetDataCallFun, values);
    }
Пример #3
0
    /// <summary>
    /// Sends the message.
    /// 发送结构体过去;
    /// </summary>
    /// <param name="msgID">Message I.</param>
    /// <param name="URL">UR.</param>
    /// <param name="protoSt">Proto st.</param>
    /// <typeparam name="T">The 1st type parameter.</typeparam>
    public void SendMsg <T> (GameMessage msgID, string URL, T protoSt, bool isNeedTipWaite = false) where T : class, ProtoBuf.IExtensible
    {
        Debuger.LogWarning("向服务器发送 http " + msgID + "  ");
        using (MemoryStream ms = new MemoryStream()) {
            bool isNeed = MsgSet.IsNeedTipByMsgID((int)msgID);
            if (isNeedTipWaite || isNeed)
            {
                GTSenceManage.Instance().StartLoadData();
            }
            new PBMessageSerializer().Serialize(ms, protoSt);
            byte[] bytes = ms.ToArray();

            NetPacket pack = new NetPacket((int)msgID, bytes.Length);
            pack.setData(bytes);

            GameObject  oneObj  = new GameObject("http_" + msgID);
            HttpDataCmp httpCmp = oneObj.AddComponent <HttpDataCmp> ();
            httpCmp.isNeedTipWaite   = isNeedTipWaite;
            httpCmp.transform.parent = transform;

            httpCmp.GET(msgID, URL, GetDataCallFun, pack);
        }
    }