33import Foundation
44import GraphQL
55
6- /// Adds client-side [graphql-ws protocol](https://github.com/apollographql/subscriptions-transport-ws/blob/master/PROTOCOL.md)
7- /// support, namely parsing and adding callbacks for each type of server respose.
8- class Client {
6+ /// Client is an open-ended implementation of the client side of the protocol. It parses and adds callbacks for each type of server respose.
7+ public class Client {
98 let messenger : Messenger
109
1110 var onConnectionError : ( ConnectionErrorResponse , Client ) -> Void = { _, _ in }
@@ -23,7 +22,7 @@ class Client {
2322 ///
2423 /// - Parameters:
2524 /// - messenger: The messenger to bind the client to.
26- init (
25+ public init (
2726 messenger: Messenger
2827 ) {
2928 self . messenger = messenger
@@ -107,48 +106,48 @@ class Client {
107106
108107 /// Define the callback run on receipt of a `connection_error` message
109108 /// - Parameter callback: The callback to assign
110- func onConnectionError( _ callback: @escaping ( ConnectionErrorResponse , Client ) -> Void ) {
109+ public func onConnectionError( _ callback: @escaping ( ConnectionErrorResponse , Client ) -> Void ) {
111110 self . onConnectionError = callback
112111 }
113112
114113 /// Define the callback run on receipt of a `connection_ack` message
115114 /// - Parameter callback: The callback to assign
116- func onConnectionAck( _ callback: @escaping ( ConnectionAckResponse , Client ) -> Void ) {
115+ public func onConnectionAck( _ callback: @escaping ( ConnectionAckResponse , Client ) -> Void ) {
117116 self . onConnectionAck = callback
118117 }
119118
120119 /// Define the callback run on receipt of a `connection_ka` message
121120 /// - Parameter callback: The callback to assign
122- func onConnectionKeepAlive( _ callback: @escaping ( ConnectionKeepAliveResponse , Client ) -> Void ) {
121+ public func onConnectionKeepAlive( _ callback: @escaping ( ConnectionKeepAliveResponse , Client ) -> Void ) {
123122 self . onConnectionKeepAlive = callback
124123 }
125124
126125 /// Define the callback run on receipt of a `data` message
127126 /// - Parameter callback: The callback to assign
128- func onData( _ callback: @escaping ( DataResponse , Client ) -> Void ) {
127+ public func onData( _ callback: @escaping ( DataResponse , Client ) -> Void ) {
129128 self . onData = callback
130129 }
131130
132131 /// Define the callback run on receipt of an `error` message
133132 /// - Parameter callback: The callback to assign
134- func onError( _ callback: @escaping ( ErrorResponse , Client ) -> Void ) {
133+ public func onError( _ callback: @escaping ( ErrorResponse , Client ) -> Void ) {
135134 self . onError = callback
136135 }
137136
138137 /// Define the callback run on receipt of any message
139138 /// - Parameter callback: The callback to assign
140- func onComplete( _ callback: @escaping ( CompleteResponse , Client ) -> Void ) {
139+ public func onComplete( _ callback: @escaping ( CompleteResponse , Client ) -> Void ) {
141140 self . onComplete = callback
142141 }
143142
144143 /// Define the callback run on receipt of a `complete` message
145144 /// - Parameter callback: The callback to assign
146- func onMessage( _ callback: @escaping ( String , Client ) -> Void ) {
145+ public func onMessage( _ callback: @escaping ( String , Client ) -> Void ) {
147146 self . onMessage = callback
148147 }
149148
150149 /// Send a `connection_init` request through the messenger
151- func sendConnectionInit( payload: ConnectionInitAuth ? ) {
150+ public func sendConnectionInit( payload: ConnectionInitAuth ? ) {
152151 messenger. send (
153152 ConnectionInitRequest (
154153 payload: payload
@@ -157,7 +156,7 @@ class Client {
157156 }
158157
159158 /// Send a `start` request through the messenger
160- func sendStart( payload: GraphQLRequest , id: String ) {
159+ public func sendStart( payload: GraphQLRequest , id: String ) {
161160 messenger. send (
162161 StartRequest (
163162 payload: payload,
@@ -167,7 +166,7 @@ class Client {
167166 }
168167
169168 /// Send a `stop` request through the messenger
170- func sendStop( id: String ) {
169+ public func sendStop( id: String ) {
171170 messenger. send (
172171 StopRequest (
173172 id: id
@@ -176,7 +175,7 @@ class Client {
176175 }
177176
178177 /// Send a `connection_terminate` request through the messenger
179- func sendConnectionTerminate( ) {
178+ public func sendConnectionTerminate( ) {
180179 messenger. send (
181180 ConnectionTerminateRequest ( ) . toJSON ( encoder)
182181 )
0 commit comments