/* WS */ public ScarletMetrics() { metricsws = new WebSocket("ws://" + MetricsWSURL + ":" + MetricsWSPort); metricsws.Connect(); metricsws.OnOpen += (sender, e) => { // Metrics - On Connection to the Metrics WS Reporting Server // Need to include username / IP in here as well. JsonObject jsonMessage = new JsonObject() .add("type", "metrics") .add("message", "connected"); metricsws.Send(jsonMessage.ToString()); }; metricsws.OnMessage += (sender, e) => { }; metricsws.OnClose += (sender, e ) => metricsws.Connect(); metricsws.OnError += (sender, e) => metricsws.Connect(); }
/// <summary> /// Set a reference. /// </summary> /// <param name="statement">GUID identifying the statement</param> /// <param name="snaks">The snaks to set the reference to. Array with property ids pointing to arrays containing the snaks for that property</param> /// <param name="reference">A hash of the reference that should be updated. When not provided, a new reference is created</param> /// <param name="baseRevisionId">The numeric identifier for the revision to base the modification on</param> /// <param name="summary">The summary for the change</param> /// <returns>The result</returns> internal JsonObject setReference(string statement, JsonObject snaks, string reference, int baseRevisionId, string summary) { Dictionary<string, string> parameters = new Dictionary<string, string>() { { "action", "wbsetreference" }, { "statement", statement }, { "snaks", snaks.ToString() } }; if (reference != null) { parameters["reference"] = reference; } return this.editAction(parameters, new Dictionary<string, string>(), baseRevisionId, summary); }
/// <summary> /// Create an entity. /// </summary> /// <param name="type">The type of the entity</param> /// <param name="data">The serialized data of the entity</param> /// <param name="baseRevisionId">The numeric identifier for the revision to base the modification on</param> /// <param name="summary">The summary for the change</param> /// <returns>The result</returns> internal JsonObject createEntity(string type, JsonObject data, int baseRevisionId, string summary) { Dictionary<string, string> parameters = new Dictionary<string, string>() { { "action", "wbeditentity" } }; Dictionary<string, string> postFields = new Dictionary<string, string>() { { "data", data.ToString() }, { "new", type } }; return this.editAction(parameters, postFields, baseRevisionId, summary); }
public void Send(string message) { JsonObject jsonMessage = new JsonObject(); jsonMessage.add("type", "metrics").add("message", message); metricsws.Send(jsonMessage.ToString()); }