public VariableSpaceDispatcher() { EventHandlers["ocw:varSpace:create"] += new Action <int, dynamic>(async(space, dataMap) => { var varSpace = new VariableSpace(space); ms_variableSpaces[space] = varSpace; var dictionary = dataMap as IDictionary <string, object>; Debug.WriteLine("variable space {0} created (map is {1}, dict is {2})", space, dataMap.GetType().Name, dictionary); if (dictionary != null) { foreach (var kvp in dictionary) { Debug.WriteLine("setting {0} in space {1} to {2}", kvp.Key, space, kvp.Value); await varSpace.SetValueNoSync(kvp.Key, kvp.Value); } } }); EventHandlers["ocw:varSpace:set"] += new Action <int, string, dynamic>((space, key, value) => { // get the variable space requested VariableSpace varSpace; if (ms_variableSpaces.TryGetValue(space, out varSpace)) { Debug.WriteLine("setting {0} in space {1} to {2}", key, space, value); varSpace.SetValueNoSync(key, value); } }); EventHandlers["onClientGameTypeStart"] += new Action <string>(a => { TriggerServerEvent("ocw:varSpace:resync"); }); Tick += VariableSpaceDispatcher_Tick; }
public VariableSpaceDispatcher() { EventHandlers["ocw:varSpace:create"] += new Action<int, dynamic>(async (space, dataMap) => { var varSpace = new VariableSpace(space); ms_variableSpaces[space] = varSpace; var dictionary = dataMap as IDictionary<string, object>; Debug.WriteLine("variable space {0} created (map is {1}, dict is {2})", space, dataMap.GetType().Name, dictionary); if (dictionary != null) { foreach (var kvp in dictionary) { Debug.WriteLine("setting {0} in space {1} to {2}", kvp.Key, space,kvp.Value); await varSpace.SetValueNoSync(kvp.Key, kvp.Value); } } }); EventHandlers["ocw:varSpace:set"] += new Action<int, string, dynamic>((space, key, value) => { // get the variable space requested VariableSpace varSpace; if (ms_variableSpaces.TryGetValue(space, out varSpace)) { Debug.WriteLine("setting {0} in space {1} to {2}", key, space, value); varSpace.SetValueNoSync(key, value); } }); EventHandlers["onClientGameTypeStart"] += new Action<string>(a => { TriggerServerEvent("ocw:varSpace:resync"); }); Tick += VariableSpaceDispatcher_Tick; }