Class sap.ui.core.ws.WebSocketModule: sap/ui/core/ws/WebSocket

known direct subclasses: SapPcpWebSocket

Basic WebSocket class
Constructor Summary
new sap.ui.core.ws.WebSocket(sUrl, aProtocols?)Creates a new WebSocket connection.
Event Summary
close(oControlEvent)The 'close' event is fired, when the connection was closed.
error(oControlEvent)The 'error' event is fired, when an error occurred.
message(oControlEvent)The 'message' event is fired, when a message was received.
open(oControlEvent)The 'open' event is fired, when the connection was successfully opened.
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.
sap.ui.core.ws.WebSocket.getMetadata()Returns a metadata object for class sap.ui.core.ws.WebSocket.
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.
close(iCode?, sReason?)Closes the connection.
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.
fireClose(mArguments?)Fire event 'close' to attached listeners.
fireError(mArguments?)Fire event 'error' to attached listeners.
fireMessage(mArguments?)Fire event 'message' to attached listeners.
fireOpen(mArguments?)Fire event 'open' to attached listeners.
getProtocol()Getter for the protocol selected by the server once the connection is open.
getReadyState()Getter for WebSocket readyState.
send(sMessage)Sends a message.
Methods borrowed from class sap.ui.base.Object
Constructor Detail
new sap.ui.core.ws.WebSocket(sUrl, aProtocols?)
Creates a new WebSocket connection.
Parameters:
stringsUrlrelative or absolute URL for WebSocket connection.
arrayaProtocols?array of protocols as strings, a single protocol as a string
Event Detail
close(oControlEvent)
The 'close' event is fired, when the connection was closed.
Parameters:
sap.ui.base.EventoControlEvent
sap.ui.base.EventProvideroControlEvent.getSource
objectoControlEvent.getParameters
stringoControlEvent.getParameters.codeClose code provided by the server.
stringoControlEvent.getParameters.reasonReason from server for closing the connection.
stringoControlEvent.getParameters.wasCleanIndicates whether the connection was cleanly closed or not.
error(oControlEvent)
The 'error' event is fired, when an error occurred.
Parameters:
sap.ui.base.EventoControlEvent
sap.ui.base.EventProvideroControlEvent.getSource
objectoControlEvent.getParameters
message(oControlEvent)
The 'message' event is fired, when a message was received.
Parameters:
sap.ui.base.EventoControlEvent
sap.ui.base.EventProvideroControlEvent.getSource
objectoControlEvent.getParameters
stringoControlEvent.getParameters.dataReceived data from the server.
open(oControlEvent)
The 'open' event is fired, when the connection was successfully opened.
Parameters:
sap.ui.base.EventoControlEvent
sap.ui.base.EventProvideroControlEvent.getSource
objectoControlEvent.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:
stringsClassNameName of the class being created
objectoClassInfo?Object literal with information about the class
functionFNMetaImpl?Constructor function for the metadata object; if not given, it defaults to sap.ui.core.ElementMetadata
Returns:
functionCreated 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.MetadataMetadata 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:
objectoData?The object, that should be passed along with the event-object when firing the event.
functionfnFunctionThe function to call, when the event occurs. This function will be called on the oListener-instance (if present) or in a 'static way'.
objectoListener?Object on which to call the given function. If empty, this WebSocket is used.
Returns:
sap.ui.core.ws.WebSocketthis 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:
objectoData?The object, that should be passed along with the event-object when firing the event.
functionfnFunctionThe function to call, when the event occurs. This function will be called on the oListener-instance (if present) or in a 'static way'.
objectoListener?Object on which to call the given function. If empty, this WebSocket is used.
Returns:
sap.ui.core.ws.WebSocketthis 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:
objectoData?The object, that should be passed along with the event-object when firing the event.
functionfnFunctionThe function to call, when the event occurs. This function will be called on the oListener-instance (if present) or in a 'static way'.
objectoListener?Object on which to call the given function. If empty, this WebSocket is used.
Returns:
sap.ui.core.ws.WebSocketthis 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:
objectoData?The object, that should be passed along with the event-object when firing the event.
functionfnFunctionThe function to call, when the event occurs. This function will be called on the oListener-instance (if present) or in a 'static way'.
objectoListener?Object on which to call the given function. If empty, this WebSocket is used.
Returns:
sap.ui.core.ws.WebSocketthis to allow method chaining
close(iCode?, sReason?): sap.ui.core.ws.WebSocket
Closes the connection.
Parameters:
intiCode?Status code that explains why the connection is closed. Must be either 1000, or between 3000 and 4999 (default 1000)
stringsReason?Closing reason as a string
Returns:
sap.ui.core.ws.WebSocketthis 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:
functionfnFunctionThe function to call, when the event occurs.
objectoListenerObject on which the given function had to be called.
Returns:
sap.ui.core.ws.WebSocketthis 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:
functionfnFunctionThe function to call, when the event occurs.
objectoListenerObject on which the given function had to be called.
Returns:
sap.ui.core.ws.WebSocketthis 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:
functionfnFunctionThe function to call, when the event occurs.
objectoListenerObject on which the given function had to be called.
Returns:
sap.ui.core.ws.WebSocketthis 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:
functionfnFunctionThe function to call, when the event occurs.
objectoListenerObject on which the given function had to be called.
Returns:
sap.ui.core.ws.WebSocketthis to allow method chaining
fireClose(mArguments?): sap.ui.core.ws.WebSocket
Fire event 'close' to attached listeners.
Parameters:
objectmArguments?the arguments to pass along with the event.
stringmArguments.code?Close code provided by the server.
stringmArguments.reason?Reason from server for closing the connection.
stringmArguments.wasClean?Indicates whether the connection was cleanly closed or not.
Returns:
sap.ui.core.ws.WebSocketthis to allow method chaining
fireError(mArguments?): sap.ui.core.ws.WebSocket
Fire event 'error' to attached listeners.
Parameters:
objectmArguments?the arguments to pass along with the event.
Returns:
sap.ui.core.ws.WebSocketthis to allow method chaining
fireMessage(mArguments?): sap.ui.core.ws.WebSocket
Fire event 'message' to attached listeners.
Parameters:
objectmArguments?the arguments to pass along with the event.
stringmArguments.data?Received data from the server.
Returns:
sap.ui.core.ws.WebSocketthis to allow method chaining
fireOpen(mArguments?): sap.ui.core.ws.WebSocket
Fire event 'open' to attached listeners.
Parameters:
objectmArguments?the arguments to pass along with the event.
Returns:
sap.ui.core.ws.WebSocketthis to allow method chaining
getProtocol(): string
Getter for the protocol selected by the server once the connection is open.
Returns:
stringprotocol
getReadyState(): sap.ui.core.ws.ReadyState
Getter for WebSocket readyState.
Returns:
sap.ui.core.ws.ReadyStatereadyState
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.
Parameters:
stringsMessageMessage to send
Returns:
sap.ui.core.ws.WebSocketthis to allow method chaining