FusionCharts for Flex > Creating Widgets > Real-Time Capabilities > Message Logger > Streaming Messages from Server

In this section, we'll see the data format required to stream messages from server to the client. Each real time update of the gauge can contain 1 message to be added to the logger. The following attributes in the real-time data stream help you to do so:

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.

 
Attribute Name Type Description
msgId String This attribute lets you specify an ID for each message - it is useful when you're tracking messages in your custom JavaScript function and need to refer to this ID to take actions. This ID is NOT displayed in the logger window. It's just passed to the JavaScript function.
msgTitle String The string title of the message that gets displayed in the message logger window can also be passed to JavaScript functions.
msgText String The actual text of the message that gets displayed in the message logger window can also be passed to JavaScript functions.
msgType String

This attribute lets you specify a type for each message streamed. Basically, each type gets rendered using a different text style in the logger for instant interpretation.

Possible values are INFO, ERROR, LITERAL, or LINK. INFO is shown in normal font properties, whereas ERROR is highlighted in a shade of red. LITERALS are shown in code like blocks, whereas LINK serves as a clickable link.

msgGoesToLog Boolean (0/1) For each message streamed from the server, you can control whether to log it in the visible message logger of gauge. By default, this attribute takes its value from messageGoesToLog attribute defined for <chart> element.
msgGoesToJS Boolean (0/1) Additionally, for each message, you can also specify whether this message should be passed to JavaScript handler. By default, this attribute takes its value from messageGoesToJS attribute of <chart> element.
clearLog Boolean (0/1) When you want to clear the message history in the currently showing gauge, you can return this parameter as part of data stream with a value of 1.
 
Examples of real-time update

Shown below is an example of real-time update string passed by server to the message logger (contained in an angular gauge 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 gauge for data update. Thereafter, we've the msgTitle and msgText parameters, which get absorbed by the message logger. Here, we have set a title - "OS update at 12:28" and text - "Operating system update downloaded automatically. Installation in-process. Reboot due in 8 minutes".

When a gauge (with message logger set as on) accepts this data stream, it will be displayed as shown below:

Note: If you're passing any special characters as part of your message text or title (like &, % etc.), you need to URLEncode the text/title.

 

Changing Message Type

As we had discussed earlier, 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 gauge reads this, it'll display the message as shown below:

 
If a message type as Literal, it will display the message as shown below:
 
Creating messages with link

If you want to display a message as link, set msgText of that message as the entire link (URL-Encoded) and msgType to LINK.

Shown below is a simple example of creating messages with link:

&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).

While specifying a link message type, the link itself is displayed as the message text. You cannnot change the message text.

This will yield the following output:

 
Linking custom text

If you want 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 need to output the HTML code for link as msgText. Add <U> tag in HTML code, if you need to underline the link. Finally, URLEncode the entire msgText parameter and then stream to the gauge.

Shown below is a simple example of linking custom text:

&label=11%3A02%3A56+AM&value=23|54&msgTitle=Test Linked Message&msgText=%3CA+HREF%3D%27
http%3A%2F%2Fwww%2Efusioncharts%2Ecom%3Fid%3D
34%27%3E%3CU%3EServer+Alert+Id%3A+33456%2E+Temperature+of+zone+1+
exceeded+pre%2Dset+threshold+1%2E%3C%2FU%3E%3C%2FA%3E&msgType=INFO

In simpler form (i.e., before URL Encoding), this stream reads as shown below:

&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 view this in the gauge, you'll get the following result:

 
Clearing Message Logger from server

From the server, you can instruct the gauge 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 clears all the contents of the existing message logger and start afresh.

Note: If you send &clearLog=1 with each real-time update, the gauge wouldn't display 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.