Whatever message this page gives is out now! Go check it out!
name="websocketName"
onMessage="JavaScript function name"
onOpen="JavaScript function name"
onClose="JavaScript function name"
onError="JavaScript function name"
useCfAuth=true|false
subscribeTo="channel_list"
secure="true|false">Attribute | Req/Opt | Descriptions |
name | Required | The name of the WebSocket object. This is the reference to the JavaScript objects that are used to call WebSocket JavaScript functions. |
onMessage | Required | The JavaScript function that is called when the WebSocket receives a message from the server. It supports the argument, aEvent. This argument is the websocket event that is dispatched from the server. |
onOpen | Optional | The JavaScript function that is called when the WebSocket establishes a connection. |
onClose | Optional | The JavaScript function that is called when the WebSocket closes a connection. |
onError | Optional | The JavaScript function that is called if there is an error while performing an action over the WebSocket connection. |
usecfAuth | Optional | If set to true (default), users need not authenticate for WebSocket connection (provided they have already logged in to the application). This is the default value. If false, users have to specify the credentials for the WebSocket connection. |
subscribeTo | Optional | Comma-separated list of channels to subscribe to. You can specify any or all channels set in the Application.cfc. |
| secure | Optional | If true, the web socket communication will happen over SSL. |
{
this.name="websocketsampleapp1";
this.wschannels=[{name="stocks"}];
}<script type="text/javascript">
function mymessagehandler(aevent, atoken)
{
var message = ColdFusion.JSON.encode(atoken);
var txt=document.getElementById("myDiv");
txt.innerHTML +=message +"<br>";
}
</script>
<cfwebsocket name="mycfwebsocketobject" onmessage="mymessagehandler" subscribeto="stocks" >
<cfdiv id="myDiv"></cfdiv>