Error in SmartFox::SetClientDetails
Posted: 13 Aug 2014, 15:23
Hi!
This is code from SmartFox.cpp:
And this is quote from documentation http://www.cplusplus.com/reference/string/string/replace/ :
As you can see, method replace (iterator i1, iterator i2, size_t n, char c) has "fill" semantics, so after execution clientDetails is white-space string delimited by CLIENT_TYPE_SEPARATOR. And I doubt that this behaviour is expected.
Further, I think that this code is copy-paste from C# version, because documentation http://docs2x.smartfoxserver.com/api-docs/cpp-doc/class_sfs2_x_1_1_smart_fox.html#ad2d91706f3ce9ccafbba9fb352bcfe70 contains "Unity":
but in SmartFox.cpp:
This is code from SmartFox.cpp:
Code: Select all
clientDetails = boost::shared_ptr<string>(new string(platformId != NULL ? platformId->replace(platformId->begin(), platformId->end(), CLIENT_TYPE_SEPARATOR, ' ') : ""));
*clientDetails += CLIENT_TYPE_SEPARATOR;
clientDetails->append(version != NULL ? version->replace(version->begin(), version->end(), CLIENT_TYPE_SEPARATOR, ' ') : "");
And this is quote from documentation http://www.cplusplus.com/reference/string/string/replace/ :
Code: Select all
fill (5) string& replace (iterator i1, iterator i2, size_t n, char c);
(5) fill Replaces the portion of the string by n consecutive copies of character c.
As you can see, method replace (iterator i1, iterator i2, size_t n, char c) has "fill" semantics, so after execution clientDetails is white-space string delimited by CLIENT_TYPE_SEPARATOR. And I doubt that this behaviour is expected.
Further, I think that this code is copy-paste from C# version, because documentation http://docs2x.smartfoxserver.com/api-docs/cpp-doc/class_sfs2_x_1_1_smart_fox.html#ad2d91706f3ce9ccafbba9fb352bcfe70 contains "Unity":
By default the generic "Unity" label is used as platform, without specifying the version.
but in SmartFox.cpp:
Code: Select all
clientDetails = boost::shared_ptr<string>(new string("C++ API"));