BoxLang 🚀 A New JVM Dynamic Language Learn More...
AdvancedSockets aims to help handling connectivity issues from the client side when using ColdFusion's WebSockets.
Below is a simple example of how to implement. The data attributes defined in the body are the default values and do not have to be set but can be overridden. For more information on how and where they are set refer to the Attributes / Properties section.
<body data-auto-connect = "true"
data-name = "ws"
data-channels = "channelname"
data-debug = "true"
data-do-message = "doMessage"
data-online-timer = "30"
data-offline-timer = "5"
data-reconnect-timer = ".5"
data-ping-url = "/ping/">
<div id="status-message"></div>
<cfwebsocket name = "ws"
onMessage = "AdvancedSocket.onMessage"
onOpen = "AdvancedSocket.onOpen"
onClose = "AdvancedSocket.onClose"
onError = "AdvancedSocket.onError">
<invalidTag src="dist/advancedsocket.min.js"></script>
<invalidTag>
function doMessage( obj ){
console.log( obj );
}
</script>
</body>
true
but can be managed by the
data-auto-connect
attribute in the body tag. It also
requires a pingURL to be defined.false
but can be managed by the
data-api-lookup
attribute in the body tag.ip-api.com
but can be managed by the
data-api-service
attribute in the body tag. Please
note, this only allows for either ip-api.com or
ipapi.com. At the current moment
ip-api.com does not require a key as HTTPS calls
are not enabled. Once we support this feature, then an API Key will
be required. ipapi.com does allow for HTTPS requests.[!IMPORTANT] Please review the sites for these services for more information.
data-api-key
attribute in the body tag. Currently, this
is only required for ipapi.com.ws
but can be managed by the data-name
attribute in the body tag.data-channels
attribute in the body tag.doMessage
. If the function is not defined
or does not exists a log message will be displayed (if debug is
enabled).doMessage
but can be managed
by the data-do-message
attribute in the body tag.data-ping-url
attribute in
the body tag.30 seconds
but
can be managed by the data-online-timer
attribute in
the body tag.5 seconds
but
can be managed by the data-offline-timer
attribute in
the body tag.FORCE-RECONNECT
value is received from the server.500ms
but can be managed by the
data-reconnect-timer
attribute in the body tag.false
but can be managed by the data-debug
attribute in the body tag.status-message
but can
be managed by the data-status-label
attribute in the
body tag.AdvancedSocket
with options
defined in the body's data attributes.ping()
call if
autoConnect
is enabled.CFWebSocketWrapper.closeConnection()
and
CFWebSocketWrapper.openConnection()
which execute
onOpen()
when the socket is open again.clientInfo.geo
.application/json
response as follows:{ "success" : true|false }
FORCE-RECONNECT
messages fires the
forceReconnect()
based on the
reconnectCount
and forwards the message to the Global
Function defined in the options.window.setTimeout
CFWebSocketWrapper.subscribe()
function for each.CFWebSocketWrapper
]CFWebSocketWrapper
]CFWebSocketWrapper
]reqType
. If none match, it routes to
processMessage()
. welcome
connecting()
authenticate
processAuthentication()
subscribe
connected()
CFWebSocketWrapper
]CFWebSocketWrapper.authenticate()
function if not
passes to the getIPInfo()
if feature enabled or
subscribe()
if not.
$
box install advancedsocket