Skip to content

feat: implement HybridWebSocket on Android #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Nov 2, 2024

Conversation

grabbou
Copy link
Collaborator

@grabbou grabbou commented Nov 1, 2024

This PR provides actual implementation for WebSocket module for Android, using okhttp in Kotlin. This is similar to how/what React Native does.

This is WIP. Functionality is missing. Reviews are welcome.

@@ -126,6 +126,9 @@ dependencies {

// Add a dependency on NitroModules
implementation project(":react-native-nitro-modules")

// Let's use whatever React Native uses right now to avoid duplicates
implementation "com.squareup.okhttp3:okhttp:+"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is correct, have to check 🤣

@grabbou
Copy link
Collaborator Author

grabbou commented Nov 1, 2024

CleanShot 2024-11-01 at 17 28 47@2x

Performance benchmark.

@grabbou grabbou changed the title feat: implement web socket on Android feat: implement HybridWebSocket on Android Nov 1, 2024
example/App.tsx Outdated
@@ -122,7 +122,9 @@ const testWebsocketMessages = async (opts: {
incomingTime: number
}> =>
new Promise((resolve) => {
const inst = new opts.Ws('ws://localhost:3000')
const inst = new opts.Ws(
Platform.OS === 'android' ? 'ws://10.0.2.2:3000' : 'ws://localhost:3000'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably move it to some config file

@grabbou grabbou merged commit 3d549b5 into feat/android Nov 2, 2024
grabbou added a commit that referenced this pull request Nov 2, 2024
* chore: add initial implementation

* revert changes

* chore: stub URL

* chore: remove todo

* chore: add onclosed

* chore: move to const
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants