@@ -124,21 +124,13 @@ func (e wsHandshakeError) Error() string {
124
124
return s
125
125
}
126
126
127
- // DialWebsocket creates a new RPC client that communicates with a JSON-RPC server
128
- // that is listening on the given endpoint.
129
- //
130
- // The context is used for the initial connection establishment. It does not
131
- // affect subsequent interactions with the client.
132
- func DialWebsocket (ctx context.Context , endpoint , origin string ) (* Client , error ) {
127
+ // DialWebsocketWithDialer creates a new RPC client that communicates with a JSON-RPC server
128
+ // that is listening on the given endpoint using the provided dialer.
129
+ func DialWebsocketWithDialer (ctx context.Context , endpoint , origin string , dialer websocket.Dialer ) (* Client , error ) {
133
130
endpoint , header , err := wsClientHeaders (endpoint , origin )
134
131
if err != nil {
135
132
return nil , err
136
133
}
137
- dialer := websocket.Dialer {
138
- ReadBufferSize : wsReadBuffer ,
139
- WriteBufferSize : wsWriteBuffer ,
140
- WriteBufferPool : wsBufferPool ,
141
- }
142
134
return newClient (ctx , func (ctx context.Context ) (ServerCodec , error ) {
143
135
conn , resp , err := dialer .DialContext (ctx , endpoint , header )
144
136
if err != nil {
@@ -152,6 +144,20 @@ func DialWebsocket(ctx context.Context, endpoint, origin string) (*Client, error
152
144
})
153
145
}
154
146
147
+ // DialWebsocket creates a new RPC client that communicates with a JSON-RPC server
148
+ // that is listening on the given endpoint.
149
+ //
150
+ // The context is used for the initial connection establishment. It does not
151
+ // affect subsequent interactions with the client.
152
+ func DialWebsocket (ctx context.Context , endpoint , origin string ) (* Client , error ) {
153
+ dialer := websocket.Dialer {
154
+ ReadBufferSize : wsReadBuffer ,
155
+ WriteBufferSize : wsWriteBuffer ,
156
+ WriteBufferPool : wsBufferPool ,
157
+ }
158
+ return DialWebsocketWithDialer (ctx , endpoint , origin , dialer )
159
+ }
160
+
155
161
func wsClientHeaders (endpoint , origin string ) (string , http.Header , error ) {
156
162
endpointURL , err := url .Parse (endpoint )
157
163
if err != nil {
0 commit comments