NBMJSONRPCClient Class Reference

Inherits from NSObject
Declared in NBMJSONRPCClient.h

Overview

NBMJSONRPCClient object communicates with web sockets using the JSON-RPC 2.0 protocol.

  url

The URL for the websocket.

@property (nonatomic) NSURL *url

Declared In

NBMJSONRPCClient.h

  configuration

The client configuration object.

@property (nonatomic, readonly) NBMJSONRPCClientConfiguration *configuration

Declared In

NBMJSONRPCClient.h

  delegate

The delegate object for the client.

@property (nonatomic, weak) id<NBMJSONRPCClientDelegate> delegate

Declared In

NBMJSONRPCClient.h

  connectionState

@property (nonatomic, readonly) NBMJSONRPCConnectionState connectionState

  connected

A boolean that indicates the websocket connection status.

@property (nonatomic, readonly, getter=isConnected) BOOL connected

Declared In

NBMJSONRPCClient.h

– initWithURL:delegate:

Creates and initializes a JSON-RPC client with the specified endpoint using default configuration.

- (instancetype)initWithURL:(NSURL *)url delegate:(id<NBMJSONRPCClientDelegate>)delegate

Parameters

url

The endpoint URL.

delegate

The delegate object for the client.

Return Value

An initialized JSON-RPC client.

Declared In

NBMJSONRPCClient.h

– initWithURL:configuration:delegate:

Creates and initializes a JSON-RPC client with the specified endpoint using provided configuration.

- (instancetype)initWithURL:(NSURL *)url configuration:(NBMJSONRPCClientConfiguration *)configuration delegate:(id<NBMJSONRPCClientDelegate>)delegate

Parameters

url

The endpoint URL.

configuration

A configuration object.

delegate

The delegate object for the client.

Return Value

An initialized JSON-RPC client.

Declared In

NBMJSONRPCClient.h

– connect

Connects client to the server using WebSocket.

- (void)connect

Discussion

Note: Use this method after initialization when configuration’s property is set to NO or when connection goes down and connected property switch to NO.

Declared In

NBMJSONRPCClient.h

– sendRequestWithMethod:completion:

Creates and sends a request with the specified method using websocket as transport channel.

- (NBMRequest *)sendRequestWithMethod:(NSString *)method completion:(void ( ^ ) ( NBMResponse *response ))responseBlock

Parameters

method

The request method. Must not be nil.

responseBlock

A block object to be executed when the request is sent. This block has no return value and takes the response object created by the client response serializer. The response object may be nil if network (e.g timeout) or parsing error occurred.

Return Value

The NBMRequest object that was sent.

Declared In

NBMJSONRPCClient.h

– sendRequestWithMethod:parameters:completion:

Creates and sends a request with the specified method and parameters using websocket as transport channel.

- (NBMRequest *)sendRequestWithMethod:(NSString *)method parameters:(id)parameters completion:(void ( ^ ) ( NBMResponse *response ))responseBlock

Parameters

method

The request method. Musto not be nil.

parameters

The parameters to encode into the request. Must be either an NSDictionary or NSArray.

responseBlock

A block object to be executed when the request is sent. This block has no return value and takes the response object created by the client. response serializer. The response object may be nil if network (e.g timeout) or parsing error occurred.

Return Value

The NBMRequest object that was sent.

Declared In

NBMJSONRPCClient.h

– sendRequest:completion:

Sends a provided request using websocket as transport channel.

- (void)sendRequest:(NBMRequest *)requestToSend completion:(void ( ^ ) ( NBMResponse *response ))responseBlock

Parameters

requestToSend

The NBMRequest object to send.

responseBlock

A block object to be executed when the request is sent. This block has no return value and takes the response object created by the client response serializer. The response object may be nil if network (e.g timeout) or parsing error occurred.

Declared In

NBMJSONRPCClient.h

– sendNotificationWithMethod:parameters:

Creates and sends a notification with the specified method and parameters using websocket as transport channel.

- (NBMRequest *)sendNotificationWithMethod:(NSString *)method parameters:(id)parameters

Parameters

method

The notification method. Must not be nil.

parameters

The parameters to encode into the notification. Must be either an NSDictionary or NSArray, may be ‘nil’.

Return Value

The NBMRequest object that was sent.

Discussion

Note: Notification is a NBMRequest object that produces no server response.

Declared In

NBMJSONRPCClient.h

– sendNotification:

Sends a provided notification using websocket as transport channel.

- (void)sendNotification:(NBMRequest *)notification

Parameters

notification

The NBMRequest object to send.

Declared In

NBMJSONRPCClient.h

– cancelRequest:

Allow to cancel a request and don’t wait for a response.

- (void)cancelRequest:(NBMRequest *)request

Parameters

request

The NBMRequest object to cancel.

Declared In

NBMJSONRPCClient.h

– cancelAllRequest

Allow to cancel all requests and don’t wait for responses.

- (void)cancelAllRequest

Declared In

NBMJSONRPCClient.h