Name
XMLSocket.onClose( ) Event Handler — specifies the callback handler invoked when the server closes the connection
Availability
Flash 5
Synopsis
socket.onClose = closeHandler
socket.closeHandler( )
Description
The onClose property allows you to specify a
callback handler to be executed automatically whenever an open
connection to socket is closed by the
server. Server-instigated closures usually result from a server
application shutting down or deliberately “kicking off”
the client.
Example
To respond to an onClose event, we must assign
our own function (i.e., our callback handler) to the
onClose property of an
XMLSocket object. In practice, we use this
callback handler to detect an external socket disconnection. The
following code assigns the function handleClose(
) to mySocket’s
onClose property. The
handleClose( ) function simply alerts the user
that a closure has occurred by updating the value of the text field
status:
mySocket = new XMLSocket( );
mySocket.onClose = handleClose;
function handleClose ( ) {
status += ("\nThe server has terminated the connection.\n");
}See Also
XMLSocket.close( );
Section 10.6.2 in Chapter 10
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access