Code: Select all
KeyNotFoundException: The given key was not present in the dictionary.
System.Collections.Generic.Dictionary`2[System.String,Sfs2X.Entities.Variables.UserVariable].get_Item (System.String key) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:150)
Sfs2X.Entities.SFSUser.GetVariable (System.String name)
SFSManager.OnUserVarsUpdate (Sfs2X.Core.BaseEvent evt) (at Assets/Scripts/Multiplayer/SFSManager.cs:930)
Sfs2X.Core.EventDispatcher.DispatchEvent (Sfs2X.Core.BaseEvent evt)
Rethrow as Exception: Error dispatching event userVariablesUpdate: The given key was not present in the dictionary. at System.Collections.Generic.Dictionary`2[System.String,Sfs2X.Entities.Variables.UserVariable].get_Item (System.String key) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:150)
Sfs2X.Entities.SFSUser.GetVariable (System.String name)
SFSManager.OnUserVarsUpdate (Sfs2X.Core.BaseEvent evt) (at Assets/Scripts/Multiplayer/SFSManager.cs:930)
Sfs2X.Core.EventDispatcher.DispatchEvent (Sfs2X.Core.BaseEvent evt)
Sfs2X.Core.EventDispatcher.DispatchEvent (Sfs2X.Core.BaseEvent evt)
Sfs2X.SmartFox.ProcessEvents ()
SFSManager.ProcessEvents () (at Assets/Scripts/Multiplayer/SFSManager.cs:72)
The offending code is simply:
Code: Select all
if(user.ContainsVariable(key) )
{
UserVariable newVar = user.GetVariable(key); //actual error line (930)
changedVarsDict[key] = newVar.Value;
}
The documentation for this function says that it should return null if the variable does not exist, not create an exception. In addition,the variable should exist since the key we are trying to get comes directly from the changedVars parameter sent from the OnUserVarsUpdate callback AND because we have already checked the value with ContainsVariable.
For now I have managed to work around this issue by handling the failure more gracefully, but it would be nice if this could be fixed.