Code: Select all
UserVariable uv_state = new SFSUserVariable("state", "waiting");
List<UserVariable> vars = Arrays.asList(uv_state);
getApi().setUserVariables(user, vars);
and at client, i try to get the state:
Code: Select all
void ConnectionTest::OnUserVarsUpdate(void* ptrContext, BaseEvent* ptrEvent)
{
vector<string>* changedVars = (vector<string>*)((*(ptrEvent->Params()))["changedVars"]);
User * user = (User*)((*(ptrEvent->Params()))["user"]);
string strBuffer = " user:" ;
strBuffer += user->Name()->c_str();
strBuffer += "change ";
for ( int i = 0 ; i < changedVars->size() ;i ++ )
{
strBuffer += " ";
strBuffer += changedVars->at(i);
strBuffer += ":";
string * strKey = new string(changedVars->at(i));
UserVariable * userVar = user->GetVariable(strKey);
if ( userVar != NULL )
strBuffer += userVar->GetStringValue()->c_str();
}
MessageBox(NULL,strBuffer.c_str(),"SmartFoxTest",MB_OK);
}
i can receive the callback, and "state" is in the changedVars, but i can not get the value in user, user->GetVariable return null.