|
|
@@ -20,6 +20,34 @@ const handlePayFinish=(message,dispatch)=>{
|
|
|
let {data}=message;
|
|
|
if (data&&data.PayNum>=200)global.showDropCoins();
|
|
|
}
|
|
|
+const handleKick=(message,dispatch)=>{
|
|
|
+ let onSure=()=>{
|
|
|
+ dispatch(updateServerKick(0));
|
|
|
+ dispatch(connectHall());
|
|
|
+ }
|
|
|
+ let data={
|
|
|
+ content:i18n.t("hall.offline"),
|
|
|
+ sureCB:onSure,
|
|
|
+ onlySure: true,
|
|
|
+ isLockClose:true,
|
|
|
+ sureLabel:i18n.t("hall.reconnect"),
|
|
|
+ }
|
|
|
+ global.msgBoxShow(data)
|
|
|
+ dispatch(updateServerKick(1));
|
|
|
+}
|
|
|
+const handleHallTimeout=(message,dispatch)=>{
|
|
|
+ let onSure=()=>{
|
|
|
+ dispatch(connectHall());
|
|
|
+ }
|
|
|
+ let data={
|
|
|
+ content:i18n.t("hall.disconnected"),
|
|
|
+ sureCB:onSure,
|
|
|
+ onlySure: true,
|
|
|
+ isLockClose:true,
|
|
|
+ sureLabel:i18n.t("hall.reconnect"),
|
|
|
+ }
|
|
|
+ global.msgBoxShow(data)
|
|
|
+}
|
|
|
const roger=(message,dispatch)=>{
|
|
|
// console.log(message);
|
|
|
if (message){
|
|
|
@@ -50,34 +78,40 @@ const roger=(message,dispatch)=>{
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
- //踢
|
|
|
- case "kick":{
|
|
|
- // send("operate",{cmd:"kick",data:{reason:"hall.other_online"}});
|
|
|
- if(!!message.data){
|
|
|
- let {data}=message;
|
|
|
- let reason=data.reason;
|
|
|
- if (reason!=null){
|
|
|
- toast.error(i18n.t("hall.offline"));
|
|
|
- }
|
|
|
- }
|
|
|
- dispatch(updateServerKick(1));
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
const chat=(message,dispatch)=>{
|
|
|
- console.log(message);
|
|
|
+
|
|
|
+}
|
|
|
+const operate=(message,dispatch)=>{
|
|
|
+ let {cmd}=message;
|
|
|
+ switch (cmd){
|
|
|
+ case "id":{
|
|
|
+ dispatch(hallSendState());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case "state":{
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ //踢
|
|
|
+ case "kick":{
|
|
|
+ // send("operate",{cmd:"kick",data:{reason:"hall.other_online"}});
|
|
|
+ handleKick(message,dispatch);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
//信息处理
|
|
|
const messageHandler={
|
|
|
__playground_message_types,
|
|
|
roger,
|
|
|
- chat
|
|
|
+ chat,
|
|
|
+ operate
|
|
|
}
|
|
|
const onHallConnect=()=>{
|
|
|
return (dispatch, getState) => {
|
|
|
dispatch(hallSendReg());
|
|
|
- dispatch(hallSendState());
|
|
|
// dispatch(hallSendState(0));
|
|
|
// dispatch(hallSendChat("123456"));
|
|
|
// setInterval(()=>{
|
|
|
@@ -85,6 +119,11 @@ const onHallConnect=()=>{
|
|
|
// },1000);
|
|
|
}
|
|
|
}
|
|
|
+const onHallTimeoutClose=()=>{
|
|
|
+ return (dispatch, getState) => {
|
|
|
+ handleHallTimeout("",dispatch);
|
|
|
+ }
|
|
|
+}
|
|
|
const send=(type,message,dispatch)=>{
|
|
|
dispatch(sendToServer({
|
|
|
roomName,
|
|
|
@@ -102,19 +141,24 @@ export const onHallMessage=(type,message)=>{
|
|
|
}
|
|
|
export const connectHall=(hallServerUrl='')=>{
|
|
|
if (hallServerUrl==='')hallServerUrl=serverUrl;
|
|
|
- return connectServer({
|
|
|
- roomName:roomName,
|
|
|
- serverUrl:hallServerUrl,
|
|
|
- messageCB:onHallMessage,
|
|
|
- onRoomConnect:onHallConnect
|
|
|
- });
|
|
|
+ return (dispatch, getState) => {
|
|
|
+ let state = getState();
|
|
|
+ let url=state.main.hallServerUrl;
|
|
|
+ if (url==='')url=serverUrl;
|
|
|
+ dispatch(connectServer({
|
|
|
+ roomName:roomName,
|
|
|
+ serverUrl:hallServerUrl,
|
|
|
+ messageCB:onHallMessage,
|
|
|
+ onRoomConnect:onHallConnect,
|
|
|
+ onRoomTimeoutClose:onHallTimeoutClose,
|
|
|
+ }));
|
|
|
+ }
|
|
|
}
|
|
|
export const disconnectHall=()=>{
|
|
|
return disconnectServer(roomName);
|
|
|
}
|
|
|
export const hallSendReg=()=>{
|
|
|
return (dispatch, getState) => {
|
|
|
- console.log("login user");
|
|
|
let main=getState().main;
|
|
|
let userInfo=main.userInfo;
|
|
|
let {UserID,GlobalUID,FaceID,NickName}=userInfo;
|