token问题,喇叭
This commit is contained in:
@@ -169,6 +169,7 @@ public class Constants {
|
||||
public static final String SOCKET_PRANKTURNTABLE = "prankTurntable";//整蛊消息
|
||||
public static final String SOCKET_USEHOTCARD = "UseHotCard";//热度卡消息
|
||||
public static final String LOVE_CHECK = "LoveCheck";//热度卡消息
|
||||
public static final String TRUMPET_NOTIFY = "TrumpetNotify";//全栈喇叭
|
||||
|
||||
public static final int SOCKET_WHAT_CONN = 0;
|
||||
public static final int SOCKET_WHAT_DISCONN = 2;
|
||||
|
||||
81
common/src/main/java/com/yunbao/common/bean/MsgModel.java
Normal file
81
common/src/main/java/com/yunbao/common/bean/MsgModel.java
Normal file
@@ -0,0 +1,81 @@
|
||||
package com.yunbao.common.bean;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class MsgModel extends BaseModel {
|
||||
/**
|
||||
* _method_ : TrumpetNotify
|
||||
* user_id : 97809
|
||||
* user_name : 严肃苏苏
|
||||
* noble_id : 5
|
||||
* trumpet_msg : 估计快了可能吧v
|
||||
* anchor_id : 97714
|
||||
*/
|
||||
|
||||
@SerializedName("_method_")
|
||||
private String method = "";
|
||||
@SerializedName("user_id")
|
||||
private String userId = "";
|
||||
@SerializedName("user_name")
|
||||
private String userName = "";
|
||||
@SerializedName("noble_id")
|
||||
private long nobleId = 0;
|
||||
@SerializedName("trumpet_msg")
|
||||
private String trumpetMsg = "";
|
||||
@SerializedName("anchor_id")
|
||||
private String anchorId = "";
|
||||
|
||||
public String getMethod() {
|
||||
return method;
|
||||
}
|
||||
|
||||
public MsgModel setMethod(String method) {
|
||||
this.method = method;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public MsgModel setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public MsgModel setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public long getNobleId() {
|
||||
return nobleId;
|
||||
}
|
||||
|
||||
public MsgModel setNobleId(long nobleId) {
|
||||
this.nobleId = nobleId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTrumpetMsg() {
|
||||
return trumpetMsg;
|
||||
}
|
||||
|
||||
public MsgModel setTrumpetMsg(String trumpetMsg) {
|
||||
this.trumpetMsg = trumpetMsg;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getAnchorId() {
|
||||
return anchorId;
|
||||
}
|
||||
|
||||
public MsgModel setAnchorId(String anchorId) {
|
||||
this.anchorId = anchorId;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
49
common/src/main/java/com/yunbao/common/bean/SocketModel.java
Normal file
49
common/src/main/java/com/yunbao/common/bean/SocketModel.java
Normal file
@@ -0,0 +1,49 @@
|
||||
package com.yunbao.common.bean;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SocketModel extends BaseModel {
|
||||
|
||||
/**
|
||||
* retcode : 000000
|
||||
* retmsg : OK
|
||||
* msg : [{"_method_":"TrumpetNotify","user_id":"97809","user_name":"严肃苏苏","noble_id":5,"trumpet_msg":"估计快了可能吧v","anchor_id":"97714"}]
|
||||
*/
|
||||
|
||||
@SerializedName("retcode")
|
||||
private String retcode = "";
|
||||
@SerializedName("retmsg")
|
||||
private String retmsg = "";
|
||||
@SerializedName("msg")
|
||||
private List<MsgModel> msg = new ArrayList<>();
|
||||
|
||||
public String getRetcode() {
|
||||
return retcode;
|
||||
}
|
||||
|
||||
public SocketModel setRetcode(String retcode) {
|
||||
this.retcode = retcode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getRetmsg() {
|
||||
return retmsg;
|
||||
}
|
||||
|
||||
public SocketModel setRetmsg(String retmsg) {
|
||||
this.retmsg = retmsg;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<MsgModel> getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public SocketModel setMsg(List<MsgModel> msg) {
|
||||
this.msg = msg;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -47,9 +47,13 @@ public class API extends BaseApi {
|
||||
Gson gson = new GsonBuilder()
|
||||
.registerTypeAdapter(Date.class, new DateTypeAdapter())
|
||||
.create();
|
||||
HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor("http");
|
||||
loggingInterceptor.setPrintLevel(HttpLoggingInterceptor.Level.BODY);
|
||||
OkHttpClient.Builder builder = new OkHttpClient()
|
||||
.newBuilder()
|
||||
.addInterceptor(initQuery(CommonAppContext.sInstance.getApplicationContext()));
|
||||
.addInterceptor(initQuery(CommonAppContext.sInstance.getApplicationContext()))
|
||||
.addInterceptor(loggingInterceptor);
|
||||
|
||||
pdLiveApi = create(builder.build(),
|
||||
GsonConverterFactory.create(gson), RxJava2CallAdapterFactory.create(), CommonAppConfig.HOST, PDLiveApi.class);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
package com.yunbao.common.http;
|
||||
|
||||
import com.yunbao.common.bean.BaseModel;
|
||||
import com.yunbao.common.bean.IMLoginModel;
|
||||
import com.yunbao.common.bean.NobleTrumpetModel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.POST;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
/**
|
||||
* PDLive网络接口访问
|
||||
@@ -40,4 +44,16 @@ public interface PDLiveApi {
|
||||
*/
|
||||
@GET("/api/public/?service=Noble.getNobleTrumpetNum")
|
||||
Observable<ResponseModel<NobleTrumpetModel>> getNobleTrumpetNum();
|
||||
|
||||
/**
|
||||
* 贵族使用喇叭
|
||||
*
|
||||
* @param trumpetMsg 喇叭内容
|
||||
* @param anchorid 主播id
|
||||
* @return
|
||||
*/
|
||||
@GET("/api/public/?service=Noble.nobleUseTrumpet")
|
||||
Observable<ResponseModel<List<BaseModel>>> nobleUseTrumpet(
|
||||
@Query("trumpet_msg") String trumpetMsg,
|
||||
@Query("anchor_id") String anchorid);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package com.yunbao.common.http.live;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
|
||||
import com.yunbao.common.bean.BaseModel;
|
||||
import com.yunbao.common.bean.NobleTrumpetModel;
|
||||
import com.yunbao.common.http.API;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
@@ -13,10 +16,10 @@ import io.reactivex.schedulers.Schedulers;
|
||||
* 直播网络请求整合
|
||||
*/
|
||||
public class LiveNetManager {
|
||||
private Activity mContext;
|
||||
private Context mContext;
|
||||
private static LiveNetManager manager;
|
||||
|
||||
public LiveNetManager(Activity context) {
|
||||
public LiveNetManager(Context context) {
|
||||
this.mContext = context;
|
||||
}
|
||||
|
||||
@@ -25,7 +28,7 @@ public class LiveNetManager {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static LiveNetManager get(Activity context) {
|
||||
public static LiveNetManager get(Context context) {
|
||||
if (null == manager) {
|
||||
manager = new LiveNetManager(context);
|
||||
}
|
||||
@@ -49,4 +52,29 @@ public class LiveNetManager {
|
||||
callback.onError(throwable.getMessage());
|
||||
}).isDisposed();
|
||||
}
|
||||
|
||||
/**
|
||||
* 贵族使用喇叭
|
||||
*
|
||||
* @param trumpetMsg 喇叭内容
|
||||
* @param anchorid 主播id
|
||||
* @param callback 回调
|
||||
*/
|
||||
public void nobleUseTrumpet(String trumpetMsg, String anchorid, HttpCallback<List<BaseModel>> callback) {
|
||||
API.get().pdLiveApi(mContext).nobleUseTrumpet(trumpetMsg, anchorid)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(baseModelResponseModel -> {
|
||||
if (baseModelResponseModel.getData().getCode() == 0 && callback != null) {
|
||||
callback.onSuccess(baseModelResponseModel.getData().getInfo());
|
||||
} else {
|
||||
if (callback != null)
|
||||
callback.onError("发送失败");
|
||||
}
|
||||
}, throwable -> {
|
||||
if (callback != null)
|
||||
callback.onError(throwable.getMessage());
|
||||
//java.lang.IllegalStateException: Fragment LiveInputDialogFragment{229db51} (f38ce923-7a48-4c64-925a-bed0edfb7fa7)} not attached to a context.
|
||||
}).isDisposed();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,6 +82,8 @@ public class IMLoginManager extends BaseCacheManager {
|
||||
if (null == userInfo) {
|
||||
userInfo = new Gson().fromJson(
|
||||
getString(KEY_USER_INFO), IMLoginModel.class);
|
||||
if (userInfo != null)
|
||||
token = userInfo.getToken();
|
||||
}
|
||||
return userInfo;
|
||||
}
|
||||
@@ -119,7 +121,9 @@ public class IMLoginManager extends BaseCacheManager {
|
||||
*/
|
||||
public void upDataUserInfo(@NonNull String json) {
|
||||
userInfo = new Gson().fromJson(json, IMLoginModel.class);
|
||||
userInfo.setToken(token);
|
||||
if (!TextUtils.isEmpty(token)) {
|
||||
userInfo.setToken(token);
|
||||
}
|
||||
put(KEY_USER_INFO, new Gson().toJson(userInfo));
|
||||
//兼容老模块(之后要把用户维护的类更换掉)
|
||||
SpUtil.getInstance().setStringValue(SpUtil.USER_INFO, new Gson().toJson(userInfo));
|
||||
@@ -209,7 +213,9 @@ public class IMLoginManager extends BaseCacheManager {
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0 && info.length > 0) {
|
||||
userInfo = new Gson().fromJson(info[0], IMLoginModel.class);
|
||||
userInfo.setToken(uidAndToken[1]);
|
||||
if (!TextUtils.isEmpty(uidAndToken[1])) {
|
||||
userInfo.setToken(uidAndToken[1]);
|
||||
}
|
||||
EventBus.getDefault().post(new DataUserInfoEvent().setUpDataSuccess(true));
|
||||
} else {
|
||||
EventBus.getDefault().post(new DataUserInfoEvent().setUpDataSuccess(false));
|
||||
|
||||
@@ -864,4 +864,5 @@
|
||||
<string name="site_wide_news_hint2">开通贵族国王、皇帝、超级皇帝免费获得</string>
|
||||
<string name="back">返回</string>
|
||||
<string name="go_nobility">前往贵族</string>
|
||||
<string name="use_successfully">使用成功</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user