Summary:
I am working in Horizon Worlds and I would like to integrate Flipper with HzW app.
Currently FlipperPlugin C++ code won't compile on Windows since it uses Linux-only headers like `netdb.h` and `sys/fcntl.h`, I posted here and looks like it is not currently supported: https://fb.workplace.com/groups/flippersupport/posts/1704837183330266
The problem seem to be in only in `FlipperConnectionEndpointVerifier.cpp`, and I'm updating it to make it compatible with Windows.
Also apparently there's some issue with `#include` of few files and namespaces, leading to "struct redefinition" errors where `#pragma once` does not help https://fb.workplace.com/groups/474291069286180/posts/25313067014981908/
Solving it with manual #define
Reviewed By: lblasa
Differential Revision: D50337573
fbshipit-source-id: affdf1aee2b9dfe615227827fedf324a5f17d8b0
Summary:
Whenever there is an issue, I always find myself adding these logs.
Instead of keep doing that, reuse the existing FLIPPER_DEBUG_LOG definition as a way of enabling/disabling the verbose logs very easily.
Reviewed By: ivanmisuno
Differential Revision: D49227973
fbshipit-source-id: d053df6668b1dda6f6782e8ef7d844c82945f126
Summary: Use the same standard used in other places.
Reviewed By: ivanmisuno
Differential Revision: D49228128
fbshipit-source-id: 771b6923f758400200298f3339b83b2c4d51648b
Summary: Make it more explicit. What has succeeded, failed, started.
Reviewed By: ivanmisuno
Differential Revision: D49227799
fbshipit-source-id: fe9e6baaff227cf1db0b3150a3ee8cf194d2b6e6
Summary:
Symmetry with D48642974.
Changelog: Don't throw in C++ if a plugin gets added/removed multiple times.
Reviewed By: lblasa
Differential Revision: D48643116
fbshipit-source-id: cc6638061b1dee2a6f7deb1fab1093906decc24a
Summary: Set delegate and close inside the operation's queue as to make it safer i.e. all socket related operations are done inside the queue.
Reviewed By: ivanmisuno
Differential Revision: D47124235
fbshipit-source-id: 48b53db1cd47d017a26186a156046ba68fe358b7
Summary:
Never really liked this code. Before this change, calls to connect were blocking.
Because of this, we had to make use of promises and a bit of really not that good-looking code.
So, this change makes connect non-blocking meaning that we make full use of our event handler.
These changes contain:
- CSR is not getting generated after each failed attempt.
- Connect is no longer blocking.
- Do not report events via the handler when explicitly disconnecting.
Reviewed By: jknoxville
Differential Revision: D46853228
fbshipit-source-id: 00e6a9c7c039a756175fe14982959e078d92bacb
Summary:
Create the step as an attempt.
Remove conditionally marking it as success or failure as connect will not be done 'synchronously' moving forward.
:::notes:::
Documentation is for personal use and will be removed next.
Reviewed By: passy
Differential Revision: D46850048
fbshipit-source-id: d6dce961d5cbd767f428e58850d24a433d50ba14
Summary: Not really part of the connect process in this case, so is getting moved closer to where the CSR is generated.
Reviewed By: passy
Differential Revision: D46849966
fbshipit-source-id: b91e2925552cd7fcab67b3d1d7af006f4f8c1431
Summary: This was a temporary variable which is not really needed, so remove.
Reviewed By: passy
Differential Revision: D46849864
fbshipit-source-id: 56fb52f9a80128fb746afcdc4d36225e6d596db2
Summary:
The event handler is a friend type that was mutating the connection manager state.
Instead, just forward the event handling to it.
Then state mutation is consolidated inside the connection manager.
Reviewed By: passy
Differential Revision: D46849769
fbshipit-source-id: 594ab32c8e891564afa94e1be6b93b1dfeffe26f
Summary:
Expose a new API to be used to check if there's an open connection with Flipper Desktop.
Changelog: new FlipperClient isConnected API
Reviewed By: antonk52
Differential Revision: D46841095
fbshipit-source-id: 82a60f52496fb218cb50c6a28d7ffe7225ae23aa
Summary: Add custom log handler setup so people can use their own log infra instead of "printf".
Reviewed By: Neil-Clifford-FB
Differential Revision: D46590343
fbshipit-source-id: ded9cf6caa580d477a71a9155cad9db295151c84
Summary: Replacing global static varaibles with local static. No cost at startup time, and also fixes any potential static initialization order fiasco.
Differential Revision: D45900297
fbshipit-source-id: 80e3ffb6527f7f7b6b08de4a6209f0f8298f7bf5
Summary:
^
There could be cases, albeit unlikely, that logs could be appended for the current state indefintely that would ultimate fail due to not having enough memory.
This change puts a cap on that.
Reviewed By: mweststrate
Differential Revision: D42313904
fbshipit-source-id: 7fd96be822c9427720bccb41c6c32a39213c7652
Summary:
So far, Flipper has concatenated paths assuming is only ever built on unix-like systems.
For RNW, this approach fails.
This change is a very simple way of achieving WIN32 support without using any extra libraries or routines for path building.
Reviewed By: antonk52
Differential Revision: D39053479
fbshipit-source-id: e8b4b71cc1d17ca6aba88d40cad7d96a30ad1267
Summary:
This change is the direct results of doing the following:
npx react-native-windows-init --overwrite
Notes: ignore the format warnings below. In this case, the ordering of includes does matter. Missing license is for auto-generated files, so ignore too.
Reviewed By: aigoncharov
Differential Revision: D36775215
fbshipit-source-id: 1cd00ff2bfc258c8505e97dcdbd9cb4365c4acfb
Summary:
^
The last change removed the overload of `send` in favour of `sendRaw`
Reviewed By: LukeDefeo
Differential Revision: D38946386
fbshipit-source-id: c4491c4afe4d719602c99878dc7185d436179aef
Summary:
folly::dynamic, std::string, implicit constructors and method overloading is not a good combination.
This renames the send method to sendRaw as to avoid issues with existing plugins currently sending string params.
Reviewed By: mweststrate
Differential Revision: D38827539
fbshipit-source-id: 653f62e41ebfbe93d1af25f39c81f6b05bf84cb4
Summary:
For C++, folly::dynamic is used throughout.
On iOS and Android though, Flipper goes through multiple conversions to get to a folly::dynamic only to ultimately obtain a JSON string from it.
Let's take a look at Android:
There are multiple types like FlipperObject, FlipperArray that wrap around a JSONObject.
When data needs to be sent:
1. The JSONObject is asked for its string representation.
2. The string representation is then parsed by folly to construct the folly::dynamic instance.
3. The step above involves an extra boundary cross through JNI.
4. Ultimately, a socket or ws connection does not understand folly::dynamic so we then get a JSON string representation from it.
5. Data is sent.
As described above, for big enough objects, this represents an issue.
So, the idea of this change, is to allow plugins to send a JSON string instead. This will remove a few serialisation/deserialisation steps from the process.
*Note: this API is not currently used by anything so there's no impact to existing plugins.*
Changelog: expose a send method that accept a string as params
Reviewed By: LukeDefeo
Differential Revision: D38741582
fbshipit-source-id: 78e0acd80fc8c97378ee986cbaf377078996ed60
Summary:
Plumbs through an optional name for FollyScopedThreadScheduler.
This allows the threads to be named in XCode/lldb.
Differential Revision: D38582449
fbshipit-source-id: 1de50d25c0f91e7003cf81cb22faf4b10a8e23a8
Summary:
Quoting lblasa:
History trip:
- It was used at the beginning of times with RSocket.
- RSocket introduced an RPC mechanism so a new responder was introduced which used it, thus making this responder legacy.
- WebSockets is introduced which doesn't have an RPC mechanism by default so this responder became the new non-legacy responder
Reviewed By: lblasa
Differential Revision: D37994288
fbshipit-source-id: 2458aed129058a5bfaafd607e73c52867d9713cf
Summary:
^
If Flipper stops, we cannot freely access the client outside of the scheduler.
There may be an scheduled operation that depends on it.
Instead, schedule the stop and wait until it finishes.
Reviewed By: cekkaewnumchai
Differential Revision: D37814820
fbshipit-source-id: 44217b5f623a8d92211a3d72a4a204d674b4bb76
Summary:
This change isolates the usage of folly async from Flipper. Is now self-contained in Flipper Folly schedulers.
Users of Flipper can decide not to use the types defined in that header and implement their own.
NOTE: changes are minimal, we are just replacing direct calls to folly event base with a scheduler which simply relays this on to folly.
Reviewed By: fabiomassimo
Differential Revision: D36626483
fbshipit-source-id: add0241caf4af0aa5c3b5c2e7efc2e725f5400ab
Summary:
This change isolates the usage of folly async from Flipper. Is now self-contained in Flipper Folly schedulers.
Users of Flipper can decide not to use the types defined in that header and implement their own.
NOTE: changes are minimal, we are just replacing direct calls to folly event base with a scheduler which simply relays this on to folly.
Reviewed By: fabiomassimo
Differential Revision: D36052198
fbshipit-source-id: 170d64a324a1f1f100224e2622a59cbac3c8b642
Summary:
^
It was used by rsocket.
Reviewed By: fabiomassimo
Differential Revision: D36246038
fbshipit-source-id: 8bdc77d9e1ecf22402436e0102b5522ed36aff27
Summary:
Flipper doesn really use library specific exceptions throughout, and that's OK.
Introducing SSLException as a replacement for the existing Folly Async Socket SSL exception.
This exception originally thrown by rsocket. Because we had rsocket and websockets using the same code, websockets were creating and throwing this same exception.
With rsocket gone, we can fully replace the usage of that exception. This is also needed as to decouple Flipper from folly async components.
Reviewed By: fabiomassimo
Differential Revision: D36245624
fbshipit-source-id: f5c97c5efe063280ce95be130008dee7f4e5d788
Summary: Introduce a 'Scheduler' interface which will allow to decouple from the existing used Folly scheduler.
Reviewed By: fabiomassimo
Differential Revision: D36245587
fbshipit-source-id: 2f28bc1612e37ae53060a134d1c8059231fbc8ad
Summary:
^
Change necessary when OpenSSL is compiled without STDIO for file operations. Basically, don't use the BIO file API's. Instead use in-memory BIO and do file operations manually.
UPDATE:
The changes were good, but have been simplified and fixed. A fixed was needed as to read and write the file in binary mode. This has no effect in POSIX systems but it does on Windows and this change was made for Windows. It meant that the BIO was incorrectly written to disk thus corrupting its content.
Changelog: Remove OpenSSL file BIO operations
Reviewed By: jknoxville
Differential Revision: D36060992
fbshipit-source-id: 21b30582dd0b32c24b8ba001d6993034d92de1da
Summary:
^
There's a similar issue/request for Android. So, this change moves the code out from the FlipperKit into Flipper as to be able to reuse it.
Reviewed By: aigoncharov
Differential Revision: D35961745
fbshipit-source-id: aa255db582a7852dc06c2feaba389d1dac3b0f67
Summary:
^
:android:third-party task, on ocassions, gets parallelised with the :configureCMake task resulting in build errors.
:configureCMake depends on dependencies being in-place and patched.
Our current setup was achieving this via setting these tasks as dependencies of the preBuild task.
Unfortunately, this seems not be a bullet-proof solution.
This patch aims to improve this situation by ensuring the tasks are executed before :configureCMake. Whatever happens first.
Changelog: Execute :third-party:prepare before :configureCMake task on Android
Reviewed By: passy
Differential Revision: D36001637
fbshipit-source-id: 6c53b6852e40e354337c0ac940b5bbad4ef83078
Summary:
To ensure that no deadlocks take place, it is important that there are no re-entrant calls from within the callbacks or event handlers.
For the most part, this was already the case. Event and message handlers run critical sections into a Folly event scheduler.
The only exception was the sendExpectResponse used during the certificate exchange. Once the response was received, the non-secure socket was disconnected.
The solution was to put that operation in the Folly event scheduler as it should've been from the beginning.
changelog: Certificate signing request response to be processed on the right event loop.
Reviewed By: fabiomassimo
Differential Revision: D35548148
fbshipit-source-id: cea2476ad66137f376acda66cdbc27801c0c47e1
Summary:
^
Changes include:
- C++ WebSocket integration
- Explicit asio namespace usage as namespace asio = websocketpp::lib::asio; this way we don't care if boost::asio or just asio is used in the end.
Reviewed By: javache
Differential Revision: D34388770
fbshipit-source-id: d0b3ee8ac687751ab1b93d483729eb2baccb8687
Summary:
^
Note: this is already a working case. The difference is that if we are unable to establish a socket connection, we will not attempt to create one using rsocket.
Changelog: Removes rsocket-fallback for mobile clients
Reviewed By: nikoant
Differential Revision: D33655430
fbshipit-source-id: cb6f752f2d1354ab46d011b1f19c89520e1e7dd3
Summary:
Introducing a Flipper WebSocket client implemented in C++.
The requirement came from Spark AR (Skylight) as they have a macOS/Linux/Windows clients.
For reviewers:
- This is an implementation of the existing FlipperSocket interface. Effectively, the only type that needs to be reviewed is WebSocketTLSClient.
- BaseClient defined a base class for WebSocketClient and WebSocketTLSClient.
- WebSocketClient is a simplified version of WebSocketTLSClient as there's no TLS configuration.
Reviewed By: mweststrate
Differential Revision: D34081943
fbshipit-source-id: 619a83f5a6783a21069d0f5111d139bb180f9e97
Summary:
^
This change allow callers to retrieve the path of different store items some of which are used for connection authentication.
Reviewed By: aigoncharov
Differential Revision: D34081942
fbshipit-source-id: c6b8d3590993de6c48a36266a5c16f2caf9f5a93
Summary:
The problem seems to be exclusive to Android emulators.
Bringing the emulator ON from a warm state brings the app from is previous state before shutting down. At this point there may have been a Flipper connection.
Flipper tries to connect and does so successfully replacing the previously, now dead connection.
The problem is that replacing that connection triggers the reconnect cycle as Flipper thinks the connection is dead and hence the reconnect loop initiates.
Changelog: Release an existing client before attempting a secure connection
Reviewed By: passy
Differential Revision: D34080726
fbshipit-source-id: 8185adb492dd4d9255fcea5874ca2e5b7fee0c84
Summary:
This change adds a safety net for receivers that may throw an exception on invocation.
Without this change, the exception is logged but not shown in Flipper.
Reviewed By: nikoant
Differential Revision: D34001224
fbshipit-source-id: ca07d3dd006b277e306ecbc1c033845929a83f4c
Summary:
Changelog: Fallback to RSockets if cert exchange fails even if the connection was successful.
Currently, we fallback to RSockets only if the connected is rejected.
It turns out that WS server does not reject connection from our RSocket client. Instead, it rejects the messages.
As result, requestSignedCertFromFlipper fails, but it never triggers the change of protocol.
With this diff we start evaluating if we need to change our protocol for every socket error.
Reviewed By: lblasa
Differential Revision: D33890235
fbshipit-source-id: f79b5c6992f01f8a93e0793e180a5cbd4a105619
Summary:
^
Changelog: Minimises the probability of throwing an exception if no exchange medium is known
Reviewed By: passy
Differential Revision: D33620655
fbshipit-source-id: e03e7fed0607c376add218ee98dcd2bd0f8880f1
Summary:
^
There was an issue for some characters in newer android API versions. One option was to fix our implementation, which can be done by casting to char to unsigned int before using std::isalnum.
But, do not duplicate existing functionality, used a solid implementation instead.
Changelog: Fixes an issue whereas the url encoding was incorrect for UTF-8
Reviewed By: mweststrate
Differential Revision: D33405760
fbshipit-source-id: e1c0a4da3dceb27e923b26d0ebfac091febeceb3