public void UpdateHypothesis(string name, bool value, string label = null) { //Console.WriteLine("HYPOTHESIS: " + name + "=" + value + " (" + label + ")."); if (label == null) { label = name; } if (!value && activeHypothesis.ContainsKey(name)) { activeHypothesis.Remove(name); } else if (value) { activeHypothesis[name] = label; } string currentLabel = null; foreach (KeyValuePair <string, string> kvp in activeHypothesis) { currentLabel = kvp.Value; } //Console.WriteLine("HYPOTHESIS: " + currentLabel); CurrentHypothesis = currentLabel; ManagerEventArgs mea = new ManagerEventArgs(name, value, label); OnHypothesisChanged(mea); if (outStompConnection == null && !outStompAttempted) { try { outStompConnection = new StompConnection(outStompHost, outStompPort); } catch (Exception) { ; } outStompAttempted = true; } if (outStompConnection != null) { // Create JSON-encoded data Hashtable sourceData = new Hashtable(); sourceData.Add("name", name); sourceData.Add("value", value); string jsonData = Json.JsonEncode(sourceData); outStompConnection.Send(outStompTopic, jsonData); Console.WriteLine("Sent " + jsonData + " to " + outStompTopic); } else { //Console.WriteLine("FAILED to send to " + outStompTopic); } }
public override void SendPacket(T packet) { if (stompConnection != null) { string body = packetConverter.ToStomp(packet); string postfix = packetConverter.GetTopicPostfix(packet); string theTopic = topic; if (postfix != null && postfix.Length > 0) { theTopic += "." + postfix; } stompConnection.Send(theTopic, body); } }