ARTWebSocketDelegate
Objective-C
@protocol ARTWebSocketDelegate <NSObject>
Swift
protocol ARTWebSocketDelegate : NSObjectProtocol
The ARTWebSocketDelegate protocol describes the methods that ARTWebSocket objects
call on their delegates to handle status and messsage events.
This protocol was previously in the SocketRocket library and named ARTSRWebSocketDelegate; all documentation comments have been copied verbatim.
-
Called when any message was received from a web socket. This method is suboptimal and might be deprecated in a future release.
Declaration
Objective-C
- (void)webSocket:(nonnull id<ARTWebSocket>)webSocket didReceiveMessage:(nonnull id)message;Swift
optional func webSocket(_ webSocket: any ARTWebSocket, didReceiveMessage message: Any)Parameters
webSocketAn
ARTWebSocketobject that received a message.messageReceived message. Either a
StringorNSData. -
Called when a frame was received from a web socket.
Declaration
Objective-C
- (void)webSocket:(nonnull id<ARTWebSocket>)webSocket didReceiveMessageWithString:(nonnull NSString *)string;Swift
optional func webSocket(_ webSocket: any ARTWebSocket, didReceiveMessageWith string: String)Parameters
webSocketAn
ARTWebSocketobject that received a message.stringReceived text in a form of UTF-8
String. -
Called when a frame was received from a web socket.
Declaration
Objective-C
- (void)webSocket:(nonnull id<ARTWebSocket>)webSocket didReceiveMessageWithData:(nonnull NSData *)data;Swift
optional func webSocket(_ webSocket: any ARTWebSocket, didReceiveMessageWith data: Data)Parameters
webSocketAn
ARTWebSocketobject that received a message.dataReceived data in a form of
NSData.
-
Called when a given web socket was open and authenticated.
Declaration
Objective-C
- (void)webSocketDidOpen:(nonnull id<ARTWebSocket>)webSocket;Swift
optional func webSocketDidOpen(_ webSocket: any ARTWebSocket)Parameters
webSocketAn
ARTWebSocketobject that was open. -
Called when a given web socket encountered an error.
Declaration
Objective-C
- (void)webSocket:(nonnull id<ARTWebSocket>)webSocket didFailWithError:(nonnull NSError *)error;Swift
optional func webSocket(_ webSocket: any ARTWebSocket, didFailWithError error: any Error)Parameters
webSocketAn
ARTWebSocketobject that failed with an error.errorAn instance of
NSError. -
Called when a given web socket was closed.
Declaration
Objective-C
- (void)webSocket:(nonnull id<ARTWebSocket>)webSocket didCloseWithCode:(NSInteger)code reason:(nullable NSString *)reason wasClean:(BOOL)wasClean;Swift
optional func webSocket(_ webSocket: any ARTWebSocket, didCloseWithCode code: Int, reason: String?, wasClean: Bool)Parameters
webSocketAn
ARTWebSocketobject that was closed.codeCode reported by the server.
reasonReason in a form of a String that was reported by the server or
nil.wasCleanBoolean value indicating whether a socket was closed in a clean state.
-
Called on receive of a ping message from the server.
Declaration
Objective-C
- (void)webSocket:(nonnull id<ARTWebSocket>)webSocket didReceivePingWithData:(nullable NSData *)data;Swift
optional func webSocket(_ webSocket: any ARTWebSocket, didReceivePingWith data: Data?)Parameters
webSocketAn
ARTWebSocketobject that received a ping frame.dataPayload that was received or
nilif there was no payload. -
Called when a pong data was received in response to ping.
Declaration
Objective-C
- (void)webSocket:(nonnull id<ARTWebSocket>)webSocket didReceivePong:(nullable NSData *)pongData;Swift
optional func webSocket(_ webSocket: any ARTWebSocket, didReceivePong pongData: Data?)Parameters
webSocketAn
ARTWebSocketobject that received a pong frame.pongDataPayload that was received or
nilif there was no payload. -
Sent before reporting a text frame to be able to configure if it shuold be convert to a UTF-8 String or passed as
NSData. If the method is not implemented - it will always convert text frames to String.Declaration
Objective-C
- (BOOL)webSocketShouldConvertTextFrameToString: (nonnull id<ARTWebSocket>)webSocket;Swift
optional func webSocketShouldConvertTextFrameToString(_ webSocket: any ARTWebSocket) -> BoolParameters
webSocketAn
ARTWebSocketobject that received a text frame.Return Value
YESif text frame should be converted to UTF-8 String, otherwise -NO. Default:YES.