void Awake() { Application.runInBackground = true; // Let the application be running while the window is not active. // Create SmartFox connection if not already available if ( SmartFox.IsInitialized() ) { Debug.Log("SmartFox is already initialized, reusing connection"); smartFox = SmartFox.Connection; } else { if( Application.platform == RuntimePlatform.WindowsWebPlayer ) { // Only set this for the webplayer, it breaks pc standalone // See http://answers.unity3d.com/questions/25122/ for details Security.PrefetchSocketPolicy(serverIP, serverPort); } try { Debug.Log("Starting new SmartFoxClient"); smartFox = new SmartFoxClient(debug); smartFox.runInQueueMode = true; } catch ( Exception e ) { Debug.Log(e.ToString()); } } // Register callback delegates, before callling Connect() SFSEvent.onConnection += OnConnection; SFSEvent.onConnectionLost += OnConnectionLost; SFSEvent.onLogin += OnLogin; SFSEvent.onRoomListUpdate += OnRoomList; SFSEvent.onDebugMessage += OnDebugMessage; //SFSEvent.onJoinRoom += OnJoinRoom; // We will not join a room in this level Debug.Log("Attempting to connect to SmartFoxServer"); smartFox.Connect(serverIP, serverPort); }
void Awake() { Application.runInBackground = true; if ( SmartFox.IsInitialized() ) { smartFox = SmartFox.Connection; } else { try { smartFox = new SmartFoxClient(debug); smartFox.runInQueueMode = true; } catch ( Exception e ) { loginErrorMessage = e.ToString(); } } // Register callback delegate SFSEvent.onConnection += OnConnection; SFSEvent.onConnectionLost += OnConnectionLost; SFSEvent.onLogin += OnLogin; SFSEvent.onRoomListUpdate += OnRoomList; SFSEvent.onDebugMessage += OnDebugMessage; }
// We start working from here void Start() { Application.runInBackground = true; // Let the application be running whyle the window is not active. smartFoxClient = GetClient(); if (smartFoxClient==null) { //Application.LoadLevel("sc_Login"); return; } SubscribeEvents(); started = true; smartFoxClient.JoinRoom("Central Square"); }