/** * Sends 1-3 parameter strings to the docent remote to serve as acceptable defaults. This provides an opportunity * for a game administrator to custom tailor the game experience to the current audience. Each game should document * what parameters they are able to accept and what effect those parameters will have so an administrator will know * what to expect of their inputs. * * @param parameter1 the first string option * @param parameter2 the optional second string option * @param parameter3 the optional third string option * @return TRUE if successfully sent, FALSE otherwise */ public bool SubmitParameterStrings(string parameter1, string parameter2 = "", string parameter3 = "") { bool eventSent = false; if (GameInterface.isConnected()) { // LoadSave.savedData.Add (Time.time.ToString () + " : SubmitParameterStrings \n"); string options = API_KEYWORD_APPLY_PARAMS + "param1=" + parameter1 + ",param2=" + parameter2 + ",param3=" + parameter3; if (0 != GameInterface.dispatchEvent(KEYWORD_DOCENT, options)) { Debug.LogWarning("parameter strings message delivery failed."); } else { eventSent = true; } } else { Debug.LogWarning("game not yet connected"); } return(eventSent); }
/** * Handles docent connection messages that occur during each frame update. * * @see Esc.ServerConnection */ public new void Update() { // Read games plist every once second if (GameInterface.isConnected()) { if (cumulativeTime > CHECK_GAMES_LIST_INTERVAL) { cumulativeTime = 0.0f; ReadGamesPlist(); } else { cumulativeTime += Time.deltaTime; } } // Dispatch heartbeat ping to Medialon system if necessary if (medialonTime > MEDIALON_PING_INTERVAL) { medialonTime = 0.0f; DispatchMedialonPing(); } else { medialonTime += Time.deltaTime; } // Reconnect if necessary if (this.willReconnect) { this.willReconnect = false; GameInterface.startLauncherInterface(); } while (GameInterface.hasMoreStatusChanges()) { int stat; if (0 == GameInterface.getNextStatusChange(out stat)) { switch (stat) { case 0: // connected //GameInterface.writeLog("socket connection established"); break; case 1: // TLS connected break; case 2: // disconnected if (null != OnDisconnected) { OnDisconnected(); } if (this.autoReconnect) { willReconnect = true; } break; case 3: // roster loaded; if (null != OnConnected) { OnConnected(); } break; case 4: // error break; default: break; } } } while (GameInterface.hasMoreEvents()) { StringBuilder user = new StringBuilder(64); StringBuilder message = new StringBuilder(256); if (user == null || user.Capacity == null || message == null || message.Capacity == null) { return; } if (0 == GameInterface.getNextEvent(user, (uint)user.Capacity, message, (uint)message.Capacity)) { string username = user.ToString(); string msgString = message.ToString(); if (username.Equals("docent")) { if (msgString.StartsWith(API_KEYWORD_GAME)) { EscEvent evt = EscEvent.FromString(msgString); //Debug.Log("message: " + msgString); string gameIdValue = ""; string option = ""; int round = -1; int difficulty = -1; //! advance settings strings int mode1 = -1; int mode2 = -1; int mode3 = -1; string param1 = ""; string param2 = ""; string param3 = ""; foreach (KeyValuePair <string, string> pair in evt.attributes) { switch (pair.Key) { case "game": gameIdValue = pair.Value; break; case "option": option = pair.Value; break; case "round": round = Convert.ToInt32(pair.Value); break; case "difficulty": difficulty = Convert.ToInt32(pair.Value); break; case "mode1": mode1 = Convert.ToInt32(pair.Value); break; case "mode2": mode2 = Convert.ToInt32(pair.Value); break; case "mode3": mode3 = Convert.ToInt32(pair.Value); break; case "param1": param1 = pair.Value; break; case "param2": param2 = pair.Value; break; case "param3": param3 = pair.Value; break; } } switch (option) { case "load": if (!this.currentLoadedGame.Equals("")) { DocentQuitGame(this.currentLoadedGame); } this.currentLoadedGame = gameIdValue; DocentLoadGame(gameIdValue); break; case "start": DocentStartGame(gameIdValue, round, difficulty); break; case "pause": DocentPauseGame(gameIdValue); break; case "stop": DocentStopGame(gameIdValue); break; case "apply": DocentApplyAdvancedSettings(gameIdValue, mode1, mode2, mode3, param1, param2, param3); break; case "quit": DocentQuitGame(gameIdValue); break; } } else if (msgString.StartsWith(API_KEYWORD_INIT)) { UpdateDocentGamesList(); } } } } }
//! Returns indication of the Esc-Unity-Plugin connection to the XMPP server. public bool IsConnected() { return(GameInterface.isConnected()); }