Message Logger > Streaming messages from server |
||||||||||||||||||||||||
Here, we'll see the data format required to stream messages from server to the client. Each real time update of the chart can contain 1 message to be added to the logger. The following attributes in the real-time data stream help you do so: Please note that the messages to be logged should be provided in the real-time data stream and not the XML document. Real-time data stream refers to the data provided by the URL specified in dataStreamURL attribute. |
||||||||||||||||||||||||
|
||||||||||||||||||||||||
Examples of real-time update | ||||||||||||||||||||||||
Shown below is an example of real-time update string passed by server to the message logger (contained in a line chart in this example): &label=10%3A44%3A15+AM&value=23|54&msgTitle=OS update at 12:28&msgText=Operating system update downloaded automatically. Installation in-process. Reboot due in 8 minutes. Here, we first have the &label and &value parameters which are absorbed by the chart for data update. Thereafter, we've the msgTitle and msgText parameters which get absorbed by the message logger. Here, we've set a title of "OS update at 12:28" and text of "Operating system update downloaded automatically. Installation in-process. Reboot due in 8 minutes. " When a chart (with message logger set as on) accepts this data stream, it will show the following: |
||||||||||||||||||||||||
Note: If you're passing any special characters as part of your message text or title (like &, % etc.), you'll need to URL Encode the text/title.
|
||||||||||||||||||||||||
Changing Message Type | ||||||||||||||||||||||||
As we had earlier discussed, you can choose a message type for each message as INFO, ERROR, LITERAL or LINK. This helps your end users easily recognize the type of each message Shown below is a simple example using message type as error: &label=10%3A48%3A28+AM&value=23|54&msgTitle=Alert at 12:24&msgText=Server Alert Id: 33456. Temperature of zone 1 exceeded pre-set threshold 1.&msgType=ERROR When a chart reads this, it'll display the message as under: |
||||||||||||||||||||||||
And, for a message type as Literal, it will show the message as under: | ||||||||||||||||||||||||
Creating messages with link | ||||||||||||||||||||||||
If you want to show a message as link, just set msgText of that message as the entire link (URL Encoded) and msgType to LINK. Example: &label=10%3A59%3A44+AM&value=23|54&msgTitle=Test Link&msgText=http%3A%2F%2Fwww%2Efusioncharts%2Ecom%3Fid%3D34&msgType=LINK In the above example, we're linking the message to http://www.fusioncharts.com?id=34 - we've URL Encoded the link, as it contains special characters (? in this case). When specifying a link message type, the link itself is shown as the message text. You cannnot change the message text. This will yield the following output: |
||||||||||||||||||||||||
Linking custom text | ||||||||||||||||||||||||
If you have a need to show your own text as message and then link it, there's a work-around. Set msgType to INFO and provide the entire link in HTML code as part of msgText. To specify a link, you'll need to output the HTML code for link as msgText. Add the <U> tag in HTML code if you need to underline the link. Finally, URLEncode the entire msgText parameter and then stream to the chart. Example: &label=11%3A02%3A56+AM&value=23|54&msgTitle=Test Linked Message&msgText=%3CA+HREF%3D%27 In simpler form (i.e., before URL Encoding), this stream reads as under: &label=11%3A02%3A56+AM&value=23|54&msgTitle=Test Linked Message&msgText=<A HREF='http://www.fusioncharts.com?id=34'><U>Server Alert Id: 33456. Temperature of zone 1 exceeded pre-set threshold 1.</U></A>&msgType=INFO When you see this in the chart, you'll get the following result: |
||||||||||||||||||||||||
Clearing Message Logger from server | ||||||||||||||||||||||||
From the server, you can instruct the chart to clear the contents of visible message logger by sending the following command: &clearLog=1 It can be sent as a part of message stream like &label=10%3A48%3A28+AM&value=23|54&msgTitle=Alert at 12:24&msgText=Server Alert Id: 33456. Temperature of zone 1 exceeded pre-set threshold 1.&msgType=ERROR&clearLog=1 This will clear all the contents of the existing message logger and start afresh. Note: If you send &clearLog=1 with each real-time update, the chart wouldn't show any messages in the logger, as the log is being cleared with each update. As such, take caution to send this command only when log needs to be cleared. Additionally, you can also clear the message logger using client side JavaScript API, which we'll see in next section. |
||||||||||||||||||||||||
Next we'll see how messages can be handled in JavaScript functions. |