Skip to content

Add support for RPC V2#1087

Open
1egoman wants to merge 15 commits into
mainfrom
add-rpc-v2
Open

Add support for RPC V2#1087
1egoman wants to merge 15 commits into
mainfrom
add-rpc-v2

Conversation

@1egoman
Copy link
Copy Markdown
Contributor

@1egoman 1egoman commented May 15, 2026

See this pull request for more info about what this does and how rpc v2 works: livekit/client-sdk-js#1832

Also, for an in depth description of behavior in edge cases, see RPC_SPEC.md here.

Warning

This pull request was LLM generated and has only been lightly reviewed by the author, who is not a flutter expert. I have tested this and can confirm it works in the happy path, but no other validation has been done.

A more thorough review of this needs to occur before it could be merged.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 15, 2026

Caution

Breaking change detected without major changeset

dart-apitool detected the following breaking changes:

Preparing git repository: https://github.com/livekit/client-sdk-flutter
Using ref: main
Cloning git repository: https://github.com/livekit/client-sdk-flutter
Checking out ref: main
Successfully cloned to: /tmp/HNUKHB
Preparing package dependencies for git package https://github.com/livekit/client-sdk-flutter (forced Flutter)
Resolving dependencies...
Downloading packages...
  _fe_analyzer_shared 85.0.0 (100.0.0 available)
  analyzer 7.7.1 (13.0.0 available)
  build 2.5.4 (4.0.6 available)
  build_config 1.1.2 (1.3.0 available)
  build_resolvers 2.5.4 (3.0.4 available)
  build_runner 2.5.4 (2.15.0 available)
  build_runner_core 9.1.2 (9.3.2 available)
  built_value 8.12.4 (8.12.6 available)
  dart_style 3.1.1 (3.1.9 available)
  dart_webrtc 1.8.0 (1.8.1 available)
  device_info_plus 12.3.0 (13.1.0 available)
  device_info_plus_platform_interface 7.0.3 (8.1.0 available)
  flutter_webrtc 1.4.0 (1.4.1 available)
  hooks 1.0.2 (1.0.3 available)
  json_annotation 4.9.0 (4.12.0 available)
  json_serializable 6.9.5 (6.14.0 available)
  matcher 0.12.19 (0.12.20 available)
  meta 1.17.0 (1.18.2 available)
  mockito 5.4.6 (5.6.5 available)
  native_toolchain_c 0.17.6 (0.18.0 available)
  path_provider_android 2.2.22 (2.3.1 available)
  source_gen 2.0.0 (4.2.3 available)
  source_helper 1.3.7 (1.3.12 available)
  synchronized 3.4.0 (3.4.0+1 available)
  test_api 0.7.10 (0.7.12 available)
  vector_math 2.2.0 (2.3.0 available)
  vm_service 15.0.2 (15.2.0 available)
  win32 5.15.0 (6.2.0 available)
  win32_registry 2.1.0 (3.0.3 available)
  xml 6.6.1 (7.0.1 available)
Got dependencies!
30 packages have newer versions incompatible with dependency constraints.
Try `flutter pub outdated` for more information.
Resolving dependencies in `./example`...
Downloading packages...
Got dependencies in `./example`.
Preparing . (forced Flutter)
Copying sources from .
Preparing package dependencies for local package . (forced Flutter)
Resolving dependencies...
Downloading packages...
  _fe_analyzer_shared 85.0.0 (100.0.0 available)
  analyzer 7.7.1 (13.0.0 available)
  build 2.5.4 (4.0.6 available)
  build_config 1.1.2 (1.3.0 available)
  build_resolvers 2.5.4 (3.0.4 available)
  build_runner 2.5.4 (2.15.0 available)
  build_runner_core 9.1.2 (9.3.2 available)
  built_value 8.12.4 (8.12.6 available)
  dart_style 3.1.1 (3.1.9 available)
  dart_webrtc 1.8.0 (1.8.1 available)
  device_info_plus 12.3.0 (13.1.0 available)
  device_info_plus_platform_interface 7.0.3 (8.1.0 available)
  flutter_webrtc 1.4.0 (1.4.1 available)
  hooks 1.0.2 (1.0.3 available)
  json_annotation 4.9.0 (4.12.0 available)
  json_serializable 6.9.5 (6.14.0 available)
  matcher 0.12.19 (0.12.20 available)
  meta 1.17.0 (1.18.2 available)
  mockito 5.4.6 (5.6.5 available)
  native_toolchain_c 0.17.6 (0.18.0 available)
  path_provider_android 2.2.22 (2.3.1 available)
  source_gen 2.0.0 (4.2.3 available)
  source_helper 1.3.7 (1.3.12 available)
  synchronized 3.4.0 (3.4.0+1 available)
  test_api 0.7.10 (0.7.12 available)
  vector_math 2.2.0 (2.3.0 available)
  vm_service 15.0.2 (15.2.0 available)
  win32 5.15.0 (6.2.0 available)
  win32_registry 2.1.0 (3.0.3 available)
  xml 6.6.1 (7.0.1 available)
Got dependencies!
30 packages have newer versions incompatible with dependency constraints.
Try `flutter pub outdated` for more information.
Resolving dependencies in `./example`...
Downloading packages...
Got dependencies in `./example`.
Omitting pub get (package config already present)
Analyzing /tmp/HNUKHB
Omitting pub get (package config already present)
Analyzing .
Cleaning up
Cleaning up
Checking Package version
ignoring prerelease
-- Generating report using: Console Reporter --
BREAKING CHANGES
├── Field "kRpcVesion" removed (CF01)
└─┬ Class Participant
  └── Field "clientProtocol" added (required) (CF02)
Non-Breaking changes
├── Interface "ClientProtocolVersion" added (CI02) (minor)
├── Interface "PacketTrailerFeature" added (CI02) (minor)
├── Interface "ClientProtocolVersionExt" added (CI02) (minor)
├── Field "kRpcVesion" added (CF02) (minor)
├── Field "kRpcVersion" added (CF02) (minor)
├── Field "kRpcRequestTopic" added (CF02) (minor)
├── Field "kRpcResponseTopic" added (CF02) (minor)
├── Field "kRpcAttrRequestId" added (CF02) (minor)
├── Field "kRpcAttrMethod" added (CF02) (minor)
├── Field "kRpcAttrResponseTimeoutMs" added (CF02) (minor)
├── Field "kRpcAttrVersion" added (CF02) (minor)
├── Field "kRpcRequestVersionV2" added (CF02) (minor)
├─┬ Class ConnectOptions
│ ├── Field "clientProtocolVersion" added (CF02) (minor)
│ └─┬ Constructor new
│   └── Parameter "clientProtocolVersion" added (CE02) (minor)
├─┬ Class RemoteParticipant
│ └── Field "clientProtocol" added (CF02) (minor)
├─┬ Class lk_models.TrackInfo
│ ├── Field "packetTrailerFeatures" added (CF02) (minor)
│ └─┬ Constructor new
│   └── Parameter "packetTrailerFeatures" added (CE02) (minor)
├─┬ Class LocalParticipant
│ └── Field "clientProtocol" added (CF02) (minor)
├─┬ Class RpcRequest
│ ├── Method "hasCompressedPayload" added (CE11) (minor)
│ ├── Method "clearCompressedPayload" added (CE11) (minor)
│ ├── Field "compressedPayload" added (CF02) (minor)
│ └─┬ Constructor new
│   └── Parameter "compressedPayload" added (CE02) (minor)
├─┬ Class RpcResponse
│ ├── Method "hasCompressedPayload" added (CE11) (minor)
│ ├── Method "clearCompressedPayload" added (CE11) (minor)
│ ├── Field "compressedPayload" added (CF02) (minor)
│ └─┬ Constructor new
│   └── Parameter "compressedPayload" added (CE02) (minor)
├─┬ Class RpcResponse_Value
│ └── Field "compressedPayload" added (CF02) (minor)
└─┬ Class lk_models.ParticipantPermission
  ├── Method "hasCanManageAgentSession" added (CE11) (minor)
  ├── Method "clearCanManageAgentSession" added (CE11) (minor)
  ├── Field "canManageAgentSession" added (CF02) (minor)
  └─┬ Constructor new
    └── Parameter "canManageAgentSession" added (CE02) (minor)
To learn more about the detected changes visit: https://github.com/bmw-tech/dart_apitool/blob/main/readme/change_codes.md
Version Check
New Version is too low!

Old version: "2.7.0"
New version: "2.7.0"
Needed version: "3.0.0"

Got "2.7.0" expected >= "3.0.0" (breaking changes)

If this is intentional, please add a changeset with major level in .changes/:

major type="changed" "Description of breaking change"

@1egoman
Copy link
Copy Markdown
Contributor Author

1egoman commented May 15, 2026

^ In the above "breaking change" warning, it looks like the issue is:

BREAKING CHANGES
└─┬ Class Participant
  └── Field "clientProtocol" added (required) (CF02)

But it's a field addition... That shouldn't be a breaking change? Let me know what I am missing - I could I think make this private, but I'd need to verify that is ok first.

Comment on lines +70 to +72
final remoteParticipant = _room.getParticipantByIdentity(destination);
final remoteProtocol = remoteParticipant?.clientProtocol ?? ClientProtocolVersion.v0.toIntValue();
final useV2 = remoteProtocol >= ClientProtocolVersion.v1.toIntValue();
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

thought: I wonder if it would be cleaner to make ClientProtocolVersion implement Comparable (this) to avoid all the toIntValue()s here?

Comment thread test/core/rpc_test.dart
Comment on lines 26 to 35
E2EContainer? container;
late Room room;

group('rpc tests', () {
test('test rpc handler register', () async {
container = E2EContainer();
room = container!.room;
await container!.connectRoom();

room.registerRpcMethod('echo', (RpcInvocationData data) async {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

question: Heads up that I kept all the old / pre-existing rpc v1 tests around. I'm not sure though if this is really still needed, because the new tests should be testing all the same paths. I'll defer to what others think here, I don't have a strong opinion on if they should be kept or removed.

@1egoman 1egoman marked this pull request as ready for review May 15, 2026 20:46
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.

1 participant