public SendableObject(SmartFox conn, bool encrypt) { provider = EncryptionProvider.GetInstance(); sendEncrypted = encrypt; connection = conn; data = new SFSObject(); }
void OnConnection(BaseEvent evt) { bool connectionSuccess = (bool)evt.Params["success"]; Debug.Log("OnConn:" + connectionSuccess); if (connectionSuccess) { SFSObject loginData = new SFSObject(); loginData.PutUtfString("username", usernameField.value); loginData.PutUtfString("password", passwordField.value); sfs.Send(new Sfs2X.Requests.LoginRequest("", "", "MainZone", loginData)); connectionWindow.SetActive(false); loggingWindow.SetActive(true); } else { sfs = Connection.Instance().Reset(); SetupListeners(); loginWindow.SetActive(true); connectionWindow.SetActive(false); } }
void Start() { SFServer = SmartFoxConnection.Connection; this.PlayerRB = this.GetComponent<Rigidbody>(); this.MecAnim = this.GetComponentInChildren<Animator>(); theUI = (GameUI)FindObjectOfType(typeof(GameUI)); }
void Update() { if (sfs != null) { sfs.ProcessEvents(); if (localPlayer != null) { // Cast a line from player to isGrounded game object to tell if the player is on something or not // (removed player object from layer mask to avoid line cast with player coliders) localPlayerIsGrounded = true; // Get input for movement and jump move(CrossPlatformInputManager.GetAxisRaw("Horizontal")); if (CrossPlatformInputManager.GetButtonDown("Jump")) { jump(); } // Change between running and idle animation based on player velocity if (localPlayer.GetComponent <Rigidbody2D>().velocity.x == 0 && localPlayer.GetComponent <Rigidbody2D>().velocity.y == 0) { localPlayer.GetComponent <Animator>().SetBool("Running", false); } else { localPlayer.GetComponent <Animator>().SetBool("Running", true); } } } else if (SmartFoxConnection.IsInitialized) { sfs = SmartFoxConnection.Connection; } }
public PublicKeyMessage(SmartFox conn, EncryptionProvider provider) : base(conn, false) { packetName = "publickey"; data.PutSFSObject("key", new ClientPublicKey().ToSFSObject()); }
public void OnConnect() { if (_sfs != null) { return; } var cfg = new ConfigData { Host = _config.Host, Port = _config.Port, Zone = _config.ZoneName }; GD.Print("Connecting..."); _sfs = new SmartFox { ThreadSafeMode = false, Debug = true }; _sfs.AddEventListener(SFSEvent.CONNECTION, OnConnection); _sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost); _sfs.AddEventListener(SFSEvent.LOGIN, OnLogin); _sfs.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError); _sfs.AddEventListener(SFSEvent.ROOM_JOIN, OnRoomJoin); _sfs.AddEventListener(SFSEvent.ROOM_JOIN_ERROR, OnRoomJoinError); _sfs.AddEventListener(SFSEvent.LOGOUT, OnLogout); _sfs.Connect(cfg); }
public void run() { if (SmartFoxConnection.IsInitialized){ smartFox = SmartFoxConnection.Connection; currentActiveRoom = smartFox.LastJoinedRoom; } if(textura2d == null) textura2d = new Texture2D(320,240,TextureFormat.RGB24,false); textura2d.LoadImage(data); textura2d.Apply(); //if(currentActiveRoom.Name !="principal"){ if (window == null) window = GameObject.Find("VideoProcessor").GetComponent<VideoCallManagerWindow>(); window.setTexture(textura2d); //} //else{ // Debug.Log("en virtual scrum"); //if ((vid == null)) // vid = GameObject.Find("panel5").GetComponent<VirtualScrumVideo>(); //vid.updateData(textura2d); // } //mytext.texture = textura2d; //mytext.transform.localScale = new Vector3(-1,1,1); }
internal void AddListeners(SmartFox smartFox) { smartFox.AddEventListener(SFSEvent.SOCKET_ERROR, onSocketError); smartFox.AddEventListener(SFSEvent.CONNECTION, onConnection); smartFox.AddEventListener(SFSEvent.CONNECTION_LOST, onConnectionLost); smartFox.AddEventListener(SFSEvent.CRYPTO_INIT, onCryptoInit); smartFox.AddEventListener(SFSEvent.CONNECTION_RETRY, onConnectionRetry); smartFox.AddEventListener(SFSEvent.CONNECTION_RESUME, onConnectionResume); smartFox.AddEventListener(SFSEvent.LOGIN, onLogin); smartFox.AddEventListener(SFSEvent.UDP_INIT, onUdpInit); smartFox.AddEventListener(SFSEvent.LOGIN_ERROR, onLoginError); smartFox.AddEventListener(SFSEvent.LOGOUT, onLogout); smartFox.AddEventListener(SFSEvent.ROOM_CREATION_ERROR, onRoomCreationError); smartFox.AddEventListener(SFSEvent.ROOM_JOIN, onRoomJoin); smartFox.AddEventListener(SFSEvent.ROOM_JOIN_ERROR, onRoomJoinError); smartFox.AddEventListener(SFSEvent.EXTENSION_RESPONSE, onExtensionResponse); smartFox.AddEventListener(SFSEvent.USER_VARIABLES_UPDATE, onUserVariableUpdate); smartFox.AddEventListener(SFSEvent.PROXIMITY_LIST_UPDATE, onProximityListUpdate); smartFox.AddEventListener(SFSEvent.MMOITEM_VARIABLES_UPDATE, onServerObjectUpdate); smartFox.AddEventListener(SFSEvent.PING_PONG, onPingPong); if (smartFox.Debug) { smartFox.AddLogListener(LogLevel.DEBUG, onDebugMessage); smartFox.AddLogListener(LogLevel.INFO, onInfoMessage); smartFox.AddLogListener(LogLevel.WARN, onWarnMessage); smartFox.AddLogListener(LogLevel.ERROR, onErrorMessage); } }
public static void SendLoginRequest(this SmartFox smartfox, string username, string password, string zone) { if (!string.IsNullOrEmpty(zone)) { smartfox.Send(new LoginRequest(username, password, zone)); } }
//---------------------------------------------------------- // Unity calback methods //---------------------------------------------------------- void Start() { if (!SmartFoxConnection.IsInitialized) { SceneManager.LoadScene("Connection"); return; } sfs = SmartFoxConnection.Connection; // Register callback delegates sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost); sfs.AddEventListener(SFSEvent.USER_VARIABLES_UPDATE, OnUserVariableUpdate); sfs.AddEventListener(SFSEvent.PROXIMITY_LIST_UPDATE, OnProximityListUpdate); // Get random avatar and color and spawn player int numModel = UnityEngine.Random.Range(0, playerModels.Length); int numMaterial = UnityEngine.Random.Range(0, playerMaterials.Length); SpawnLocalPlayer(numModel, numMaterial); // Update settings panel with the selected model and material GameUI ui = GameObject.Find("UI").GetComponent("GameUI") as GameUI; ui.SetAvatarSelection(numModel); ui.SetColorSelection(numMaterial); }
//---------------------------------------------------------- // Called when program starts //---------------------------------------------------------- void Start() { smartFox = new SmartFox(); smartFox.AddEventListener(SFSEvent.CONNECTION, OnConnection); smartFox.AddLogListener(LogLevel.DEBUG, OnDebugMessage); smartFox.Connect(ip, port); }
//---------------------------------------------------------- // Unity calback methods //---------------------------------------------------------- void Awake() { Application.runInBackground = true; if (SmartFoxConnection.IsInitialized) { sfs = SmartFoxConnection.Connection; } else { SceneManager.LoadScene("Login"); return; } sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost); sfs.AddEventListener(SFSEvent.PUBLIC_MESSAGE, OnPublicMessage); sfs.AddEventListener(SFSEvent.USER_ENTER_ROOM, OnUserEnterRoom); sfs.AddEventListener(SFSEvent.USER_EXIT_ROOM, OnUserExitRoom); setCurrentGameState(GameState.WAITING_FOR_PLAYERS); // Create game logic controller instance trisGame = new TrisGame(); trisGame.InitGame(sfs); }
public void OnClickedLoginUsingUsername() { if (inputUsername.text == "") { return; } if (OverloadSFS.Instance.SFS.IsConnected == false) { OverloadSFS.Instance.Connect(); } sfs = OverloadSFS.Instance.SFS; if (sfs != null) { if (sfs.IsConnected) { DoLoginUsingUsername(inputUsername.text); } else { StartCoroutine(DoConnect(TypeLogin.USERNAME, inputUsername.text)); } } else { Debug.LogError("WTF???"); } }
// Start is called before the first frame update void Start() { Debug.Log(GetAdminToken()); token = PlayerPrefs.GetString("token", "No token found"); username = PlayerPrefs.GetString("username", "noUser"); if (SFS.getSFS() == null) { // Initialize SFS2X client. This can be done in an earlier scene instead SmartFox sfs = new SmartFox(); // For C# serialization DefaultSFSDataSerializer.RunningAssembly = Assembly.GetExecutingAssembly(); SFS.setSFS(sfs); Debug.Log("SFS was null. Setting it now"); } if (!SFS.IsConnected()) { SFS.Connect(username); Debug.Log("was not connected. Connecting now"); } HostGameButton.interactable = false; LaunchGameButton.interactable = false; NewGameButton.interactable = false; SavedSessionButtonA.interactable = false; SavedSessionButtonB.interactable = false; DeleteButton.interactable = false; DeleteSessionButton.interactable = false; // if(resetFields) { // SetFields(); // } GetSessions(); }
private ManagerDB() { if (SmartFoxConnection.IsInitialized) { smartFox = SmartFoxConnection.Connection; } }
//---------------------------------------------------------- // Called when program starts //---------------------------------------------------------- void Start() { // In a webplayer (or editor in webplayer mode) we need to setup security policy negotiation with the server first if (Application.isWebPlayer || Application.isEditor) { if (!Security.PrefetchSocketPolicy(serverName, serverPort, 500)) { Debug.LogError("Security Exception. Policy file loading failed!"); } } // Lets connect smartFox = new SmartFox(true); // Register callback delegate smartFox.AddEventListener(SFSEvent.CONNECTION, OnConnection); smartFox.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost); smartFox.AddEventListener(SFSEvent.LOGIN, OnLogin); smartFox.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError); smartFox.AddEventListener(SFSEvent.LOGOUT, OnLogout); smartFox.AddEventListener(SFSEvent.ROOM_JOIN, OnJoinRoom); smartFox.AddEventListener(SFSEvent.PUBLIC_MESSAGE, OnPublicMessage); smartFox.AddLogListener(LogLevel.DEBUG, OnDebugMessage); smartFox.Connect(serverName, serverPort); // var ipaddress = Network.player.ipAddress; // Debug.Log (ipaddress); }
private void Awake() { Application.runInBackground = true; if (SmartFoxConnection.IsInitialized) sfs = SmartFoxConnection.Connection; else { Application.LoadLevel("Login"); return; } //sfs.RemoveAllEventListeners(); Debug.Log("Login As: " + sfs.MySelf.Name); // Register event listeners sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost); sfs.AddEventListener(SFSEvent.PUBLIC_MESSAGE, OnPublicMessage); sfs.AddEventListener(SFSEvent.ROOM_JOIN, OnRoomJoin); sfs.AddEventListener(SFSEvent.ROOM_JOIN_ERROR, OnRoomJoinError); sfs.AddEventListener(SFSEvent.USER_ENTER_ROOM, OnUserEnterRoom); sfs.AddEventListener(SFSEvent.USER_EXIT_ROOM, OnUserExitRoom); sfs.AddEventListener(SFSEvent.ROOM_ADD, OnRoomAdded); sfs.AddEventListener(SFSEvent.ROOM_REMOVE, OnRoomRemoved); sfs.AddEventListener(SFSEvent.PLAYER_TO_SPECTATOR, OnSpectatorEnterRoom); sfs.AddEventListener(SFSEvent.PLAYER_TO_SPECTATOR_ERROR, OnSpectatorEnterRoomErro); // Join the Lobby Room (must exist in the Zone!) sfs.Send(new JoinRoomRequest("The Lobby")); }
void Awake() { Application.runInBackground = true; if (SmartFoxConnection.IsInitialized) { sfs = SmartFoxConnection.Connection; } else { SceneManager.LoadScene("Login"); return; } Debug.Log("Coming in lobby as " + sfs.MySelf.Name); loggedInText.text = "Logged in as " + sfs.MySelf.Name; // Register event listeners sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost); sfs.AddEventListener(SFSEvent.ROOM_JOIN, OnRoomJoin); sfs.AddEventListener(SFSEvent.ROOM_JOIN_ERROR, OnRoomJoinError); sfs.AddEventListener(SFSEvent.USER_ENTER_ROOM, OnUserEnterRoom); sfs.AddEventListener(SFSEvent.USER_EXIT_ROOM, OnUserExitRoom); sfs.AddEventListener(SFSEvent.ROOM_ADD, OnRoomAdded); sfs.AddEventListener(SFSEvent.ROOM_REMOVE, OnRoomRemoved); // Populate list of available games populateGamesList(); // Join the lobby Room (must exist in the Zone!) sfs.Send(new JoinRoomRequest("The Lobby")); }
void CheckInitialize() { if (sfs == null || !sfs.IsConnected) { sfs = new SmartFox (); isRunning = true; } }
//---------------------------------------------------------- // Unity calback methods //---------------------------------------------------------- void Awake() { Application.runInBackground = true; if (SmartFoxConnection.IsInitialized) { sfs = SmartFoxConnection.Connection; } else { SceneManager.LoadScene("Login"); return; } loggedInText.text = "Logged in as " + sfs.MySelf.Name; // Register event listeners sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost); sfs.AddEventListener(SFSEvent.PUBLIC_MESSAGE, OnPublicMessage); sfs.AddEventListener(SFSEvent.ROOM_JOIN, OnRoomJoin); sfs.AddEventListener(SFSEvent.ROOM_JOIN_ERROR, OnRoomJoinError); sfs.AddEventListener(SFSEvent.USER_ENTER_ROOM, OnUserEnterRoom); sfs.AddEventListener(SFSEvent.USER_EXIT_ROOM, OnUserExitRoom); sfs.AddEventListener(SFSEvent.ROOM_ADD, OnRoomAdded); sfs.AddEventListener(SFSEvent.ROOM_REMOVE, OnRoomRemoved); // Populate list of available games populateGamesList(); // Disable chat controls until the lobby Room is joined successfully chatControls.interactable = false; // Join the lobby Room (must exist in the Zone!) sfs.Send(new JoinRoomRequest("The Lobby")); }
//---------------------------------------------------------- // Public interface methods for UI //---------------------------------------------------------- public void OnLoginButtonClick() { enableLoginUI(false); // Set connection parameters ConfigData cfg = new ConfigData(); cfg.Host = Host; cfg.Port = TcpPort; cfg.Zone = Zone; cfg.UdpHost = Host; cfg.UdpPort = UdpPort; // Initialize SFS2X client and add listeners sfs = new SmartFox(); sfs.AddEventListener(SFSEvent.CONNECTION, OnConnection); sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost); sfs.AddEventListener(SFSEvent.LOGIN, OnLogin); sfs.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError); sfs.AddEventListener(SFSEvent.UDP_INIT, OnUdpInit); // Connect to SFS2X sfs.Connect(cfg); }
public override void Execute(SmartFox sfs) { List <int> list = new List <int>(); foreach (object invitedUser in invitedUsers) { if (invitedUser is User) { if (invitedUser as User != sfs.MySelf) { list.Add((invitedUser as User).Id); } } else if (invitedUser is Buddy) { list.Add((invitedUser as Buddy).Id); } } sfso.PutIntArray(KEY_INVITED_USERS, list.ToArray()); sfso.PutShort(KEY_TIME, (short)secondsForAnswer); if (parameters != null) { sfso.PutSFSObject(KEY_PARAMS, parameters); } }
void ClickConnect() { _connectButton.interactable = true; ConfigData cfg = new ConfigData(); cfg.Host = HostIp; #if !UNITY_WEBGL cfg.Port = TcpPort; #else cfg.Port = WsPort; #endif cfg.Zone = ZoneName; #if !UNITY_WEBGL _smartFoxServer = new SmartFox(); #else _smartFoxServer = new SmartFox(UseWebSocket.WS); #endif _smartFoxServer.ThreadSafeMode = true; _smartFoxServer.AddEventListener(SFSEvent.CONNECTION, OnConnection); _smartFoxServer.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost); _smartFoxServer.AddEventListener(SFSEvent.LOGIN, OnLogin); _smartFoxServer.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError); _smartFoxServer.Connect(cfg); DebugConsole.Log("Connecting..."); }
//---------------------------------------------------------- // Public interface methods for UI //---------------------------------------------------------- public void JoinZone() { // Set connection parameters ConfigData cfg = new ConfigData(); cfg.Host = Host; #if !UNITY_WEBGL cfg.Port = TcpPort; #else cfg.Port = WSPort; #endif cfg.Zone = Zone; // Initialize SFS2X client and add listeners #if !UNITY_WEBGL sfs = new SmartFox(); #else sfs = new SmartFox(UseWebSocket.WS); #endif cfg.Debug = true; // Set ThreadSafeMode explicitly, or Windows Store builds will get a wrong default value (false) sfs.ThreadSafeMode = true; sfs.AddEventListener(SFSEvent.CONNECTION, OnConnection); sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost); sfs.AddEventListener(SFSEvent.LOGIN, OnLogin); sfs.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError); // Connect to SFS2X sfs.Connect(cfg); }
public void InitSmartfox() { if (Application.isWebPlayer || Application.isEditor) { bool flag = Security.PrefetchSocketPolicy(serverName, serverPort); Logger.trace("[NetworkManager::InitSmartfox] securityPolicyPassed: " + flag); } if (SmartFoxConnection.IsInitialized) { Debug.Log("<< is initialized"); smartFox = SmartFoxConnection.Connection; } else { bool debug = true; Debug.Log("<< initializing smartfox"); smartFox = new SmartFox(debug); } GameObject x = GameObject.Find("Game"); if (x != null) { } smartFox.AddLogListener(LogLevel.INFO, OnDebugMessage); m_state = null; }
//---------------------------------------------------------- // Public interface methods for UI //---------------------------------------------------------- public void OnLoginButtonClick() { enableLoginUI(false); // Set connection parameters ConfigData cfg = new ConfigData(); cfg.Host = Host; #if !UNITY_WEBGL cfg.Port = TcpPort; #else cfg.Port = WSPort; #endif cfg.Zone = Zone; // Initialize SFS2X client and add listeners #if !UNITY_WEBGL sfs = new SmartFox(); #else sfs = new SmartFox(UseWebSocket.WS_BIN); #endif sfs.AddEventListener(SFSEvent.CONNECTION, OnConnection); sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost); sfs.AddEventListener(SFSEvent.LOGIN, OnLogin); sfs.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError); sfs.AddEventListener(SFSEvent.ROOM_JOIN, OnRoomJoin); sfs.AddEventListener(SFSEvent.ROOM_JOIN_ERROR, OnRoomJoinError); // Connect to SFS2X sfs.Connect(cfg); }
private void Start() { m_isConnected = false; m_isLoggedIn = false; m_isInRoom = false; m_serviceSet = false; m_qTime = 20; smartFox = null; if (true) { mServerMode = ServerMode.director; } else { serverName = CN_INTERNAL; mServerMode = ServerMode.single; } if (mServerMode == ServerMode.single) { InitSmartfox(); } else { AskDirector(); } }
public override void Execute(SmartFox sfs) { if (room != null) { sfso.PutInt(KEY_ROOM_ID, room.Id); } }
void Start() { //Start up connection if (SmartFoxConnection.Connection == null) { SceneManager.LoadScene("Login"); return; } SFServer = SmartFoxConnection.Connection; // Setup server event listeners SFServer.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost); SFServer.AddEventListener(SFSEvent.EXTENSION_RESPONSE, OnExtensionResponse); //Setup sub-managers ourUserInterface = new UIManager(this); ourGameManager = new GameManager(this); //Setup player actions playerActionDictionary.Add("EnterChat", new EnterChatAction()); //Setup server response handlers ourSRHDictionary.Add("EnterChat", new EnterChatHandler()); ourSRHDictionary.Add("PlayerConnected", new PlayerConnectedHandler()); ourSRHDictionary.Add("PlayerDisconnected", new PlayerDisconnectedHandler()); ourSRHDictionary.Add("OnlinePlayers", new OnlinePlayersHandler()); ourSRHDictionary.Add("EditFormation", new EditFormationHandler()); ourSRHDictionary.Add("GetFormation", new GetFormationHandler()); ourSRHDictionary.Add("NewGame", new NewGameHandler()); ourSRHDictionary.Add("SpawnUnit", new SpawnUnitHandler()); //Send a request to get the OnlinePlayers SFServer.Send(new ExtensionRequest("OnlinePlayers", new SFSObject())); }
public void OnClickedLoginAsGuest() { if (OverloadSFS.Instance.SFS.IsConnected == false) { OverloadSFS.Instance.Connect(); } sfs = OverloadSFS.Instance.SFS; if (sfs != null) { if (sfs.IsConnected) { DoLoginAsGuest(); } else { StartCoroutine(DoConnect(TypeLogin.GUESS)); } } else { Debug.LogError("WTF???"); } }
}//end extension private void reset() { // Remove SFS2X listeners sfs.RemoveAllEventListeners(); sfs = null; }
// Use this for initialization void Start() { LoginPanel = GameObject.Find("LoginBox"); RegisterPanel = GameObject.Find("RegisterBox"); RegisterPanel.SetActive(false); MessageText = GameObject.Find("MessageText"); MessageText.SetActive(false); UsernameTB = GameObject.Find("UsernameTB").GetComponent <InputField>(); PasswordTB = GameObject.Find("PasswordTB").GetComponent <InputField>(); UsernameTB.Select(); SFServer = new SmartFox(); //Set our basic default connection parameters this.OurConfigData.Host = "biele.us"; this.OurConfigData.Port = 9933; this.OurConfigData.Zone = GAME_ZONE; // Set ThreadSafeMode explicitly, or Windows Store builds will get a wrong default value (false) SFServer.ThreadSafeMode = true; SFServer.AddEventListener(SFSEvent.CONNECTION, OnConnection); SFServer.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost); SFServer.AddEventListener(SFSEvent.LOGIN, OnLogin); SFServer.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError); SFServer.AddEventListener(SFSEvent.EXTENSION_RESPONSE, OnExtensionResponse); SFServer.Connect(this.OurConfigData); }
public override void Validate(SmartFox sfs) { List <string> list = new List <string>(); if (pos == null) { list.Add("Position must be a valid Vec3D "); } if (room == null) { room = sfs.LastJoinedRoom; } if (room == null) { list.Add("You are not joined in any room"); } if (!(room is MMORoom)) { list.Add("Selected Room is not an MMORoom"); } if (list.Count > 0) { throw new SFSValidationError("SetUserVariables request error", list); } }
//---------------------------------------------------------- // Public interface methods for UI //---------------------------------------------------------- public void OnActivateAccountButtonClicked() { activation = Activation.text; if (activation == "" || activation == " ") { TextMessage.text = "Missing to fill required value"; } else { // Enable interface enableInterface(false); #if UNITY_WEBGL { sfs = new SmartFox(UseWebSocket.WS); ServerPort = defaultWsPort; } #else { sfs = new SmartFox(); ServerPort = defaultTcpPort; } #endif sfs.ThreadSafeMode = true; sfs.AddEventListener(SFSEvent.CONNECTION, OnConnection); sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost); sfs.AddEventListener(SFSEvent.LOGIN, OnLogin); sfs.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError); sfs.AddEventListener(SFSEvent.EXTENSION_RESPONSE, OnExtensionResponse); sfs.Connect(ServerIP, ServerPort); } }
// get smartfox goin again private void Awake() { // need to look up what this even does Application.runInBackground = true; if (SmartFoxConnection.IsInitialized) { sfs = SmartFoxConnection.Connection; } else { SceneManager.LoadScene("main"); return; } sfs.ThreadSafeMode = true; sfs.AddEventListener(SFSEvent.OBJECT_MESSAGE, OnObjectMessage); sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost); sfs.AddEventListener(SFSEvent.USER_VARIABLES_UPDATE, OnUserVariableUpdate); sfs.AddEventListener(SFSEvent.USER_ENTER_ROOM, OnUserEnterRoom); sfs.AddEventListener(SFSEvent.USER_EXIT_ROOM, OnUserExitRoom); sfs.AddEventListener(SFSEvent.PUBLIC_MESSAGE, OnPublicMessage); // spawn the player SpawnLocalPlayer(); // update ui here in the future for color stuff }
void Awake() { Application.runInBackground = true; if ( SmartFoxConnection.IsInitialized ) { smartFox = SmartFoxConnection.Connection; } else { Application.LoadLevel("login"); return; } // Register callbacks smartFox.AddEventListener(SFSEvent.LOGOUT, OnLogout); smartFox.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost); smartFox.AddEventListener(SFSEvent.PUBLIC_MESSAGE, OnPublicMessage); smartFox.AddEventListener(SFSEvent.ROOM_JOIN, OnJoinRoom); smartFox.AddEventListener(SFSEvent.ROOM_CREATION_ERROR, OnCreateRoomError); smartFox.AddEventListener(SFSEvent.USER_ENTER_ROOM, OnUserEnterRoom); smartFox.AddEventListener(SFSEvent.USER_EXIT_ROOM, OnUserLeaveRoom); smartFox.AddEventListener(SFSEvent.ROOM_ADD, OnRoomAdded); smartFox.AddEventListener(SFSEvent.ROOM_REMOVE, OnRoomDeleted); chatWindow = new ChatWindow(20, 110, Screen.width-250, Screen.height-150); // Lets update internal API room list that might have changed while we played a game SetupRoomList(); started = true; }
public void RegisButtonClick() { enableLoginUI(false); // Set connection parameters Sfs2X.Util.ConfigData cfg = new ConfigData(); cfg.Host = Host; cfg.Port = TcpPort; cfg.Zone = Zone; cfg.UdpHost = Host; cfg.UdpPort = UdpPort; // Initialize SFS2X client and add listeners sfs = new SmartFox(); // Set ThreadSafeMode explicitly, or Windows Store builds will get a wrong default value (false) sfs.ThreadSafeMode = true; sfs.AddEventListener(SFSEvent.CONNECTION, OnConnection); sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost); sfs.AddEventListener(SFSEvent.LOGIN, OnLogin); sfs.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError); sfs.AddEventListener(SFSEvent.UDP_INIT, OnUdpInit); sfs.AddEventListener(SFSEvent.EXTENSION_RESPONSE, OnExtensionResponse); // Connect to SFS2X sfs.Connect(cfg); }
void Awake() { if (Instance == null) { Instance = this; } else if (Instance != this) { Destroy(gameObject); } Application.runInBackground = true; if (SmartFoxConnection.IsInitialized) { sfs = SmartFoxConnection.Connection; InitGame(); } else { //no point starting the game, need to relogin Debug.Log("sfs is null!!"); SceneManager.LoadScene("Login"); return; } }
public void startSmartfox() { sfs = new SmartFox(); // Set ThreadSafeMode explicitly, or Windows Store builds will get a wrong default value (false) sfs.ThreadSafeMode = true; // SmartFox Event listeners sfs.AddEventListener(SFSEvent.CONNECTION, connectionHandler); sfs.AddEventListener(SFSEvent.CONNECTION_LOST, connectionLostHandler); sfs.AddEventListener(SFSEvent.CONFIG_LOAD_SUCCESS, configLoadHandler); sfs.AddEventListener(SFSEvent.CONFIG_LOAD_FAILURE, configLoadFailHandler); sfs.AddEventListener(SFSEvent.LOGIN, loginHandler); sfs.AddEventListener(SFSEvent.LOGIN_ERROR, loginErrorHandler); sfs.AddEventListener(SFSEvent.ROOM_ADD, roomAddHandler); sfs.AddEventListener(SFSEvent.ROOM_CREATION_ERROR, roomCreationErrorHandler); sfs.AddEventListener(SFSEvent.ROOM_JOIN, roomJoinHandler); sfs.AddEventListener(SFSEvent.ROOM_JOIN_ERROR, roomJoinErrorHandler); serverIP = inputField.text; if (UseConfigFile) { sfs.LoadConfig(Application.dataPath + "/Resources/sfs-config.xml", true); } else { sfs.Connect(serverIP, serverPort); } popUp.SetActive(false); }
public override void Validate(SmartFox sfs) { List <string> list = new List <string>(); if (isSearchListRoom) { if (whereToSearchRoom == null || whereToSearchRoom.Count < 1) { list.Add("Missing whereToSearch parameter"); } else if (whereToSearchRoom.Count > MAX_ROOMS) { list.Add("Too many Rooms specified in the whereToSearch parameter. Client limit is: " + MAX_ROOMS); } } if (isSearchListString) { if (whereToSearchString == null || whereToSearchString.Count < 1) { list.Add("Missing whereToSearch parameter"); } else if (whereToSearchString.Count > MAX_ROOMS) { list.Add("Too many Rooms specified in the whereToSearch parameter. Client limit is: " + MAX_ROOMS); } } if (list.Count > 0) { throw new SFSValidationError("QuickJoinGame request error", list); } }
public void Setup(SmartFox client , SFSUser user) { if (!user.IsItMe) { mobileStickController.enabled = false; userControllder2D.enabled = false; } }
public CreateCharacterMessage(SmartFox conn, bool encrypt, string characterName, string sex, string characterClass) : base(conn, encrypt) { packetName = "createCharacter"; PutString(data, "characterName", characterName); PutString(data, "sex", sex); PutString(data, "characterClass", characterClass); }
private SFSClient( ) { SFSInstance = new SmartFox ( debug ); Application.runInBackground = true; RegisterCallbacks (); SFSInstance.AddLogListener ( logLevel, OnDebugMessage ); }
void Start() { SFServer = SmartFoxConnection.Connection; this.PlayerRB = this.GetComponent<Rigidbody>(); crosshairTransform = Camera.main.transform.parent; this.MecAnim = this.GetComponentInChildren<Animator>(); this.ourLPC = this.GetComponentInParent<LocalPlayerController>(); theUI = (GameUI)FindObjectOfType(typeof(GameUI)); }
public ChatWindow() { posX = 0; posY = 0; this.width = 100; this.height = 100; chatWindow = new Rect(posX, posY, this.width, this.height); smartFox = SmartFoxConnection.Connection; SetStyle(); }
public ChatWindow(int x, int y, int width, int height) { posX = x; posY = y; this.width = width; this.height = height; chatWindow = new Rect(posX, posY, this.width, this.height); smartFox = SmartFoxConnection.Connection; SetStyle(); }
void Start() { smartFox = SmartFoxConnection.Connection; if (smartFox == null) { Debug.Log ("not connected to server"); return; } // SubscribeDelegates(); // TimeManager.Instance.Init(); }
public RoomVariableManager(SmartFox smf, Room car ) { smartFox = smf; currentActiveRoom = smartFox.LastJoinedRoom; smartFox.AddEventListener(SFSEvent.ROOM_VARIABLES_UPDATE, conectionListChange); conectionsList = new List<GUIContent>(); updateConectionsList(); currentName = smartFox.MySelf.Name; SFSExtensionManager extensionManager=SFSExtensionManager.getInstance(); extensionManager.sendRequest(new ExtensionRequest("getIP", new SFSObject()), "getIpResponse", getIPResponse); }
public static bool IsLowestID(SmartFox smartFox) { int lowestUserID = int.MaxValue; int myID = smartFox.MySelf.GetPlayerId(smartFox.LastJoinedRoom); foreach (User u in smartFox.LastJoinedRoom.UserList) { int userIDToCheck = u.GetPlayerId(smartFox.LastJoinedRoom); if (userIDToCheck < lowestUserID) lowestUserID = userIDToCheck; } return myID == lowestUserID; }
public LoginMessage(SmartFox conn, bool encrypt, string username, string password) : base(conn, encrypt) { packetName = "login"; SFSObject tr = new SFSObject(); PutString(tr, "user", username); PutString(tr, "password", password); data.PutSFSObject("login", tr); }
void Start () { // get the current smartfox connection smartFox = SmartFoxConnection.Connection; // log an error and just quit the script if no smartfox connection if(smartFox == null){ Debug.Log ("MEUIChatBox - Init Failed: There was no smartfox connection."); return; } //smartFox.AddEventListener(SFSEvent.PUBLIC_MESSAGE, OnPublicMessage); }
void OnConnectionLost(BaseEvent evt) { string reason = evt.Params["reason"] as string; print("Connection lost: " + reason); sfs = Connection.Instance().Reset(); SetupListeners(); loginWindow.SetActive(true); loggingWindow.SetActive(false); connectionWindow.SetActive(false); }
// Use this for initialization void Start() { smartFox = SmartFoxConnection.Connection; smartFox.AddEventListener(SFSEvent.EXTENSION_RESPONSE, OnExtensionResponse); if (smartFox == null) { Application.LoadLevel("The Lobby"); return; } string nombre = "salaP"; ISFSObject obj = new SFSObject (); obj.PutUtfString ("nombre", nombre); ExtensionRequest request = new ExtensionRequest("crearSalaVS", obj); // True flag = UDP smartFox.Send (request); }
/** * Initialize the game. */ public void InitGame(SmartFox smartFox) { // Register to SmartFox events sfs = smartFox; sfs.AddEventListener(SFSEvent.EXTENSION_RESPONSE, OnExtensionResponse); timer = new MyTimer(); // Setup my properties myPlayerID = sfs.MySelf.PlayerId; // Reset game board ResetGameBoard(); // Tell extension I'm ready to play sfs.Send(new ExtensionRequest("ready", new SFSObject(), sfs.LastJoinedRoom)); }
// Use this for initialization void Start() { me = this; if (!Statici.multigiocatoreOn) return; Application.runInBackground = true; if (!SmartFoxConnection.NonNulla) { SceneManager.LoadScene("ScenaZero"); return; } sfs = SmartFoxConnection.Connection; sfs.ThreadSafeMode = true; sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost); }
/// <summary> /// Método que recria a instância do SmartFox. É necessário ser chamado sempre que o cliente perde a conexão com o servidor. Em modo de /// debug essa instância também redireciona as mensagens do log para o console da Unity. /// </summary> /// <returns>A instância do SmartFox.</returns> public SmartFox Reset() { if (sfs != null) sfs.RemoveAllEventListeners(); #if DEBUG sfs = new SmartFox(true); sfs.Logger.LoggingLevel = LogLevel.INFO; sfs.AddLogListener(LogLevel.INFO, OnInfoMessage); sfs.AddLogListener(LogLevel.WARN, OnWarnMessage); sfs.AddLogListener(LogLevel.ERROR, OnErrorMessage); #else sfs = new SmartFox(false); #endif return sfs; }
protected void Awake() { handlers = new Dictionary<string, IMessageHandler>(); Application.runInBackground = true; if (SmartFoxConnection.IsInitialized) { smartFox = SmartFoxConnection.Connection; } else { smartFox = new SmartFox(debug); } // Create encryption provider provider = EncryptionProvider.GetInstance(); smartFox.AddEventListener(SFSEvent.EXTENSION_RESPONSE, OnExtensionResponse); }
private void Awake() { Application.runInBackground = true; if (SmartFoxConnection.IsInitialized) sfs = SmartFoxConnection.Connection; else { Application.LoadLevel("Login"); return; } sfs.RemoveAllEventListeners(); // Register event listeners sfs.AddEventListener(SFSEvent.EXTENSION_RESPONSE, OnExtensionReponse); OnStartGame(); }
public SmartFoxConnector() { Debug.Log("SmartFoxInterface init"); _smartFox = new SmartFox(); _smartFox.Debug = true; _smartFox.AddEventListener(SFSEvent.CONNECTION, OnConnection); _smartFox.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost); _smartFox.AddEventListener(SFSEvent.LOGIN, OnLogin); _smartFox.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError); _smartFox.AddEventListener(SFSEvent.ROOM_VARIABLES_UPDATE, OnRoomVariableUpdate); _smartFox.AddEventListener(SFSEvent.ROOM_JOIN, OnRoomJoin); _smartFox.AddEventListener(SFSEvent.ROOM_JOIN_ERROR, OnRoomJoinError); _smartFox.AddEventListener(SFSEvent.USER_ENTER_ROOM, OnUserEnterRoom); _smartFox.AddEventListener(SFSEvent.USER_EXIT_ROOM, OnUserExitRoom); _smartFox.AddEventListener(SFSEvent.ROOM_ADD, OnRoomAdd); _smartFox.AddEventListener(SFSEvent.ROOM_CREATION_ERROR, OnRoomAddError); _smartFox.AddEventListener(SFSEvent.PUBLIC_MESSAGE, OnPublicMessage); }