send method

Sends data to the server using a WebSocket connection.

Syntax

object.send(data)

Parameters

data [in]
ValueMeaning
string

Sends a string to the server

Blob

Sends a binary stream of data to the server. See msStreamReader.readAsBlob.

ArrayBuffer

Sends a generic fixed-length binary data buffer to the server.

ArrayBufferView

Sends a variable-length A typed array view of an ArrayBuffer to the server.

 

Return value

This method does not return a value.

Remarks

An ArrayBufferView is a typed array view of an ArrayBuffer. An ArrayBuffer is a unformatted block of raw data that is sent in its entirety to a server. By using a typed array to define the format of the buffer, and the start and length (number of elements), you can send portions of an ArrayBuffer to a server.


var buf = new ArrayBuffer(100);
var firstFourBytes = new Uint8Array(buf, 0, 4);
socket.send(firstFourBytes);


This method can throw one of the following exceptions:

ExceptionDescription
InvalidStateError(11)The connection is not currently OPEN.

 

See also

FileReader.readAsArrayBuffer
msStreamReader.readAsBlob
readyState
WebSocket
WebSockets in Windows
WebSockets RFC 6455
The WebSocket API

 

 

Show:
© 2014 Microsoft