private void OnCreate(SDNet.ReturnCode code, string res) { if (code == SDNet.ReturnCode.OK) _panel.GetComponent<PanelLogin>().State = PanelLogin.ePanelLoginState.CHARA; else Debug.Log(res); }
private void OnLogin(SDNet.ReturnCode code, string res) { if (code == SDNet.ReturnCode.OK) _panel.GetComponent<PanelLogin>().State = PanelLogin.ePanelLoginState.CHARA; else if (res.Length == 39) ErrorMenu.Instance.setErrorMsg("Email or password invalid"); }
private void OnRegister(SDNet.ReturnCode code, string res) { if (code == SDNet.ReturnCode.OK) _panel.GetComponent<PanelLogin>().State = PanelLogin.ePanelLoginState.LOGIN; else ErrorMenu.Instance.setErrorMsg(res); }
public void OnCharactersLoaded(SDNet.ReturnCode code, string res) { if (code == SDNet.ReturnCode.OK) { if (res.Length > 0) { parseRequest(res); displayCharacter(); } } else _panel.GetComponent<PanelLogin>().State = PanelLogin.ePanelLoginState.LOGIN; }
// ---------------------------------------------------------------------------------------------------------------- #region NET callbacks private void OnNetMasterServerReply(SDNet.ReturnCode code, string res) { // reply from server if (code == SDNet.ReturnCode.OK) { simple_console_text += "Connected.\n"; // now check version state = State.waiting; simple_console_text += "Checking version ..."; waitMsg = "Checking game version"; StartCoroutine(SDNet.Instance.VersionCheck(OnNetVersionReply)); } else { state = State.none; simple_console_text += "Failed: " + res + "\n"; } }
private void OnNetSettingsSaved(SDNet.ReturnCode code, string res) { state = State.inlobby; if (code != SDNet.ReturnCode.OK) { simple_console_text += "Failed: " + res + "\n"; } else { simple_console_text += "Done.\n"; } }
private void OnNetAdvertURL(SDNet.ReturnCode code, string res) { if (code == SDNet.ReturnCode.OK) { StartCoroutine(DownloadAdvert(res)); } }
private void OnNetNews(SDNet.ReturnCode code, string res) { if (code == SDNet.ReturnCode.OK) { char[] splitter = { '|' }; string[] msgs = res.Split(splitter); splitter[0] = '^'; foreach (string m in msgs) { if (string.IsNullOrEmpty(m)) continue; string[] vals = m.Split(splitter); if (vals.Length > 1) { news_text += "[" + vals[0] + "] " + vals[1] + "\n"; } } } else news_text = "Error: Could not load news\n"; }
private void OnNetLogin(SDNet.ReturnCode code, string res) { if (code != SDNet.ReturnCode.OK) { simple_console_text += "Login failed: " + res + "\n"; state = State.login_window; } else { state = State.inlobby; simple_console_text += res;// "Done.\n"; chat.ConnectChat(); // read some settings that where saved on server emailNotify = GamePHP.Instance.opt_email_notify == 1; // ask for latest news SDNet.Instance.NormalRequest(GamePHP.Instance.MainUrl + "news/", OnNetNews, null); // ask for URL to an advert to load SDNet.Instance.NormalRequest(GamePHP.Instance.MainUrl + "aimg/", OnNetAdvertURL, null); } }
private void OnNetRecoverPW(SDNet.ReturnCode code, string res) { if (code != SDNet.ReturnCode.OK) { simple_console_text += "\nERROR: " + res + "\n"; state = State.login_window; } else { simple_console_text += "Complete. Check your e-mail for new password.\n"; state = State.login_window; } }
private void OnNetRegisterReply(SDNet.ReturnCode code, string res) { // net returned with a registration result if (code != SDNet.ReturnCode.OK) { simple_console_text += "\nERROR: " + res + "\n"; state = State.reg_window; } else { simple_console_text += "Complete. You may now login.\n"; state = State.login_window; } }
private void OnNetVersionReply(SDNet.ReturnCode code, string res) { // reply from server - version check if (code == SDNet.ReturnCode.OK) { simple_console_text += "Done.\n"; // check if correct version if (res != GamePHP.VER) { // if version incorrect you will want to show the player // some kind of message and perhaps link to the game's website simple_console_text += "The game must be updated.\nCurrent version: "+GamePHP.VER+", expected version: "+res+"\n"; } else { // version was fine. show the login window state = State.login_window; } } else { state = State.none; simple_console_text += "Failed: " + res + "\n"; } }
private void OnNetPlayerList(SDNet.ReturnCode code, string res) { if (code == SDNet.ReturnCode.OK && res.Length > 0) { Chat.Instance.players.Clear(); // decode message char[] splitter = { '|' }; string[] players = res.Split(splitter); splitter[0] = ','; foreach (string p in players) { if (string.IsNullOrEmpty(p)) continue; string[] v = p.Split(splitter); if (v.Length < 3) continue; int id = SDUtil.ParseInt(v[0], 0); if (id <= 0) continue; int status = SDUtil.ParseInt(v[1], 3); Chat.Instance.players.Add(new Chat.ChatPlayer(id, status, v[2])); } if (Chat.Instance.players.Count > 0) { // sort players Chat.Instance.players.Sort(delegate(Chat.ChatPlayer f1, Chat.ChatPlayer f2) { return f1.name.CompareTo(f2.name); }); } Chat.Instance.UpdateNamesCache(); } }
private void OnNetChatMessages(SDNet.ReturnCode code, string res) { GamePHP.Instance.Update_ChatMsgRefreshTimeout(true); // increase by default (will decr below if needed) message_refresh = Time.time; if (code == SDNet.ReturnCode.OK) { int chan_id = 0; char[] splitter = { '|' }; string[] msgs = res.Split(splitter); foreach (string m in msgs) { if (string.IsNullOrEmpty(m)) continue; GamePHP.Instance.Update_ChatMsgRefreshTimeout(false); // got a msg, dec wait time // check if it is a channel id if (m[0] == '*') { string sn = m.Substring(1); int num = SDUtil.ParseInt(sn, 0); if (num > 0) { // seems to be valid channel id // check if channel exist, if not, create it now Chat.ChannelInfo chan = Chat.Instance.Channel(num); if (chan == null) { CreateChatChannelGUI("pm-" + num, num, false); getChannelNames += "," + num; // will haveta ask server what the channel name is } chan_id = num; continue; } } Chat.Instance.AddMessage(chan_id, m); } } }
private void OnNetPmNames(SDNet.ReturnCode code, string res) { if (code == SDNet.ReturnCode.OK) { char[] splitter = { '|' }; string[] chans = res.Split(splitter); splitter[0] = ','; foreach (string c in chans) { if (string.IsNullOrEmpty(c)) continue; string[] vals = c.Split(splitter); if (vals.Length < 2) continue; int cid = SDUtil.ParseInt(vals[0], 0); if (cid > 0) { Chat.ChannelInfo cci = Chat.Instance.Channel(cid); if (cci != null) cci.name = vals[1]; } } } }
private void OnNetStartPm(SDNet.ReturnCode code, string res) { state = State.normal; if (code == SDNet.ReturnCode.OK) { int id = SDUtil.ParseInt(res, 0); if (id > 0) { CreateChatChannelGUI(nameInput, id, true); return; } } winMsg = "Could not find the player you wish to contact. The name must be 5 or more character in length. The search is not case sensitive but you must provide the correct and the complete name of the player to find."; state = State.msg; }
private void OnNetFriendDeleted(SDNet.ReturnCode code, string res) { friends_refresh = Time.time; // reset it now so refresh can be called again when needed state = State.normal; if (code == SDNet.ReturnCode.OK) { // not gonna make unnecessary refresh call so remove the active player from // list since it should be the one that was selected for removal Chat.Instance.friends.RemoveAt(selectedFriend); Chat.Instance.UpdateNamesCache(); selectedFriend = 0; } }
private void OnNetFriendAdded(SDNet.ReturnCode code, string res) { friends_refresh = Time.time; // reset it now so refresh can be called again when needed state = State.normal; if (code == SDNet.ReturnCode.OK) { // should find the new friend's name in reply, add him with 'unknown' status for now if (res.Length > 0) { string[] v = res.Split(new char[] { ',' }); if (v.Length > 1) { int id = SDUtil.ParseInt(v[0], 0); if (id > 0) { Chat.Instance.friends.Add(new Chat.ChatPlayer(id, 3, v[1])); Chat.Instance.UpdateNamesCache(); } } } return; } winMsg = "Could not find the player you wish to add. The name must be 5 or more character in length. The search is not case sensitive but you must provide the correct and the complete name of the player to find."; state = State.msg; }