[UPDATE] New Client API update
[UPDATE] New Client API update
We have just released a small update for all our client API, which addresses the caching of UserVariables when users enter and leave multiple Rooms. A recent bug submission has pointed to a specific situation in which a UserVariable would remain in the cache, potentially wasting some memory.
You can read more in the related support forum discussion:
https://forums.smartfoxserver.com/v ... 18&t=31191
And download the latest release from our API Download page:
https://www.smartfoxserver.com/download/sfs2x#p=client
Cheers
You can read more in the related support forum discussion:
https://forums.smartfoxserver.com/v ... 18&t=31191
And download the latest release from our API Download page:
https://www.smartfoxserver.com/download/sfs2x#p=client
Cheers
Re: [UPDATE] New Client API update
I am trying to get the updated Api for IOS/Objective C. It says there is a version 1.8.4 but the download is giving me 1.7.15.
I have downloaded the Smartfoxserver 2_19_1.dmg and the patch 2.20.3 and this is the code files I am trying to use. I have commented ou the errors and files that are not working.
Bridging-Header.h
I have downloaded the Smartfoxserver 2_19_1.dmg and the patch 2.20.3 and this is the code files I am trying to use. I have commented ou the errors and files that are not working.
Bridging-Header.h
Code: Select all
#import <CFNetwork/CFNetwork.h>
#import <QuartzCore/QuartzCore.h>
#import <Security/Security.h>
#import <SFS2XAPIIOS/SmartFox2XClient.h>
//#import <SFS2XAPIIOS/SmartFox2XClient.h>
#import <SFS2XAPIIOS/SFSEvent.h>
#import <SFS2XAPIIOS/ISFSEvents.h>
//#import <SFS2XAPIIOS/SFSConfig.h>
#import <SFS2XAPIIOS/ConfigData.h> //Trial file to connect
#import <SFS2XAPIIOS/SFSObject.h>
#import <SFS2XAPIIOS/LoginRequest.h>
#import <SFS2XAPIIOS/ExtensionRequest.h>
#import <SFS2XAPIIOS/JoinRoomRequest.h>
import Foundation
final class SmartFoxManager: NSObject, ObservableObject, ISFSEvents {
static let shared = SmartFoxManager()
@Published var isConnected = false
@Published var isLoggedIn = false
@Published var lastError: String?
private var sfs: SmartFox2XClient?
// MARK: - Connect
func connect(host: String = "127.0.0.1",
port: Int32 = 9933,
zone: String = "BasicExamples",
debug: Bool = true) {
// Build config
let cfg = ConfigData() //SFSConfig()
cfg.host = host
cfg.port = port //Cannot assign Int32 to Int
cfg.zone = zone //Cannot assign a value: 'zone' is a method
cfg.debug = debug
// Create client
sfs = SmartFox2XClient(config: cfg, delegate: self) //Cannot convert value of type ConfigData to expected type Bool
sfs?.connect()
}
// MARK: - Login
func login(username: String, password: String? = nil) {
guard let sfs = sfs, sfs.isConnected else { return }
let req = LoginRequest(userName: username, password: password, zoneName: nil, params: nil)
sfs.send(req)
}
// MARK: - Send extension command example
func sendExtension(cmd: String, params: [String: Any]) {
guard let sfs = sfs, sfs.isConnected else { return }
let obj = SFSObject()
params.forEach { key, value in
switch value {
case let v as Int: obj.putInt(key, value: Int(Int32(v)))
case let v as Bool: obj.putBool(key, value: v)
case let v as String: obj.putUtfString(key, value: v)
default: break
}
}
let req = ExtensionRequest()
sfs.send(req)
}
}
// MARK: - ISFSEventDelegate
extension SmartFoxManager: ISFSEventDelegate { //Cannot find ISFSEventDelegate
func dispatch(_ evt: SFSEvent!) {
guard let evt = evt else { return }
switch evt.type {
case SFSEvent.CONNECTION: //SFSEvent has no member CONNECTION
let success = evt.params?["success"] as? Bool ?? false
DispatchQueue.main.async {
self.isConnected = success
}
print("SFS Connection:", success)
case SFSEvent.CONNECTION_LOST: //SFSEvent has no member CONNECTION_LOST
let reason = evt.params?["reason"] as? String
DispatchQueue.main.async {
self.isConnected = false
self.isLoggedIn = false
self.lastError = reason
}
print("SFS Disconnected. Reason:", reason ?? "unknown")
case SFSEvent.LOGIN: //SFSEvent has no member LOGIN
DispatchQueue.main.async {
self.isLoggedIn = true
}
print("SFS Login OK")
case SFSEvent.LOGIN_ERROR: //SFSEvent has no member LOGIN_ERROR
let errorMsg = evt.params?["errorMessage"] as? String ?? "unknown"
DispatchQueue.main.async {
self.isLoggedIn = false
self.lastError = errorMsg
}
print("SFS Login error:", errorMsg)
case SFSEvent.EXTENSION_RESPONSE: //SFSEvent has no member EXTENSION_RESPONSE
if let cmd = evt.params?["cmd"] as? String,
let data = evt.params?["params"] as? ISFSObject {
print("EXT RESP:", cmd, data)
// Parse your response here
}
default:
// Handle more events as you need (ROOM_JOIN, USER_ENTER_ROOM, PUBLIC_MESSAGE, etc.)
break
}
}
}Re: [UPDATE] New Client API update
Hi Scott,
This unfortunately looks like of those AI spam posts... but I'll give you the benefit of the doubt
There is no such thing as version 1.8.4 for the Objective-C API. The latest is 1.7.15 as you will find in the relative download page: https://www.smartfoxserver.com/download#p=client
You can convert the value to an Int or declare the port parameter as Int instead.
use setZone("SomeValue")
Because the constructor signature is as follows:
You should use this instead:
You will find the event names as constants such as:
SFSEvent_CONNECTION
SFSEvent_LOGIN
SFSEvent_LOGOUT
etc...
Cheers
scott1224 wrote:I am trying to get the updated Api for IOS/Objective C. It says there is a version 1.8.4 but the download is giving me 1.7.15.
This unfortunately looks like of those AI spam posts... but I'll give you the benefit of the doubt
There is no such thing as version 1.8.4 for the Objective-C API. The latest is 1.7.15 as you will find in the relative download page: https://www.smartfoxserver.com/download#p=client
//Cannot assign Int32 to Int
You can convert the value to an Int or declare the port parameter as Int instead.
//Cannot assign a value: 'zone' is a method
use setZone("SomeValue")
//Cannot convert value of type ConfigData to expected type Bool
Because the constructor signature is as follows:
Code: Select all
SmartFox2XClient(smartFoxWithDebugMode: true, delegate: self)You should use this instead:
Code: Select all
sfs = SmartFox2XClient(smartFoxWithDebugMode: true, delegate: self)
sfs?.connect(withConfig: cfg);//SFSEvent has no member CONNECTION
You will find the event names as constants such as:
SFSEvent_CONNECTION
SFSEvent_LOGIN
SFSEvent_LOGOUT
etc...
Cheers
Re: [UPDATE] New Client API update
Thanks for the reply. I asked because the download page says it was upgraded.
I just updated my account and I will try again next week.
What is the difference between SFS2XAPIIOS.xcframework and SFS2XAPIOSX.framework?
I am going to start with the first one.
I just updated my account and I will try again next week.
What is the difference between SFS2XAPIIOS.xcframework and SFS2XAPIOSX.framework?
I am going to start with the first one.
Re: [UPDATE] New Client API update
SFS2XAPIIOS.xcframework is for developing apps for iOS (iPhone/iPad/Catalyst)
SFS2XAPIOSX.framework is for developing apps for MacOS
Cheers
SFS2XAPIOSX.framework is for developing apps for MacOS
Cheers
Re: [UPDATE] New Client API update
Thanks lol. I do see that now.
I see the files but the files are hidden or empty. IOS finds nothing there
I started with IOS and moved to server access.
Server works but doesn't connect to zone BasicExample
I am back to IOS and failed again
I will try again tonight
I see the files but the files are hidden or empty. IOS finds nothing there
I started with IOS and moved to server access.
Server works but doesn't connect to zone BasicExample
I am back to IOS and failed again
I will try again tonight
Re: [UPDATE] New Client API update
I see the files but the files are hidden or empty. IOS finds nothing there
I am not sure what you're referring to.
I would recommend to follow the documentation to setup an iOS project in XCode with the SFS2X API:
https://docs2x.smartfoxserver.com/Getti ... t-api-objc
Cheers
Re: [UPDATE] New Client API update
Thanks for the document link,
I have been able to get some of the files working via the bridgingheader file. Next step is to make a connection.
Thanks again.
I have been able to get some of the files working via the bridgingheader file. Next step is to make a connection.
Thanks again.