Pepper_31_C_interfaces
|
#include <ppb_websocket.h>
Public Attributes | |
PP_Resource(* | Create )(PP_Instance instance) |
PP_Bool(* | IsWebSocket )(PP_Resource resource) |
int32_t(* | Connect )(PP_Resource web_socket, struct PP_Var url, const struct PP_Var protocols[], uint32_t protocol_count, struct PP_CompletionCallback callback) |
int32_t(* | Close )(PP_Resource web_socket, uint16_t code, struct PP_Var reason, struct PP_CompletionCallback callback) |
int32_t(* | ReceiveMessage )(PP_Resource web_socket, struct PP_Var *message, struct PP_CompletionCallback callback) |
int32_t(* | SendMessage )(PP_Resource web_socket, struct PP_Var message) |
uint64_t(* | GetBufferedAmount )(PP_Resource web_socket) |
uint16_t(* | GetCloseCode )(PP_Resource web_socket) |
struct PP_Var(* | GetCloseReason )(PP_Resource web_socket) |
PP_Bool(* | GetCloseWasClean )(PP_Resource web_socket) |
struct PP_Var(* | GetExtensions )(PP_Resource web_socket) |
struct PP_Var(* | GetProtocol )(PP_Resource web_socket) |
PP_WebSocketReadyState(* | GetReadyState )(PP_Resource web_socket) |
struct PP_Var(* | GetURL )(PP_Resource web_socket) |
The PPB_WebSocket
interface provides bi-directional, full-duplex, communications over a single TCP socket.
Definition at line 182 of file ppb_websocket.h.
int32_t(* PPB_WebSocket_1_0::Close)(PP_Resource web_socket, uint16_t code, struct PP_Var reason, struct PP_CompletionCallback callback) |
Close() closes the specified WebSocket connection by specifying code
and reason
.
[in] | web_socket | A PP_Resource corresponding to a WebSocket. |
[in] | code | The WebSocket close code. This is ignored if it is PP_WEBSOCKETSTATUSCODE_NOT_SPECIFIED . PP_WEBSOCKETSTATUSCODE_NORMAL_CLOSURE must be used for the usual case. To indicate some specific error cases, codes in the range PP_WEBSOCKETSTATUSCODE_USER_REGISTERED_MIN to PP_WEBSOCKETSTATUSCODE_USER_REGISTERED_MAX , and in the range PP_WEBSOCKETSTATUSCODE_USER_PRIVATE_MIN to PP_WEBSOCKETSTATUSCODE_USER_PRIVATE_MAX are available. |
[in] | reason | A PP_Var representing the WebSocket close reason. This is ignored if it is PP_VARTYPE_UNDEFINED . Otherwise, its PP_VarType must be PP_VARTYPE_STRING . |
[in] | callback | A PP_CompletionCallback called when the connection is closed or an error occurs in closing the connection. |
pp_errors.h
. Returns PP_ERROR_BADARGUMENT
if reason
contains an invalid character as a UTF-8 string, or is longer than 123 bytes. PP_ERROR_BADARGUMENT
corresponds to a JavaScript SyntaxError in the WebSocket API specification. Returns PP_ERROR_NOACCESS
if the code is not an integer equal to 1000 or in the range 3000 to 4999. PP_ERROR_NOACCESS
corresponds to an InvalidAccessError in the WebSocket API specification. Returns PP_ERROR_INPROGRESS
if a previous call to Close() is not finished. Definition at line 286 of file ppb_websocket.h.
int32_t(* PPB_WebSocket_1_0::Connect)(PP_Resource web_socket, struct PP_Var url, const struct PP_Var protocols[], uint32_t protocol_count, struct PP_CompletionCallback callback) |
Connect() connects to the specified WebSocket server. You can call this function once for a web_socket
.
[in] | web_socket | A PP_Resource corresponding to a WebSocket. |
[in] | url | A PP_Var representing a WebSocket server URL. The PP_VarType must be PP_VARTYPE_STRING . |
[in] | protocols | A pointer to an array of PP_Var specifying sub-protocols. Each PP_Var represents one sub-protocol and its PP_VarType must be PP_VARTYPE_STRING . This argument can be null only if protocol_count is 0. |
[in] | protocol_count | The number of sub-protocols in protocols . |
[in] | callback | A PP_CompletionCallback called when a connection is established or an error occurs in establishing connection. |
pp_errors.h
. Returns PP_ERROR_BADARGUMENT
if the specified url
, or protocols
contain an invalid string as defined in the WebSocket API specification. PP_ERROR_BADARGUMENT
corresponds to a SyntaxError in the WebSocket API specification. Returns PP_ERROR_NOACCESS
if the protocol specified in the url
is not a secure protocol, but the origin of the caller has a secure scheme. Also returns PP_ERROR_NOACCESS
if the port specified in the url
is a port that the user agent is configured to block access to because it is a well-known port like SMTP. PP_ERROR_NOACCESS
corresponds to a SecurityError of the specification. Returns PP_ERROR_INPROGRESS
if this is not the first call to Connect(). Definition at line 245 of file ppb_websocket.h.
PP_Resource(* PPB_WebSocket_1_0::Create)(PP_Instance instance) |
Create() creates a WebSocket instance.
[in] | instance | A PP_Instance identifying the instance with the WebSocket. |
PP_Resource
corresponding to a WebSocket if successful. Definition at line 192 of file ppb_websocket.h.
uint64_t(* PPB_WebSocket_1_0::GetBufferedAmount)(PP_Resource web_socket) |
GetBufferedAmount() returns the number of bytes of text and binary messages that have been queued for the WebSocket connection to send, but have not been transmitted to the network yet.
[in] | web_socket | A PP_Resource corresponding to a WebSocket. |
Definition at line 351 of file ppb_websocket.h.
uint16_t(* PPB_WebSocket_1_0::GetCloseCode)(PP_Resource web_socket) |
GetCloseCode() returns the connection close code for the WebSocket connection.
[in] | web_socket | A PP_Resource corresponding to a WebSocket. |
Definition at line 361 of file ppb_websocket.h.
struct PP_Var(* PPB_WebSocket_1_0::GetCloseReason)(PP_Resource web_socket) |
GetCloseReason() returns the connection close reason for the WebSocket connection.
[in] | web_socket | A PP_Resource corresponding to a WebSocket. |
PP_VARTYPE_STRING
var. If called before the close reason is set, the return value contains an empty string. Returns a PP_VARTYPE_UNDEFINED
if called on an invalid resource. Definition at line 373 of file ppb_websocket.h.
PP_Bool(* PPB_WebSocket_1_0::GetCloseWasClean)(PP_Resource web_socket) |
GetCloseWasClean() returns if the connection was closed cleanly for the specified WebSocket connection.
[in] | web_socket | A PP_Resource corresponding to a WebSocket. |
PP_FALSE
if called before the connection is closed, called on an invalid resource, or closed for abnormal reasons. Otherwise, returns PP_TRUE
if the connection was closed cleanly. Definition at line 386 of file ppb_websocket.h.
struct PP_Var(* PPB_WebSocket_1_0::GetExtensions)(PP_Resource web_socket) |
GetExtensions() returns the extensions selected by the server for the specified WebSocket connection.
[in] | web_socket | A PP_Resource corresponding to a WebSocket. |
PP_VARTYPE_STRING
var. If called before the connection is established, the var's data is an empty string. Returns a PP_VARTYPE_UNDEFINED
if called on an invalid resource. Definition at line 398 of file ppb_websocket.h.
struct PP_Var(* PPB_WebSocket_1_0::GetProtocol)(PP_Resource web_socket) |
GetProtocol() returns the sub-protocol chosen by the server for the specified WebSocket connection.
[in] | web_socket | A PP_Resource corresponding to a WebSocket. |
PP_VARTYPE_STRING
var. If called before the connection is established, the var contains the empty string. Returns a PP_VARTYPE_UNDEFINED
if called on an invalid resource. Definition at line 410 of file ppb_websocket.h.
PP_WebSocketReadyState(* PPB_WebSocket_1_0::GetReadyState)(PP_Resource web_socket) |
GetReadyState() returns the ready state of the specified WebSocket connection.
[in] | web_socket | A PP_Resource corresponding to a WebSocket. |
PP_WEBSOCKETREADYSTATE_INVALID
if called before Connect() is called, or if this function is called on an invalid resource. Definition at line 422 of file ppb_websocket.h.
struct PP_Var(* PPB_WebSocket_1_0::GetURL)(PP_Resource web_socket) |
GetURL() returns the URL associated with specified WebSocket connection.
[in] | web_socket | A PP_Resource corresponding to a WebSocket. |
PP_VARTYPE_STRING
var. If called before the connection is established, the var contains the empty string. Returns a PP_VARTYPE_UNDEFINED
if this function is called on an invalid resource. Definition at line 434 of file ppb_websocket.h.
PP_Bool(* PPB_WebSocket_1_0::IsWebSocket)(PP_Resource resource) |
IsWebSocket() determines if the provided resource
is a WebSocket instance.
[in] | resource | A PP_Resource corresponding to a WebSocket. |
PP_TRUE
if resource
is a PPB_WebSocket
, PP_FALSE
if the resource
is invalid or some type other than PPB_WebSocket
. Definition at line 205 of file ppb_websocket.h.
int32_t(* PPB_WebSocket_1_0::ReceiveMessage)(PP_Resource web_socket, struct PP_Var *message, struct PP_CompletionCallback callback) |
ReceiveMessage() receives a message from the WebSocket server. This interface only returns a single message. That is, this interface must be called at least N times to receive N messages, no matter the size of each message.
[in] | web_socket | A PP_Resource corresponding to a WebSocket. |
[out] | message | The received message is copied to provided message . The message must remain valid until ReceiveMessage() completes. Its received PP_VarType will be PP_VARTYPE_STRING or PP_VARTYPE_ARRAY_BUFFER . |
[in] | callback | A PP_CompletionCallback called when ReceiveMessage() completes. This callback is ignored if ReceiveMessage() completes synchronously and returns PP_OK . |
pp_errors.h
. If an error is detected or connection is closed, ReceiveMessage() returns PP_ERROR_FAILED
after all buffered messages are received. Until buffered message become empty, ReceiveMessage() continues to return PP_OK
as if connection is still established without errors. Definition at line 314 of file ppb_websocket.h.
int32_t(* PPB_WebSocket_1_0::SendMessage)(PP_Resource web_socket, struct PP_Var message) |
SendMessage() sends a message to the WebSocket server.
[in] | web_socket | A PP_Resource corresponding to a WebSocket. |
[in] | message | A message to send. The message is copied to an internal buffer, so the caller can free message safely after returning from the function. Its sent PP_VarType must be PP_VARTYPE_STRING or PP_VARTYPE_ARRAY_BUFFER . |
pp_errors.h
. Returns PP_ERROR_FAILED
if the ReadyState is PP_WEBSOCKETREADYSTATE_CONNECTING
. PP_ERROR_FAILED
corresponds to a JavaScript InvalidStateError in the WebSocket API specification. Returns PP_ERROR_BADARGUMENT
if the provided message
contains an invalid character as a UTF-8 string. PP_ERROR_BADARGUMENT
corresponds to a JavaScript SyntaxError in the WebSocket API specification. Otherwise, returns PP_OK
, which doesn't necessarily mean that the server received the message. Definition at line 340 of file ppb_websocket.h.