You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Documentation/Usage.md
+14-5Lines changed: 14 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -350,8 +350,17 @@ let blockNumber = try! web3.eth.getBlockNumber()
350
350
### Web3socketDelegate
351
351
352
352
To receive messages from endpoint you need to create a class that adopt to Web3SocketDelegate protocol.
353
+
Later, in order to open a connection to WebSocket server, you will use socket provider (WebsocketProvider or InfuraWebsocketProvider). And we recommend you to make it a property, so it doesn't get deallocated right after being setup.
353
354
```swift
354
-
let delegate: Web3SocketDelegate =DelegateClass() // Some delegate class which will receive messages from endpoint
355
+
classDelegateClass: Web3SocketDelegate {
356
+
var socketProvider: WebsocketProvider?=nil// WebSocket Provider
357
+
var socketProvider: InfuraWebsocketProvider?=nil// Infura WebSocket Provider
358
+
359
+
// Protocol method, here will be messages, received from WebSocket server
360
+
funcreceived(message: Any) {
361
+
// Make something with message
362
+
}
363
+
}
355
364
```
356
365
357
366
### Custom Websocket Provider
@@ -360,7 +369,7 @@ let delegate: Web3SocketDelegate = DelegateClass() // Some delegate class which
360
369
361
370
You can create WebsocketProvider and connect/disconnect it.
0 commit comments