protected void DispatchEvent(JObject theEvent) { string eventName = (string)theEvent["event"]; switch (eventName) { case "OnVariableValueChanged": { JArray jVariables = (JArray)theEvent["variables"]; VariableValue[] variables = StdJson.ObjectFromJToken <VariableValue[]>(jVariables); listener.OnVariableValueChanged(variables); } break; case "OnVariableHistoryChanged": { JArray jChanges = (JArray)theEvent["changes"]; HistoryChange[] variables = StdJson.ObjectFromJToken <HistoryChange[]>(jChanges); listener.OnVariableHistoryChanged(variables); } break; case "OnConfigChanged": { JArray jChanges = (JArray)theEvent["changedObjects"]; ObjectRef[] changes = StdJson.ObjectFromJToken <ObjectRef[]>(jChanges); listener.OnConfigChanged(changes); } break; case "OnAlarmOrEvent": { AlarmOrEvent alarmOrEvent = StdJson.ObjectFromJToken <AlarmOrEvent>(theEvent["alarmOrEvent"]); listener.OnAlarmOrEvent(alarmOrEvent); } break; default: Console.Error.WriteLine("Unknown event: " + eventName); break; } }