public void Socket_Listen() { NetSocket.inst.AddListener(NetBase.SOCKET_CHAT, (VoSocket vo) => { Dictionary <string, object> data = (Dictionary <string, object>)vo.data; data ["ctype"] = "chat"; data ["effect"] = true; chatModel.all.Add(data); DispatchManager.inst.Dispatch(new MainEvent(MainEvent.CHAT_SEND, vo.data)); }); NetSocket.inst.AddListener(NetBase.SOCKET_APPLEJOINGUILD, (VoSocket vo) => { Dictionary <string, object> data = (Dictionary <string, object>)vo.data; data ["ctype"] = "guild"; data ["effect"] = true; chatModel.all.Add(data); chatModel.Add_RedCount(); DispatchManager.inst.Dispatch(new MainEvent(MainEvent.CHAT_APPLEJOINGUILD, vo.data)); }); NetSocket.inst.AddListener(NetBase.SOCKET_GUILDJOIN, (VoSocket vo) => { Dictionary <string, object> data = (Dictionary <string, object>)vo.data; Dictionary <string, object> user1 = (Dictionary <string, object>)data ["user1"]; Dictionary <string, object> user2 = (Dictionary <string, object>)data ["user2"]; string uid = user2 ["uid"].ToString(); int index = chatModel.RemoveChat("guild", uid); data ["ctype"] = "guild_join"; data ["effect"] = true; chatModel.all.Add(data); if (index != -1) { chatModel.Remove_RedCount(); } else { chatModel.Add_RedCount(); } DispatchManager.inst.Dispatch(new MainEvent(MainEvent.CHAT_GUILDJOIN, vo.data)); }); NetSocket.inst.AddListener(NetBase.SOCKET_GUILDMODIFY, (VoSocket vo) => { Dictionary <string, object> data = (Dictionary <string, object>)vo.data; Dictionary <string, object> user1 = (Dictionary <string, object>)data ["user1"]; Dictionary <string, object> user2 = (Dictionary <string, object>)data ["user2"]; if (Convert.ToInt32(data ["num"]) == -1) //被T { chatModel.Clear(); if (userModel.uid == user2 ["uid"].ToString()) { DispatchManager.inst.Dispatch(new MainEvent(MainEvent.GUILD_ESC, 10)); } else if (guildModel.my_guild_member != null) { guildModel.my_guild_member.Remove(user2 ["uid"].ToString()); } } else { Dictionary <string, object> ttt; if (guildModel.my_guild_member != null && guildModel.my_guild_member.ContainsKey(user2 ["uid"].ToString())) { ttt = (Dictionary <string, object>)guildModel.my_guild_member [user2 ["uid"].ToString()]; ttt ["gradation"] = Convert.ToInt32(data ["num"]); if (userModel.uid == user2 ["uid"].ToString()) { guildModel.my_guild_job = Convert.ToInt32(data ["num"]); } if (Convert.ToInt32(data ["num"]) == 0) { ttt = (Dictionary <string, object>)guildModel.my_guild_member [user1 ["uid"].ToString()]; ttt ["gradation"] = 1; if (userModel.uid == user1 ["uid"].ToString()) { guildModel.my_guild_job = 1; } } } } data ["ctype"] = "guild_modify"; data ["effect"] = true; chatModel.all.Add(data); DispatchManager.inst.Dispatch(new MainEvent(MainEvent.CHAT_GUILDMODIFY, vo.data)); }); NetSocket.inst.AddListener(NetBase.SOCKET_GUILDEXIT, (VoSocket vo) => { Dictionary <string, object> data = (Dictionary <string, object>)vo.data; Dictionary <string, object> user1 = (Dictionary <string, object>)data ["user"]; if (userModel.uid == user1 ["uid"].ToString()) { chatModel.Clear(); } else { data ["ctype"] = "guild_modify"; data ["effect"] = true; chatModel.all.Add(data); DispatchManager.inst.Dispatch(new MainEvent(MainEvent.CHAT_GUILDMODIFY, vo.data)); } }); NetSocket.inst.AddListener(NetBase.SOCKET_SENDGUILDREDBAG, (VoSocket vo) => { Dictionary <string, object> data = (Dictionary <string, object>)vo.data; data ["ctype"] = "send_guild_redbag"; data ["effect"] = true; chatModel.all.Add(data); chatModel.Add_RedCount(); DispatchManager.inst.Dispatch(new MainEvent(MainEvent.CHAT_SENDGUILDREDBAG, vo.data)); }); NetSocket.inst.AddListener(NetBase.SOCKET_REQUIREGUILDSUPPORT, (VoSocket vo) => { Dictionary <string, object> data = (Dictionary <string, object>)vo.data; data ["ctype"] = "require_guild_support"; data ["effect"] = true; chatModel.all.Add(data); if (data ["uid"].ToString() != userModel.uid) { chatModel.Add_RedCount(); } DispatchManager.inst.Dispatch(new MainEvent(MainEvent.CHAT_REQUIREGUILDSUPPORT, vo.data)); }); NetSocket.inst.AddListener(NetBase.SOCKET_SENDGUILDSUPPORT, (VoSocket vo) => { Dictionary <string, object> data = (Dictionary <string, object>)vo.data; Dictionary <string, object> da = (Dictionary <string, object>)data ["require_user"]; string uid = da ["uid"].ToString(); string cardId = ""; string name = ModelUser.GetUname(data ["uid"], data ["name"]); int count = -1; if (userModel.uid == uid) { foreach (string n in da.Keys) { if (n == Config.ASSET_GOLD) { userModel.gold = Convert.ToInt32(da [n]); } else if (n == Config.ASSET_CARD) { Dictionary <string, object> temp = (Dictionary <string, object>)da [n]; foreach (string id in temp.Keys) { count = userModel.GetCardMulCard(userModel.card [id], temp [id]); userModel.card [id] = temp [id]; cardId = id; } } } if (count != -1) { string str = ""; str = count == 0 ? " " : "X" + count.ToString(); string msg = Tools.GetMessageById("14035", new string[] { name, CardVo.GetCardName(cardId), str }); msg = Tools.GetMessageColor(msg, new string[] { "dc8100", "2699ea" }); if (count == 0) { ViewManager.inst.ShowText(Tools.GetMessageById("33212")); } ViewManager.inst.ShowMessage(msg); } } chatModel.UpdateGuildSupport(data); //List<int> index = DispatchManager.inst.Dispatch(new MainEvent(MainEvent.CHAT_SENDGUILDSUPPORT)); }); NetSocket.inst.AddListener(NetBase.SOCKET_GUILDFIGHTSHARE, (VoSocket vo) => { Dictionary <string, object> data = (Dictionary <string, object>)vo.data; data ["ctype"] = "guild_fight_share"; data ["effect"] = true; chatModel.all.Add(data); DispatchManager.inst.Dispatch(new MainEvent(MainEvent.CHAT_FIGHTSHARE, vo.data)); }); NetSocket.inst.AddListener(NetBase.SOCKET_NOTICE, (VoSocket vo) => { Dictionary <string, object> d = (Dictionary <string, object>)vo.data; foreach (string n in d.Keys) { userModel.notice [n] = d [n]; } DispatchManager.inst.Dispatch(new MainEvent(MainEvent.RED_UPDATE, vo.data)); }); NetSocket.inst.AddListener(NetBase.SOCKET_GETINVITE, (VoSocket vo) => { if (!userModel.IsInvite()) { return; } // bool isOk = userModel.GetUnlcok (Config.UNLOCK_TEAMMATCH); // if (!isOk) // return; // isOk = userModel.GetUnlcok (Config.UNLOCK_FREEMATCH1); // if (!isOk) // return; // isOk = userModel.GetUnlcok (Config.UNLOCK_FREEMATCH2); // if (!isOk) // return; Dictionary <string, object> data = (Dictionary <string, object>)vo.data; data ["type"] = 0; ViewManager.inst.ShowInviteAlert(data); // string name = ModelUser.GetUname (data ["uid"], data ["name"]); // string teamId = data ["team_id"].ToString (); // ViewManager.inst.ShowAlert (Tools.GetMessageById ("25006", new String[]{ name }), (int index) => // { // if (index == 1) // { // Dictionary<string,object> da = new Dictionary<string, object> (); // da ["team_id"] = teamId; // NetSocket.inst.Send (NetBase.SOCKET_ACCEPTINVITE, da); // } // }, true); }); NetSocket.inst.AddListener(NetBase.SOCKET_ACCEPTINVITE, (VoSocket vo) => { if (vo.data is Boolean && !Convert.ToBoolean(vo.data)) { ViewManager.inst.ShowText(Tools.GetMessageById("25007")); return; } fightModel.SetTeam(vo.data); fightModel.isRequest = false; ViewManager.inst.ShowScene <MediatorMain> (); ViewManager.inst.ShowView <MediatorTeamMatch> (); ViewManager.inst.CloseInviteAlertAll(); }); NetSocket.inst.AddListener(NetBase.SOCKET_FREEGETINVITE, (VoSocket vo) => { if (!userModel.IsInvite()) { return; } bool isOk = userModel.GetUnlcok(Config.UNLOCK_TEAMMATCH); if (!isOk) { return; } isOk = userModel.GetUnlcok(Config.UNLOCK_FREEMATCH1); if (!isOk) { return; } isOk = userModel.GetUnlcok(Config.UNLOCK_FREEMATCH2); if (!isOk) { return; } Dictionary <string, object> data = (Dictionary <string, object>)vo.data; data ["type"] = 1; ViewManager.inst.ShowInviteAlert(data); // string name = ModelUser.GetUname (data ["uid"], data ["name"]); // string roomId = data ["room_id"].ToString (); // ViewManager.inst.ShowAlert (Tools.GetMessageById ("25040", new String[]{ name }), (int index) => // { // if (index == 1) // { // Dictionary<string,object> da = new Dictionary<string, object> (); // da ["room_id"] = roomId; // NetSocket.inst.Send (NetBase.SOCKET_FREEACCEPTINVITE, da); // } // }, true); }); NetSocket.inst.AddListener(NetBase.SOCKET_FREEACCEPTINVITE, (VoSocket vo) => { if (vo.data is Boolean && !Convert.ToBoolean(vo.data)) { ViewManager.inst.ShowText(Tools.GetMessageById("25007")); return; } fightModel.SetFreeTeam(vo.data); fightModel.isRequest = false; ViewManager.inst.ShowScene <MediatorMain> (); ViewManager.inst.ShowView <MediatorFreeMatch> (); ViewManager.inst.CloseInviteAlertAll(); }); NetSocket.inst.AddListener(NetBase.SOCKET_SHOWMSG, (VoSocket vo) => { Dictionary <string, object> data = (Dictionary <string, object>)vo.data; string id = data ["id"].ToString(); Dictionary <string, object> reward = userModel.GetReward(data ["data"]); userModel.UpdateData(data ["data"]); string msg = ""; if (id == "share") { msg = Tools.GetMessageById("14034", new string[] { reward ["coin"].ToString() }); msg = Tools.GetMessageColor(msg, new string[] { "dc8100", "2699ea" }); DispatchManager.inst.Dispatch(new MainEvent(MainEvent.EVENTSHARE, "3")); ViewManager.inst.ShowMessage(msg); } }); NetSocket.inst.AddListener(NetBase.SOCKET_GRABGUILDREDBAG, (VoSocket vo) => { userModel.records ["guild_redbag_log"] = vo.data; // Dictionary<string,object> da = (Dictionary<string,object>)vo.data; // Log.debug ("remain_num - " + da ["remain_num"].ToString ()); DispatchManager.inst.Dispatch(new MainEvent(MainEvent.CHAT_ISSENDREDBAG)); }); NetSocket.inst.AddListener(NetBase.SOCKET_GETRESUILTPUSH, (VoSocket vo) => { if (fightModel.fightResult != null) { return; } Dictionary <string, object> data = new Dictionary <string, object> (); data ["data"] = vo.data; data ["type"] = fightModel.fightType; fightModel.fightResult = data; DispatchManager.inst.Dispatch(new MainEvent(MainEvent.FIGHT_RESULT, data)); }); NetSocket.inst.AddListener(NetBase.SOCKET_GETRESUILTTEAMPUSH, (VoSocket vo) => { if (fightModel.fightResult != null) { return; } Dictionary <string, object> data = new Dictionary <string, object> (); data ["data"] = vo.data; data ["type"] = fightModel.fightType; fightModel.fightResult = data; DispatchManager.inst.Dispatch(new MainEvent(MainEvent.FIGHT_RESULT, data)); }); }