Commit 5847bd3
feat: Native Websocket Plugin (uses okhttp) (#1335)
* feat: ✨ Native Websocket Plugin (uses okhttp)
* update: readme of cordova websocket plugin for importing it.
* Apply suggestions from code review
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* feat: enhance WebSocket plugin with custom headers and improved close functionality
- Updated `WebSocketPlugin.connect` to accept custom headers.
- Enhanced `WebSocketInstance.close` method to allow specifying close code and reason.
- Added `WebSocketPlugin.listClients` method to list active WebSocket instances.
- Updated JavaScript interface to support new features and improved documentation.
* feat: improve WebSocketInstance and WebSocketPlugin with enhanced logging and error handling
- Updated `WebSocketInstance.send` and `close` methods to include detailed logging for better debugging.
- Modified `WebSocketPlugin` to handle close operation errors and provide appropriate feedback to the callback context.
- Ensured proper binding of event handlers in the JavaScript WebSocket interface for consistent context handling.
* Apply suggestions from code review
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* refactor: replace HashMap with ConcurrentHashMap for thread-safe WebSocket instances management
* feat: enhance WebSocket close event handling
- Updated `WebSocketInstance.onClosed` to send a structured close event with code and reason.
- Modified JavaScript event handling to properly receive and process the close event data.
* feat: enhance WebSocketInstance with binary message support and improved event handling
- Added support for binary messages in `WebSocketInstance` with a new `onMessage` method for handling `ByteString`.
- Updated `sendEvent` method to include a flag indicating if the message is binary.
- Modified JavaScript interface to handle binary data and added logging for better debugging.
- Updated `WebSocketPlugin.connect` to accept a `binaryType` parameter for configuration.
* fix: add missing import for ByteString in WebSocketInstance
Fixes ` error: name clash: class WebSocketInstance has two methods with the same erasure, yet neither overrides the other public void onMessage(@nonnull WebSocket webSocket, @nonnull String text) { ^ first method: onMessage(WebSocket,ByteString) in WebSocketInstance second method: onMessage(WebSocket,ByteString) in WebSocketListener`
* feat: add devcontainer configuration with Android SDK support
* feat: enhance WebSocket plugin with binary message support and improved API
- Updated `WebSocketPlugin.connect` to accept an optional `binaryType` parameter.
- Modified `WebSocketInstance.send` method to handle both string and binary messages.
- Enhanced JavaScript interface to support binary message sending and receiving.
- Improved event handling for binary messages in both Java and JavaScript layers.
- Added logging for better debugging of message sending and receiving.
* feat: improve WebSocket instance management on close event
- Added logic to remove the WebSocket instance from the plugin after a close event is received.
- Introduced a new static method `removeInstance` in `WebSocketPlugin` to handle instance removal.
* fix: ensure WebSocket closes properly on closing event
- Added a call to `this.webSocket.close(code, reason)` in the `onClosing` method to ensure the WebSocket instance closes with the specified code and reason.
Ref: square/okhttp#6510 (comment)
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>1 parent bef8c97 commit 5847bd3
File tree
9 files changed
+724
-0
lines changed- .devcontainer
- src/plugins/websocket
- src/android
- www
9 files changed
+724
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
| 80 | + | |
79 | 81 | | |
80 | 82 | | |
81 | 83 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
0 commit comments