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 void Connect() { if (!isLoadConfig) { ConfigData data = new ConfigData(); data.Port = PORT; data.Zone = ZONE; data.Host = HOST; data.Debug = false; sfs.Connect(data); } else { string path = Consts.SMARTFOX_CONFIG; sfs.LoadConfig(path); } }
void Start() { sfs = new SmartFox(); sfs.ThreadSafeMode = true; sfs.AddEventListener(SFSEvent.CONNECTION, OnConnection); sfs.AddEventListener(SFSEvent.LOGIN, OnLogin); sfs.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError); sfs.AddEventListener(SFSEvent.CONFIG_LOAD_SUCCESS, OnConfigLoad); sfs.AddEventListener(SFSEvent.CONFIG_LOAD_FAILURE, OnConfigFail); sfs.AddEventListener(SFSEvent.ROOM_JOIN, OnJoinRoom); sfs.AddEventListener(SFSEvent.ROOM_JOIN_ERROR, OnJoinRoomError); sfs.AddEventListener(SFSEvent.PUBLIC_MESSAGE, OnPublicMessage); if (UseConfigFile) { sfs.LoadConfig(Application.dataPath + "/" + ConfigFile); } else { sfs.Connect(ServerIP, ServerPort); } }
// Use this for initialization void Start() { _sfs = new SmartFox(); _sfs.ThreadSafeMode = true; _sfs.AddEventListener(SFSEvent.CONNECTION , OnConnection); _sfs.AddEventListener(SFSEvent.LOGIN, OnLogin); _sfs.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError); _sfs.AddEventListener(SFSEvent.CONFIG_LOAD_SUCCESS, OnConfigLoad); _sfs.AddEventListener(SFSEvent.CONFIG_LOAD_FAILURE, OnConfigFail); _sfs.AddEventListener(SFSEvent.ROOM_JOIN, OnJoinRoom); _sfs.AddEventListener(SFSEvent.ROOM_JOIN_ERROR, OnJoinRoomError); _sfs.AddEventListener(SFSEvent.PUBLIC_MESSAGE, OnPublicMessage); _sfs.AddEventListener(SFSEvent.EXTENSION_RESPONSE, OnSumResponse); Security.PrefetchSocketPolicy(serverIp,serverPort); if(useConfigFile) _sfs.LoadConfig(Application.dataPath + "/" + configFile); else _sfs.Connect(serverIp,serverPort); }