Skip to content

Commit

Permalink
Fix synchronization on collaboration
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Jan 17, 2025
1 parent 2f243b6 commit 6bca355
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 52 deletions.
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

| Version | Supported | |
| --------- | ------------------ | -------------------------------------------------------------------------------------------------------------------------------- |
| 2.2.3-dev | :warning: | [Docs](https://butterfly.linwood.dev/docs/2.2/intro) [Release](https://github.com/LinwoodDev/butterfly/releases/tag/v2.2.3-rc.2) |
| 2.3-dev | :warning: | [Docs](https://butterfly.linwood.dev/docs/2.2/intro) [Release](https://github.com/LinwoodDev/butterfly/releases/tag/v2.3.0-beta.0) |
| 2.2.3 | :white_check_mark: | [Docs](https://butterfly.linwood.dev/docs/2.2/intro) [Release](https://github.com/LinwoodDev/butterfly/releases/tag/v2.2.3) |
| 2.1.1 | :x: | [Docs](https://butterfly.linwood.dev/docs/2.1/intro) [Release](https://github.com/LinwoodDev/butterfly/releases/tag/v2.1.1) |
| 2.0.3 | :x: | [Docs](https://butterfly.linwood.dev/docs/2.0/intro) [Release](https://github.com/LinwoodDev/butterfly/releases/tag/v2.0.3) |
Expand Down
4 changes: 2 additions & 2 deletions api/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ packages:
path: "packages/dart_leap"
ref: db69a03082e6811c58dc2d0e5c23d04305e1623f
resolved-ref: db69a03082e6811c58dc2d0e5c23d04305e1623f
url: "https://github.com/LinwoodDev/dart_pkgs"
url: "https://github.com/LinwoodDev/dart_pkgs.git"
source: git
version: "1.0.0"
dart_mappable:
Expand Down Expand Up @@ -333,7 +333,7 @@ packages:
path: "packages/lw_file_system_api"
ref: e4c17cb5e3a53c0cd02d4127458c2215f7c6e7d4
resolved-ref: e4c17cb5e3a53c0cd02d4127458c2215f7c6e7d4
url: "https://github.com/LinwoodDev/dart_pkgs"
url: "https://github.com/LinwoodDev/dart_pkgs.git"
source: git
version: "1.0.0"
macros:
Expand Down
4 changes: 2 additions & 2 deletions api/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ dependencies:
xml: ^6.5.0
lw_file_system_api:
git:
url: https://github.com/LinwoodDev/dart_pkgs
url: https://github.com/LinwoodDev/dart_pkgs.git
path: packages/lw_file_system_api
ref: e4c17cb5e3a53c0cd02d4127458c2215f7c6e7d4
dart_leap:
git:
url: https://github.com/LinwoodDev/dart_pkgs
url: https://github.com/LinwoodDev/dart_pkgs.git
path: packages/dart_leap
ref: db69a03082e6811c58dc2d0e5c23d04305e1623f

Expand Down
36 changes: 13 additions & 23 deletions app/lib/services/network.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,23 +90,17 @@ class NetworkingService {
void sendConnections() {
final current = server.clientConnections;
_connections.add(current);
rpc.sendMessage(RpcNetworkerPacket(
function: NetworkEvent.connections.index,
data: Uint8List.fromList(jsonEncode(current.toList()).codeUnits),
channel: kAuthorityChannel,
));
rpc.sendNamedFunction(
NetworkEvent.connections,
Uint8List.fromList(jsonEncode(current.toList()).codeUnits),
);
}

server.clientConnect.listen((event) async {
final state = _bloc?.state;
if (state is! DocumentLoaded) return;
rpc.sendMessage(
RpcNetworkerPacket(
function: NetworkEvent.init.index,
data: await state.saveBytes(),
channel: kAuthorityChannel,
),
event.$1);
rpc.sendNamedFunction(NetworkEvent.init, await state.saveBytes(),
channel: event.$1);
sendConnections();
});
server.clientDisconnect.listen((event) {
Expand All @@ -122,7 +116,7 @@ class NetworkingService {
if (!uri.hasPort) {
uri = uri.replace(port: kDefaultPort);
}
if(!uri.hasScheme) {
if (!uri.hasScheme) {
uri = uri.replace(scheme: 'ws');
}
final client = NetworkerSocketClient(uri);
Expand Down Expand Up @@ -173,24 +167,20 @@ class NetworkingService {
}

void sendUser(NetworkingUser user) {
state?.$2.sendMessage(RpcNetworkerPacket(
function: NetworkEvent.user.index,
data: Uint8List.fromList(jsonEncode(user.toJson()).codeUnits),
channel: kAuthorityChannel,
));
state?.$2.sendNamedFunction(NetworkEvent.user,
Uint8List.fromList(jsonEncode(user.toJson()).codeUnits));
}

bool _externalEvent = false;

void onEvent(DocumentEvent event) {
if (!event.shouldSync() || _externalEvent) return;
state?.$2.sendMessage(RpcNetworkerPacket(
function: NetworkEvent.event.index,
data: Uint8List.fromList(
state?.$2.sendNamedFunction(
NetworkEvent.event,
Uint8List.fromList(
jsonEncode(event.toJson()).codeUnits,
),
channel: state?.$1 is NetworkerServer ? kAuthorityChannel : kAnyChannel,
));
);
}

void onMessage(DocumentEvent event) {
Expand Down
30 changes: 15 additions & 15 deletions app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ packages:
path: "packages/dart_leap"
ref: db69a03082e6811c58dc2d0e5c23d04305e1623f
resolved-ref: db69a03082e6811c58dc2d0e5c23d04305e1623f
url: "https://github.com/LinwoodDev/dart_pkgs"
url: "https://github.com/LinwoodDev/dart_pkgs.git"
source: git
version: "1.0.0"
dart_mappable:
Expand Down Expand Up @@ -781,9 +781,9 @@ packages:
dependency: "direct main"
description:
path: "packages/lw_file_system"
ref: "760972dc351ab9aecd3df37e8679b2b029f34e80"
resolved-ref: "760972dc351ab9aecd3df37e8679b2b029f34e80"
url: "https://github.com/LinwoodDev/dart_pkgs"
ref: ada8a1a9ef9624cb0c546b318247626c7514b6ea
resolved-ref: ada8a1a9ef9624cb0c546b318247626c7514b6ea
url: "https://github.com/LinwoodDev/dart_pkgs.git"
source: git
version: "1.0.0"
lw_file_system_api:
Expand All @@ -792,7 +792,7 @@ packages:
path: "packages/lw_file_system_api"
ref: e4c17cb5e3a53c0cd02d4127458c2215f7c6e7d4
resolved-ref: e4c17cb5e3a53c0cd02d4127458c2215f7c6e7d4
url: "https://github.com/LinwoodDev/dart_pkgs"
url: "https://github.com/LinwoodDev/dart_pkgs.git"
source: git
version: "1.0.0"
lw_sysapi:
Expand All @@ -801,7 +801,7 @@ packages:
path: "packages/lw_sysapi"
ref: ebf47114a4d63fc06a6be0dbbfd5594ed82e7ee5
resolved-ref: ebf47114a4d63fc06a6be0dbbfd5594ed82e7ee5
url: "https://github.com/LinwoodDev/dart_pkgs"
url: "https://github.com/LinwoodDev/dart_pkgs.git"
source: git
version: "0.0.1"
macros:
Expand Down Expand Up @@ -840,9 +840,9 @@ packages:
dependency: "direct main"
description:
path: "packages/material_leap"
ref: e0bff15c46124cef83b428b3b6f566ce8726eca2
resolved-ref: e0bff15c46124cef83b428b3b6f566ce8726eca2
url: "https://github.com/LinwoodDev/dart_pkgs"
ref: ada8a1a9ef9624cb0c546b318247626c7514b6ea
resolved-ref: ada8a1a9ef9624cb0c546b318247626c7514b6ea
url: "https://github.com/LinwoodDev/dart_pkgs.git"
source: git
version: "0.0.1"
meta:
Expand Down Expand Up @@ -873,18 +873,18 @@ packages:
dependency: "direct main"
description:
path: "packages/networker/networker"
ref: "4d8b20841bcfa644695963c69f3e3032b764d283"
resolved-ref: "4d8b20841bcfa644695963c69f3e3032b764d283"
url: "https://github.com/LinwoodDev/dart_pkgs"
ref: "0bdc62d3af7f31e19a694d9cd39fe020dced8754"
resolved-ref: "0bdc62d3af7f31e19a694d9cd39fe020dced8754"
url: "https://github.com/LinwoodDev/dart_pkgs.git"
source: git
version: "1.0.0"
networker_socket:
dependency: "direct main"
description:
path: "packages/networker/networker_socket"
ref: "630928b8588064a0895e45ca91993ce05723811f"
resolved-ref: "630928b8588064a0895e45ca91993ce05723811f"
url: "https://github.com/LinwoodDev/dart_pkgs"
ref: fa036587c2a26db6455dd063701aef32b3531800
resolved-ref: fa036587c2a26db6455dd063701aef32b3531800
url: "https://github.com/LinwoodDev/dart_pkgs.git"
source: git
version: "1.0.0"
nm:
Expand Down
18 changes: 9 additions & 9 deletions app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,28 +78,28 @@ dependencies:
ref: 85a6db5889db2916733a0f6c6914e66d06931f71
material_leap:
git:
url: https://github.com/LinwoodDev/dart_pkgs
ref: e0bff15c46124cef83b428b3b6f566ce8726eca2
url: https://github.com/LinwoodDev/dart_pkgs.git
ref: ada8a1a9ef9624cb0c546b318247626c7514b6ea
path: packages/material_leap
lw_sysapi:
git:
url: https://github.com/LinwoodDev/dart_pkgs
url: https://github.com/LinwoodDev/dart_pkgs.git
ref: ebf47114a4d63fc06a6be0dbbfd5594ed82e7ee5
path: packages/lw_sysapi
networker:
git:
url: https://github.com/LinwoodDev/dart_pkgs
ref: 4d8b20841bcfa644695963c69f3e3032b764d283
url: https://github.com/LinwoodDev/dart_pkgs.git
ref: 0bdc62d3af7f31e19a694d9cd39fe020dced8754
path: packages/networker/networker
networker_socket:
git:
url: https://github.com/LinwoodDev/dart_pkgs
ref: 630928b8588064a0895e45ca91993ce05723811f
url: https://github.com/LinwoodDev/dart_pkgs.git
ref: fa036587c2a26db6455dd063701aef32b3531800
path: packages/networker/networker_socket
lw_file_system:
git:
url: https://github.com/LinwoodDev/dart_pkgs
ref: 760972dc351ab9aecd3df37e8679b2b029f34e80
url: https://github.com/LinwoodDev/dart_pkgs.git
ref: ada8a1a9ef9624cb0c546b318247626c7514b6ea
path: packages/lw_file_system
flutter_localized_locales: ^2.0.5
dynamic_color: ^1.7.0
Expand Down

0 comments on commit 6bca355

Please sign in to comment.