Class sap.ui.core.ws.WebSocketModule: sap/ui/core/ws/WebSocket
Basic WebSocket class
Constructor Summary
Event Summary
Method Summary
sap.ui.core.ws.WebSocket.extend(sClassName, oClassInfo?, FNMetaImpl?)Creates a new subclass of class sap.ui.core.ws.WebSocket with name
sClassName
and enriches it with the information contained in oClassInfo
.attachClose(oData?, fnFunction, oListener?)Attach event-handler
fnFunction
to the 'close' event of this sap.ui.core.ws.WebSocket
.attachError(oData?, fnFunction, oListener?)Attach event-handler
fnFunction
to the 'error' event of this sap.ui.core.ws.WebSocket
.attachMessage(oData?, fnFunction, oListener?)Attach event-handler
fnFunction
to the 'message' event of this sap.ui.core.ws.WebSocket
.attachOpen(oData?, fnFunction, oListener?)Attach event-handler
fnFunction
to the 'open' event of this sap.ui.core.ws.WebSocket
.detachClose(fnFunction, oListener)Detach event-handler
fnFunction
from the 'close' event of this sap.ui.core.ws.WebSocket
.detachError(fnFunction, oListener)Detach event-handler
fnFunction
from the 'error' event of this sap.ui.core.ws.WebSocket
.detachMessage(fnFunction, oListener)Detach event-handler
fnFunction
from the 'message' event of this sap.ui.core.ws.WebSocket
.detachOpen(fnFunction, oListener)Detach event-handler
fnFunction
from the 'open' event of this sap.ui.core.ws.WebSocket
.Methods borrowed from class sap.ui.base.EventProvider
Methods borrowed from class sap.ui.base.Object
Constructor Detail
Event Detail
close(oControlEvent)
The 'close' event is fired, when the connection was closed.
Parameters:
{sap.ui.base.Event} | oControlEvent | |
{sap.ui.base.EventProvider} | oControlEvent.getSource | |
{object} | oControlEvent.getParameters | |
{string} | oControlEvent.getParameters.code | Close code provided by the server. |
{string} | oControlEvent.getParameters.reason | Reason from server for closing the connection. |
{string} | oControlEvent.getParameters.wasClean | Indicates whether the connection was cleanly closed or not. |
error(oControlEvent)
The 'error' event is fired, when an error occurred.
Parameters:
{sap.ui.base.Event} | oControlEvent | |
{sap.ui.base.EventProvider} | oControlEvent.getSource | |
{object} | oControlEvent.getParameters |
message(oControlEvent)
The 'message' event is fired, when a message was received.
Parameters:
{sap.ui.base.Event} | oControlEvent | |
{sap.ui.base.EventProvider} | oControlEvent.getSource | |
{object} | oControlEvent.getParameters | |
{string} | oControlEvent.getParameters.data | Received data from the server. |
open(oControlEvent)
The 'open' event is fired, when the connection was successfully opened.
Parameters:
{sap.ui.base.Event} | oControlEvent | |
{sap.ui.base.EventProvider} | oControlEvent.getSource | |
{object} | oControlEvent.getParameters |
Method Detail
sap.ui.core.ws.WebSocket.extend(sClassName, oClassInfo?, FNMetaImpl?): function
Creates a new subclass of class sap.ui.core.ws.WebSocket with name
sClassName
and enriches it with the information contained in oClassInfo
. oClassInfo
might contain the same kind of information as described in sap.ui.base.EventProvider.extend.
Parameters:
{string} | sClassName | Name of the class being created |
{object} | oClassInfo? | Object literal with information about the class |
{function} | FNMetaImpl? | Constructor function for the metadata object; if not given, it defaults to sap.ui.core.ElementMetadata |
Returns:
{function} | Created class / constructor function |
sap.ui.core.ws.WebSocket.getMetadata(): sap.ui.base.Metadata
Returns a metadata object for class sap.ui.core.ws.WebSocket.
Returns:
{sap.ui.base.Metadata} | Metadata object describing this class |
attachClose(oData?, fnFunction, oListener?): sap.ui.core.ws.WebSocket
Attach event-handler
fnFunction
to the 'close' event of this sap.ui.core.ws.WebSocket
.Parameters:
{object} | oData? | The object, that should be passed along with the event-object when firing the event. |
{function} | fnFunction | The function to call, when the event occurs. This function will be called on the oListener-instance (if present) or in a 'static way'. |
{object} | oListener? | Object on which to call the given function. If empty, this WebSocket is used. |
Returns:
{sap.ui.core.ws.WebSocket} | this to allow method chaining |
attachError(oData?, fnFunction, oListener?): sap.ui.core.ws.WebSocket
Attach event-handler
fnFunction
to the 'error' event of this sap.ui.core.ws.WebSocket
.Parameters:
{object} | oData? | The object, that should be passed along with the event-object when firing the event. |
{function} | fnFunction | The function to call, when the event occurs. This function will be called on the oListener-instance (if present) or in a 'static way'. |
{object} | oListener? | Object on which to call the given function. If empty, this WebSocket is used. |
Returns:
{sap.ui.core.ws.WebSocket} | this to allow method chaining |
attachMessage(oData?, fnFunction, oListener?): sap.ui.core.ws.WebSocket
Attach event-handler
fnFunction
to the 'message' event of this sap.ui.core.ws.WebSocket
.Parameters:
{object} | oData? | The object, that should be passed along with the event-object when firing the event. |
{function} | fnFunction | The function to call, when the event occurs. This function will be called on the oListener-instance (if present) or in a 'static way'. |
{object} | oListener? | Object on which to call the given function. If empty, this WebSocket is used. |
Returns:
{sap.ui.core.ws.WebSocket} | this to allow method chaining |
attachOpen(oData?, fnFunction, oListener?): sap.ui.core.ws.WebSocket
Attach event-handler
fnFunction
to the 'open' event of this sap.ui.core.ws.WebSocket
.Parameters:
{object} | oData? | The object, that should be passed along with the event-object when firing the event. |
{function} | fnFunction | The function to call, when the event occurs. This function will be called on the oListener-instance (if present) or in a 'static way'. |
{object} | oListener? | Object on which to call the given function. If empty, this WebSocket is used. |
Returns:
{sap.ui.core.ws.WebSocket} | this to allow method chaining |
close(iCode?, sReason?): sap.ui.core.ws.WebSocket
Closes the connection.
Parameters:
{int} | iCode? | Status code that explains why the connection is closed. Must be either 1000, or between 3000 and 4999 (default 1000) |
{string} | sReason? | Closing reason as a string |
Returns:
{sap.ui.core.ws.WebSocket} | this to allow method chaining |
detachClose(fnFunction, oListener): sap.ui.core.ws.WebSocket
Detach event-handler
fnFunction
from the 'close' event of this sap.ui.core.ws.WebSocket
.The passed function and listener object must match the ones previously used for event registration.
Parameters:
{function} | fnFunction | The function to call, when the event occurs. |
{object} | oListener | Object on which the given function had to be called. |
Returns:
{sap.ui.core.ws.WebSocket} | this to allow method chaining |
detachError(fnFunction, oListener): sap.ui.core.ws.WebSocket
Detach event-handler
fnFunction
from the 'error' event of this sap.ui.core.ws.WebSocket
.The passed function and listener object must match the ones previously used for event registration.
Parameters:
{function} | fnFunction | The function to call, when the event occurs. |
{object} | oListener | Object on which the given function had to be called. |
Returns:
{sap.ui.core.ws.WebSocket} | this to allow method chaining |
detachMessage(fnFunction, oListener): sap.ui.core.ws.WebSocket
Detach event-handler
fnFunction
from the 'message' event of this sap.ui.core.ws.WebSocket
.The passed function and listener object must match the ones previously used for event registration.
Parameters:
{function} | fnFunction | The function to call, when the event occurs. |
{object} | oListener | Object on which the given function had to be called. |
Returns:
{sap.ui.core.ws.WebSocket} | this to allow method chaining |
detachOpen(fnFunction, oListener): sap.ui.core.ws.WebSocket
Detach event-handler
fnFunction
from the 'open' event of this sap.ui.core.ws.WebSocket
.The passed function and listener object must match the ones previously used for event registration.
Parameters:
{function} | fnFunction | The function to call, when the event occurs. |
{object} | oListener | Object on which the given function had to be called. |
Returns:
{sap.ui.core.ws.WebSocket} | this to allow method chaining |
fireClose(mArguments?): sap.ui.core.ws.WebSocket
Fire event 'close' to attached listeners.
Parameters:
{object} | mArguments? | the arguments to pass along with the event. |
{string} | mArguments.code? | Close code provided by the server. |
{string} | mArguments.reason? | Reason from server for closing the connection. |
{string} | mArguments.wasClean? | Indicates whether the connection was cleanly closed or not. |
Returns:
{sap.ui.core.ws.WebSocket} | this to allow method chaining |
fireError(mArguments?): sap.ui.core.ws.WebSocket
Fire event 'error' to attached listeners.
Parameters:
{object} | mArguments? | the arguments to pass along with the event. |
Returns:
{sap.ui.core.ws.WebSocket} | this to allow method chaining |
fireMessage(mArguments?): sap.ui.core.ws.WebSocket
Fire event 'message' to attached listeners.
Parameters:
{object} | mArguments? | the arguments to pass along with the event. |
{string} | mArguments.data? | Received data from the server. |
Returns:
{sap.ui.core.ws.WebSocket} | this to allow method chaining |
fireOpen(mArguments?): sap.ui.core.ws.WebSocket
Fire event 'open' to attached listeners.
Parameters:
{object} | mArguments? | the arguments to pass along with the event. |
Returns:
{sap.ui.core.ws.WebSocket} | this to allow method chaining |
getProtocol(): string
Getter for the protocol selected by the server once the connection is open.
Returns:
{string} | protocol |
getReadyState(): sap.ui.core.ws.ReadyState
Getter for WebSocket readyState.
Returns:
{sap.ui.core.ws.ReadyState} | readyState |
send(sMessage): sap.ui.core.ws.WebSocket
Sends a message.
If the connection is not yet opened, the message will be queued and sent when the connection is established.
If the connection is not yet opened, the message will be queued and sent when the connection is established.
Parameters:
{string} | sMessage | Message to send |
Returns:
{sap.ui.core.ws.WebSocket} | this to allow method chaining |