text: //
  //  EXOWebSocket.h
  //
  //  Created by Michael Conrad Tadpol Tilstra on 10/29/15.
  //  Copyright (c) 2015 Exosite. All rights reserved.
  //
  
  #import <Foundation/Foundation.h>
  #import "EXORpcActivateRequest.h"
  #import "EXORpcAuthKey.h"
  #import "EXORpcClientResource.h"
  #import "EXORpcCloneResource.h"
  #import "EXORpcCreateRequest.h"
  #import "EXORpcDataportResource.h"
  #import "EXORpcDataruleResource.h"
  #import "EXORpcDispatchResource.h"
  #import "EXORpcDeactivateRequest.h"
  #import "EXORpcDropRequest.h"
  #import "EXORpcFlushRequest.h"
  #import "EXORpcInfoRequest.h"
  #import "EXORpcListingRequest.h"
  #import "EXORpcLookupRequest.h"
  #import "EXORpcMapRequest.h"
  #import "EXORpcReadRequest.h"
  #import "EXORpcRecordRequest.h"
  #import "EXORpcRevokeRequest.h"
  #import "EXORpcShareRequest.h"
  #import "EXORpcUnmapRequest.h"
  #import "EXORpcUpdateRequest.h"
  #import "EXORpcUsageRequest.h"
  #import "EXORpcValue.h"
  #import "EXORpcWaitRequest.h"
  #import "EXORpcWriteRequest.h"
  #import "EXOWebSocketSubscribeRequest.h"
  
  NS_ASSUME_NONNULL_BEGIN
  /**
   Key for Errors specific to EXOWebSocket.
   */
  extern NSString *EXOWebSocketErrorDomain;
  
  /**
   EXOWebSocket error codes
   */
  typedef NS_ENUM(NSInteger, EXOWebSocketError) {
      EXOWebSocketError_UnknownResponse = -1,
      EXOWebSocketError_MissingAuthKey = -2,
      EXOWebSocketError_NoRequests = -3,
      EXOWebSocketError_WebSocketClosed = -4,
      EXOWebSocketError_UnderlyingError = -5,
      EXOWebSocketError_MalformedResponse = -6,
      EXOWebSocketError_NotOK = -7,
  };
  
  /**
   Callback for the completion of a WebSocket exchange
  
   @param error If not nil, then the error generated by the failed network calls
   */
  typedef void(^EXOWebSocketComplete)(NSError * __nullable error);
  
  
  /**
   * The WebSocket
   */
  @interface EXOWebSocket : NSObject
  
  /**
   Which base URL is being used for the One Platform requests.
   */
  @property(nonatomic,copy,readonly) NSURL *domain;
  
  /**
   The 1P authentication key used for this WebSocket
   */
  @property (copy,nonatomic,readonly) EXORpcAuthKey* auth;
  
  /**
   Initialize a One Platform WebSocket object with a specific domain.
  
   @param auth The authentication for this websocket
   @param domain Which base URL to use for the API requests. Passing nil uses the default.
   @param onError A callback for reporting top level errors.
  
   @return The WebSocket object
   */
  - (nullable instancetype)initWithAuth:(EXORpcAuthKey*)auth domain:(nullable NSURL *)domain onError:(EXOWebSocketComplete)onError NS_DESIGNATED_INITIALIZER;
  
  /**
   Initialize a One Platform WebSocket object with a specific domain.
  
   @param auth The authentication for this websocket
   @param onError A callback for reporting top level errors.
  
   @return The WebSocket object
   */
  - (nullable instancetype)initWithAuth:(EXORpcAuthKey*)auth onError:(EXOWebSocketComplete)onError;
  
  /**
   Send RPC calls to 1P over this web socket.
   
   If the current web socket is closed, a new one will be opened first.
  
   @param calls NSArray of object that subclass from EXORpcRequest
   @param complete Callback called once all requests are queued.
   
   If #complete is called with an error, then none of the requests are queued and none of the requests's callbacks will be called.
  
   */
  - (void)doCalls:(NSArray<EXORpcRequest *> *)calls complete:(EXOWebSocketComplete)complete;
  
  /**
   Close the current web socket
   */
  - (void)close;
  
  @end
  
  NS_ASSUME_NONNULL_END
  