package com.bytedance.common.wschannel.model;

import X.0HH;
import X.Q39;
import android.os.Parcel;
import android.os.Parcelable;
import com.bytedance.covode.number.Covode;
import org.json.JSONException;
import org.json.JSONObject;

public class SocketState implements Parcelable {
    public static final Parcelable.Creator<SocketState> CREATOR = new Parcelable.Creator<SocketState>() {
        static {
            Covode.recordClassIndex(24947);
        }

        public final /* bridge */ /* synthetic */ Object[] newArray(int i) {
            return new SocketState[i];
        }

        public final /* synthetic */ Object createFromParcel(Parcel parcel) {
            return new SocketState(parcel);
        }
    };
    public int LIZ;
    public int LIZIZ;
    public String LIZJ;
    public int LIZLLL;
    public int LJ;
    public String LJFF;
    public int LJI;

    public int describeContents() {
        return 0;
    }

    public SocketState() {
    }

    static {
        Covode.recordClassIndex(24946);
    }

    public final JSONObject LIZ() {
        JSONObject jSONObject = new JSONObject();
        try {
            jSONObject.put("channel_id", this.LIZLLL);
            jSONObject.put("type", this.LIZ);
            jSONObject.put("state", this.LIZIZ);
            jSONObject.put("url", this.LIZJ);
            jSONObject.put("channel_type", this.LJ);
            jSONObject.put("error", this.LJFF);
            jSONObject.put("error_code", this.LJI);
        } catch (JSONException e) {
            0HH.LIZ(e);
        }
        return jSONObject;
    }

    public String toString() {
        return "SocketState{connectionType=" + this.LIZ + ", connectionState=" + this.LIZIZ + ", connectionUrl='" + this.LIZJ + '\'' + ", channelId=" + this.LIZLLL + ", channelType=" + this.LJ + ", error='" + this.LJFF + '\'' + '}';
    }

    public SocketState(Parcel parcel) {
        this.LIZ = parcel.readInt();
        this.LIZIZ = parcel.readInt();
        this.LIZJ = parcel.readString();
        this.LIZLLL = parcel.readInt();
        this.LJ = parcel.readInt();
        this.LJFF = parcel.readString();
        this.LJI = parcel.readInt();
    }

    public static SocketState LIZ(JSONObject jSONObject) {
        SocketState socketState = new SocketState();
        socketState.LIZLLL = jSONObject.optInt("channel_id", Integer.MIN_VALUE);
        socketState.LIZ = jSONObject.optInt("type", -1);
        socketState.LIZIZ = jSONObject.optInt("state", -1);
        socketState.LIZJ = jSONObject.optString("url", Q39.LIZJ);
        socketState.LJ = jSONObject.optInt("channel_type");
        socketState.LJFF = jSONObject.optString("error", Q39.LIZJ);
        socketState.LJI = jSONObject.optInt("error_code");
        return socketState;
    }

    public void writeToParcel(Parcel parcel, int i) {
        parcel.writeInt(this.LIZ);
        parcel.writeInt(this.LIZIZ);
        parcel.writeString(this.LIZJ);
        parcel.writeInt(this.LIZLLL);
        parcel.writeInt(this.LJ);
        parcel.writeString(this.LJFF);
        parcel.writeInt(this.LJI);
    }
}
