Hello people of earth!
While exploring the C++ API, I couldn't help but notice the target action paradigm that was adopted by the API to implement callbacks. As far as I can tell, this gives a lot of flexibility and loose coupling for components, but in return, it's fragile and requires a precise management to get things through.
OK, so what?
Well, I was wondering if the delegation pattern would be a better fit for the API, especially with the recent adoption of the smart pointers. Arguably, the biggest headache in the delegation pattern is the properly holding a reference to the callback object and properly releasing the memory when it's over. Well, this burden can be carried by the smart pointers now! Needless to day, other great benefits of this pattern is the well defined interface it will introduce between the API and the code base.
The reason I took the effort to write this is because I really love smartfox more than any other alternative, and I am here to watch it evolve. It's also because I was having trouble sending a class method as a callback function, actually. Then I realized I had to send a pure function's pointer, and use that to call the context's method or something, which just made me remember the time I dealt with hooking C++ with ObjC, but those are two different languages, of course.
Anyways, I just wanted to throw this here and maybe it sticks, maybe not. The least I am hoping for is to start a healthy community discussion to learn a few things about designing APIs.
Best,
- Board index SmartFoxServer 2X SFS2X Client API SFS2X C++ API
- Search
-
- It is currently 11 Feb 2026, 06:10
- All times are UTC
Delegates vs target/action
Post here your questions about the C++ API for SFS2X
Moderators: Lapo, Bax, MBagnati
Jump to
- SmartFoxServer 2X
- ↳ SFS2X Questions
- ↳ SFS2X Client API
- ↳ SFS2X ActionScript 3 API
- ↳ SFS2X C# API
- ↳ SFS2X iPhone / iPad / OSX API
- ↳ SFS2X Java / Android API
- ↳ SFS2X HTML5 / JavaScript API
- ↳ SFS2X C++ API
- ↳ RedBox 2X
- ↳ 2X Features Wish List
- SmartFoxServer Pro/Basic 1.x
- ↳ SmartFoxServer 1.x Discussions and Help
- ↳ Server Side Extension Development
- ↳ BlueBox
- ↳ RedBox
- ↳ Features Wish List
- ↳ The Bug Trap
- ↳ Client API - SFS 1.x
- ↳ .Net / Unity3D API
- ↳ iPhone Objective-C API
- ↳ Silverlight API
- ↳ Java2SE / Android Client API
- ↳ Other Client API
- OpenSpace Support
- ↳ OpenSpace v2 discussions and help
- ↳ OpenSpace v1 discussions and help
- SmartFoxBits Support
- ↳ SmartFoxBits for SFS 2X
- ↳ SmartFoxBits for SFS 1.x
- Community
- ↳ Job offers and requests
- ↳ The Gallery