private void _GetModelsAndSessionDetails () { string SessionDetailsString; #if UNITY_WEBGL && !UNITY_EDITOR if (useEditorModelsList) { #if DEVELOPMENT_BUILD //in dev builds, don't clear models list Debug.LogWarning("Using editor's model list. You should turn off 'Use Editor Models List' off in NetworkManager."); #else //in non-dev build, ignore the flag. modelData.models.Clear(); #endif SessionDetailsString = SocketIOEditorSimulator.GetSessionDetails(); } else { modelData.models.Clear(); SessionDetailsString = SocketIOJSLib.GetSessionDetails(); } if (System.String.IsNullOrEmpty(SessionDetailsString)) { Debug.Log("Error: Details are null or empty."); } else { Debug.Log("SessionDetails: " + SessionDetailsString); var details = JsonUtility.FromJson<SessionDetails>(SessionDetailsString); if (useEditorModelsList) { #if DEVELOPMENT_BUILD //in dev builds, don't pass details to the models list if the flag is enabled. Debug.LogWarning("Using editor's model list. You should turn off 'Use Editor Models List' off in NetworkManager."); #else //in non-dev build, ignore the flag. modelData.models = details.assets; #endif } else { modelData.models = details.assets; } if (sessionName != null) { sessionName = details.session_name; buildName = details.build; } else { Debug.LogError("SessionName Ref in NetworkUpdateHandler's Text Component is missing from editor"); } } #endif }
private void _GetParams () { #if UNITY_WEBGL && !UNITY_EDITOR client_id = SocketIOJSLib.GetClientIdFromBrowser(); session_id = SocketIOJSLib.GetSessionIdFromBrowser(); isTeacher = SocketIOJSLib.GetIsTeacherFlagFromBrowser(); #else client_id = SocketSim.GetClientIdFromBrowser(); session_id = SocketSim.GetSessionIdFromBrowser(); isTeacher = SocketSim.GetIsTeacherFlagFromBrowser(); #endif }
public void CloseChatConnection() { int result; #if UNITY_WEBGL && !UNITY_EDITOR result = SocketIOJSLib.CloseChatConnection(); #else result = socketSim.CloseChatConnection(); #endif if (result != SocketIOJSLib.SUCCESS) { connectionAdapter.DisplaySocketIOAdapterError("CloseChatConnection failed."); } }
public void SendStateCatchUpRequest() { int result; #if UNITY_WEBGL && !UNITY_EDITOR result = SocketIOJSLib.SendStateCatchUpRequest(); #else result = socketSim.SendStateCatchUpRequest(); #endif if (result != SocketIOJSLib.SUCCESS) { connectionAdapter.DisplaySocketIOAdapterError("SendStateCatchUpRequest failed."); } }
public void LeaveSyncSession() { int result; #if UNITY_WEBGL && !UNITY_EDITOR result = SocketIOJSLib.LeaveSyncSession(); #else result = socketSim.LeaveSyncSession(); #endif if (result != SocketIOJSLib.SUCCESS) { connectionAdapter.DisplaySocketIOAdapterError("LeaveSyncSession failed."); } }
public void SetChatEventListeners() { int result; #if UNITY_WEBGL && !UNITY_EDITOR result = SocketIOJSLib.SetChatEventListeners(); #else result = socketSim.SetChatEventListeners(); #endif if (result != SocketIOJSLib.SUCCESS) { connectionAdapter.DisplaySocketIOAdapterError("SetChatEventListeners failed."); } }
// Set the window.socketIOAdapterName variable in JS so that SendMessage calls in jslib are guaranteed to talk to the gameObject that has this script on it. public void SetName() { #if !UNITY_EDITOR && UNITY_WEBGL string nameOnWindow = SocketIOJSLib.SetSocketIOAdapterName(gameObject.name); #else string nameOnWindow = SocketIOEditorSimulator.Instance.SetSocketIOAdapterName(gameObject.name); #endif if (nameOnWindow != gameObject.name) { Debug.LogError($"SocketIOAdapter: window.socketIOAdapterName: Expected: {gameObject.name}, Actual: {nameOnWindow}"); connectionAdapter.DisplaySocketIOAdapterError($"window.socketIOAdapterName: Expected: {gameObject.name}, Actual: {nameOnWindow}"); } }
public void Send() { #if UNITY_WEBGL && !UNITY_EDITOR SocketIOJSLib.BrowserEmitMessage(this.type, this.data); #else var socketSim = SocketIOEditorSimulator.Instance; if (!socketSim) { Debug.LogWarning("No SocketIOEditorSimulator found"); } socketSim.BrowserEmitMessage(this.type, this.data); #endif }
public string GetPlayerNameFromClientID(int clientID) { #if UNITY_WEBGL && !UNITY_EDITOR string SessionDetailsString = SocketIOJSLib.GetSessionDetails(); #else string SessionDetailsString = SocketIOEditorSimulator.GetSessionDetails(); #endif var Details = JsonUtility.FromJson<SessionDetails>(SessionDetailsString); foreach (User user in Details.users) { if (clientID != user.student_id) { continue; } return user.first_name + " " + user.last_name; } return "Client " + clientID; }