UDPSocket.onMessage
js
UDPSocket.onMessage(function callback)Listens for the message-received event.
Parameters
- function callback: the callback function for the message-received event
callback parameter description:
Object res:
| Property | Type | Default | Description |
|---|---|---|---|
| message | ArrayBuffer | The received message | |
| remoteInfo | Object | Sender address information | |
| localInfo | Object | Receiver address information |
remoteInfo structure:
| Property | Type | Default | Description |
|---|---|---|---|
| address | string | The address of the socket that sent the message | |
| family | string | The protocol family used, either IPv4 or IPv6 | |
| port | number | Port number | |
| size | number | The size of message, in bytes |
localInfo structure:
| Property | Type | Default | Description |
|---|---|---|---|
| address | string | The address of the socket that sent the message | |
| family | string | The protocol family used, either IPv4 or IPv6 | |
| port | number | Port number |
