Beispiel #1
0
    /// <summary>
    /// subject 콜백
    /// </summary>
    private void connectServer(NetData netData)
    {
        m_bConnecting.Value = true;

        var stream = ObservableWWW.PostWWW(URLData.BaseServer, netData.data.form()).CatchIgnore((WWWErrorException ex) =>
        {
            Debug.LogError(ex.RawErrorMessage);
            if (ex.HasResponse)
            {
                Debug.LogError(ex.StatusCode);
            }
            foreach (var item in ex.ResponseHeaders)
            {
                Debug.LogError(item.Key + ":" + item.Value);
            }
            netData.Destroy();
        });

        stream.Subscribe(_ =>
        {
            m_bConnecting.Value     = false;
            object dic_reciveObject = Json.Deserialize(_.text);

            Dictionary <string, object> data = (Dictionary <string, object>)dic_reciveObject;
            netData.subject.OnNext(data);
            netData.subject.OnCompleted();
        }).Dispose();
    }