### CMake Installation Rules for Application Bundle Source: https://github.com/connectycube/connectycube-flutter-samples/blob/master/conf_call_sample/linux/CMakeLists.txt This section defines the installation process for the Flutter application. It ensures a clean build bundle directory, installs the executable, Flutter ICU data, the main Flutter library, and any bundled plugin libraries to their respective destinations within the installation prefix. ```cmake # === Installation === # By default, "installing" just makes a relocatable bundle in the build # directory. set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() # Start with a clean build bundle directory every time. install(CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) install(FILES "${bundled_library}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endforeach(bundled_library) # Fully re-copy the assets directory on each build to avoid having stale files ``` -------------------------------- ### CMake Installation Rules for Application Bundle Source: https://github.com/connectycube/connectycube-flutter-samples/blob/master/p2p_call_sample/linux/CMakeLists.txt Configures the installation process to create a relocatable application bundle. It cleans the build directory, installs the executable, and copies necessary data and library files. ```cmake set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() install(CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) install(FILES "${bundled_library}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endforeach(bundled_library) ``` -------------------------------- ### Installation Rules for Connectycube Flutter App Source: https://github.com/connectycube/connectycube-flutter-samples/blob/master/conf_call_sample/windows/CMakeLists.txt Specifies the installation rules for the Connectycube Flutter application. This includes installing the main executable, Flutter ICU data, libraries, bundled plugin libraries, and the assets directory. It ensures that all necessary components are placed correctly for the application to run, especially when building from Visual Studio. ```cmake # === Installation === # Support files are copied into place next to the executable, so that it can # run in place. This is done instead of making a separate bundle (as on Linux) # so that building and running from within Visual Studio will work. set(BUILD_BUNDLE_DIR "$") # Make the "install" step default, as it's required to run. set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() # Fully re-copy the assets directory on each build to avoid having stale files # from a previous install. set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) # Install the AOT library on non-Debug builds only. install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### CMake Installation Rules for Flutter App Bundle Source: https://github.com/connectycube/connectycube-flutter-samples/blob/master/chat_sample/linux/CMakeLists.txt Configures the installation process to create a relocatable application bundle. It cleans the build directory, installs the executable, Flutter ICU data, the core Flutter library, bundled plugin libraries, and the Flutter assets directory, ensuring all necessary components are correctly placed for runtime. ```cmake set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() install(CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) install(FILES "${bundled_library}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endforeach(bundled_library) set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install Flutter Assets using CMake Source: https://github.com/connectycube/connectycube-flutter-samples/blob/master/p2p_call_sample/linux/CMakeLists.txt This script installs Flutter assets into the application bundle. It first removes any existing 'flutter_assets' directory and then copies the new assets from the build directory to the installation destination. This ensures that the latest assets are always deployed. ```cmake set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### CMake Build Configuration and Settings Source: https://github.com/connectycube/connectycube-flutter-samples/blob/master/chat_sample/windows/CMakeLists.txt This snippet covers the initial CMake setup, including project declaration, build mode configuration (Debug, Profile, Release), and setting standard compilation options and features for C++ projects. It ensures consistent build environments and applies necessary flags for different build types. ```cmake cmake_minimum_required(VERSION 3.15) project(chat_sample LANGUAGES CXX) set(BINARY_NAME "chat_sample") cmake_policy(SET CMP0063 NEW) set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") # Configure build options. get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) if(IS_MULTICONFIG) set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" CACHE STRING "" FORCE) else() if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Flutter build mode" FORCE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Profile" "Release") endif() endif() set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") # Use Unicode for all projects. add_definitions(-DUNICODE -D_UNICODE) # Compilation settings that should be applied to most targets. function(APPLY_STANDARD_SETTINGS TARGET) target_compile_features(${TARGET} PUBLIC cxx_std_17) target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") target_compile_options(${TARGET} PRIVATE /EHsc) target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") endfunction() ``` -------------------------------- ### Flutter Chat Sample - Troubleshooting Common Issues Source: https://github.com/connectycube/connectycube-flutter-samples/blob/master/chat_sample/README.md This code block provides commands to clean and rebuild your Flutter project, which can help resolve common issues like unresolved references. It involves running `flutter clean`, `flutter pub get`, and Android-specific Gradle cleaning. ```bash flutter clean flutter pub get cd android ./gradlew clean cd .. ``` -------------------------------- ### Configure Flutter Tool Backend Assembly with CMake Source: https://github.com/connectycube/connectycube-flutter-samples/blob/master/conf_call_sample/windows/flutter/CMakeLists.txt This CMake setup defines a custom command to invoke the Flutter tool backend script. It's designed to run every time due to a phony output file, ensuring that the Flutter library, headers, and wrapper sources are assembled correctly for the Windows build configuration. ```cmake # === Flutter tool backend === # _phony_ is a non-existent file to force this command to run every time, # since currently there's no way to get a full input/output list from the # flutter tool. set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) add_custom_command( OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ${CPP_WRAPPER_SOURCES_APP} ${PHONY_OUTPUT} COMMAND ${CMAKE_COMMAND} -E env ${FLUTTER_TOOL_ENVIRONMENT} "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" windows-x64 $ VERBATIM ) add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ${CPP_WRAPPER_SOURCES_APP} ) ``` -------------------------------- ### Initialize Chat Message Listeners in Flutter Source: https://context7.com/connectycube/connectycube-flutter-samples/llms.txt Sets up listeners for incoming chat messages, delivery and read statuses, typing indicators, and reactions. It requires a dialog ID and a callback function for new messages. Errors in listener setup are caught and logged. ```dart import 'package:connectycube_sdk/connectycube_sdk.dart'; import 'dart:async'; class MessageManager { StreamSubscription? messageSubscription; StreamSubscription? deliveredSubscription; StreamSubscription? readSubscription; StreamSubscription? typingSubscription; StreamSubscription? reactionSubscription; // Initialize message listeners void initMessageListeners(String dialogId, Function(CubeMessage) onNewMessage) { // Listen for new messages messageSubscription = CubeChatConnection.instance .messagesManager! .messagesStream .where((message) => message.dialogId == dialogId) .listen((message) { print("New message: ${message.body}"); onNewMessage(message); }); // Listen for delivered status deliveredSubscription = CubeChatConnection.instance .messagesManager! .deliveredStream .listen((status) { print("Message ${status.messageId} delivered to ${status.userId}"); }); // Listen for read status readSubscription = CubeChatConnection.instance .messagesManager! .readStream .listen((status) { print("Message ${status.messageId} read by ${status.userId}"); }); // Listen for typing indicators typingSubscription = CubeChatConnection.instance .messagesManager! .typingStream .where((status) => status.dialogId == dialogId) .listen((status) { print("User ${status.userId} is typing: ${status.isTyping}"); }); // Listen for reactions reactionSubscription = CubeChatConnection.instance .messagesManager! .reactionsStream .listen((reaction) { print("Reaction ${reaction.reaction} on message ${reaction.messageId}"); }); } // ... other methods ... ``` -------------------------------- ### Install AOT Library Conditionally (CMake) Source: https://github.com/connectycube/connectycube-flutter-samples/blob/master/chat_sample/linux/CMakeLists.txt This snippet conditionally installs the AOT library on non-debug builds. It ensures the library is placed in the specified bundle directory as a runtime component. This configuration is specific to CMake build systems. ```cmake if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Conference Call Management in Dart Source: https://context7.com/connectycube/connectycube-flutter-samples/llms.txt Manages the lifecycle of conference calls, including starting, joining, event handling, and participant management. It utilizes the ConnectyCube SDK and requires the 'uuid' package for generating meeting IDs. ```dart import 'package:connectycube_sdk/connectycube_sdk.dart'; import 'package:flutter/material.dart'; import 'package:uuid/uuid.dart'; class ConferenceCallManager { static final ConferenceCallManager _instance = ConferenceCallManager._internal(); static ConferenceCallManager get instance => _instance; ConferenceCallManager._internal(); ConferenceSession? _conferenceSession; String? _meetingId; // Start new conference call Future startConferenceCall({ required int currentUserId, required List participantIds, required int callType, // CallType.VIDEO_CALL or CallType.AUDIO_CALL required String callName, }) async { // Generate unique meeting ID _meetingId = const Uuid().v4(); // Create conference session ConferenceSession session = await ConferenceClient.instance.createCallSession(currentUserId, callType: callType); _conferenceSession = session; // Configure video quality settings VideoConfig config = VideoConfig(); config.width = 1280; config.height = 720; config.frameRate = 30; session.setVideoConfig(config); // Setup event listeners setupConferenceListeners(session); // Send call invitations via ConnectyCube messaging await sendCallInvitations( meetingId: _meetingId!, participantIds: participantIds, callType: callType, callName: callName, ); print("Conference started: $_meetingId"); return session; } // Join existing conference Future joinConference({ required int currentUserId, required String meetingId, required int callType, }) async { _meetingId = meetingId; ConferenceSession session = await ConferenceClient.instance.createCallSession(currentUserId, callType: callType); _conferenceSession = session; setupConferenceListeners(session); print("Joining conference: $meetingId"); return session; } // Setup conference event listeners void setupConferenceListeners(ConferenceSession session) { // Local stream ready session.onLocalStreamReceived = (stream) { print("Local conference stream ready"); }; // Remote participant joined session.onRemoteStreamReceived = (userId, stream) { print("Participant $userId joined with stream"); }; // Remote participant left session.onRemoteStreamRemoved = (userId, stream) { print("Participant $userId left"); }; // Connection state changed session.onSessionStateChanged = (state) { print("Conference state: $state"); }; // Participant left session.onParticipantLeft = (userId) { print("Participant $userId disconnected"); }; } // Send call invitations to participants Future sendCallInvitations({ required String meetingId, required List participantIds, required int callType, required String callName, }) async { // Build system messages for each participant for (int participantId in participantIds) { CubeMessage message = CubeMessage(); message.recipientId = participantId; message.properties = { 'meeting_id': meetingId, 'call_type': callType.toString(), 'caller_name': callName, 'signal_type': 'startCall', 'call_opponents': participantIds.join(','), }; await sendSystemMessage(participantId, message.properties); } print("Invitations sent to ${participantIds.length} participants"); } // Enable/disable local video void toggleVideo(bool enabled) { if (_conferenceSession != null) { _conferenceSession!.setVideoEnabled(enabled); print("Conference video ${enabled ? 'enabled' : 'disabled'}"); } } // Enable/disable local audio void toggleAudio(bool enabled) { if (_conferenceSession != null) { _conferenceSession!.setAudioEnabled(enabled); print("Conference audio ${enabled ? 'enabled' : 'disabled'}"); } } // Switch camera Future switchCamera() async { if (_conferenceSession != null) { await _conferenceSession!.switchCamera(); print("Camera switched"); } } // Enable screen sharing Future startScreenSharing() async { if (_conferenceSession != null) { await _conferenceSession!.enableScreenSharing(true); print("Screen sharing started"); } } // Disable screen sharing Future stopScreenSharing() async { if (_conferenceSession != null) { await _conferenceSession!.enableScreenSharing(false); print("Screen sharing stopped"); } } // Leave conference Future leaveConference() async { if (_conferenceSession != null) { await _conferenceSession!.leave(); print("Left conference"); _conferenceSession = null; _meetingId = null; } } } ``` -------------------------------- ### Running Flutter Chat Sample on Windows Source: https://github.com/connectycube/connectycube-flutter-samples/blob/master/chat_sample/README.md Command to run the Flutter chat sample on a Windows desktop environment. This command initiates the application build and execution specifically targeting the Windows platform. ```bash flutter run -d windows ``` -------------------------------- ### Running Flutter Chat Sample on Linux Source: https://github.com/connectycube/connectycube-flutter-samples/blob/master/chat_sample/README.md Command to run the Flutter chat sample on a Linux desktop environment. This command initiates the application build and execution specifically targeting the Linux platform. ```bash flutter run -d linux ``` -------------------------------- ### Running Flutter Chat Sample on macOS Source: https://github.com/connectycube/connectycube-flutter-samples/blob/master/chat_sample/README.md Command to run the Flutter chat sample on a macOS desktop environment. This command initiates the application build and execution specifically targeting the macOS platform. ```bash flutter run -d macos ``` -------------------------------- ### Get Active Participants in Conference Session Source: https://context7.com/connectycube/connectycube-flutter-samples/llms.txt Retrieves a list of active participants in a conference session. Returns an empty list if the conference session is not initialized. This function is part of managing ongoing multi-party conferences. ```dart // Get active participants List getActiveParticipants() { if (_conferenceSession != null) { return _conferenceSession!.getActiveParticipants(); } return []; } } ``` -------------------------------- ### Firebase Configuration for Flutter Source: https://github.com/connectycube/connectycube-flutter-samples/blob/master/chat_sample/README.md This snippet outlines the process of setting up Firebase for your Flutter application, which is often a prerequisite for features like push notifications. It involves generating a `firebase_options.dart` file and placing it in the `lib/` directory. ```dart lib/firebase_options.dart ``` -------------------------------- ### CMake Project Configuration and Settings Source: https://github.com/connectycube/connectycube-flutter-samples/blob/master/p2p_call_sample/linux/CMakeLists.txt Configures the CMake project, sets the binary name and application ID, and defines build policies. It also handles bundling libraries and setting the system root for cross-building. ```cmake cmake_minimum_required(VERSION 3.10) project(runner LANGUAGES CXX) set(BINARY_NAME "p2p_call_sample") set(APPLICATION_ID "com.connectycube.p2p_call_sample") cmake_policy(SET CMP0063 NEW) set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") if(FLUTTER_TARGET_PLATFORM_SYSROOT) set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) endif() if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Flutter build mode" FORCE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Profile" "Release") endif() ``` -------------------------------- ### Get Message History in Flutter ConnectyCube Source: https://context7.com/connectycube/connectycube-flutter-samples/llms.txt Retrieves a paginated list of messages for a given dialog ID. It allows specifying the limit and skip count for pagination and sorts messages in descending order by date sent. It also marks messages as unread upon retrieval. ```dart // Get message history Future> getMessageHistory( String dialogId, {int limit = 50, int skip = 0} ) async { try { Map params = { 'chat_dialog_id': dialogId, 'sort_desc': 'date_sent', 'limit': limit, 'skip': skip, 'mark_as_read': 0, }; PagedResult result = await getMessages(dialogId, params); print("Loaded ${result.items.length} messages"); return result.items; } catch (error) { print("Error loading history: $error"); throw error; } } ``` -------------------------------- ### Initialize ConnectyCube SDK Source: https://context7.com/connectycube/connectycube-flutter-samples/llms.txt Initializes the ConnectyCube SDK using application credentials and configures API and chat endpoints. This function must be called before any other SDK operations. It handles session restoration for a seamless user experience. ```dart import 'package:connectycube_sdk/connectycube_sdk.dart'; // Configuration constants const String appId = "12345"; // Your app ID from ConnectyCube admin panel const String authKey = "your_auth_key"; // Your auth key from admin panel const String apiEndpoint = "https://api.connectycube.com"; const String chatEndpoint = "chat.connectycube.com"; // Initialize SDK in main.dart void initializeConnectyCube() { init( appId, authKey, '', onSessionRestore: () async { // Restore session logic - return existing session or create new one SharedPrefs sharedPrefs = await SharedPrefs.instance.init(); CubeUser? user = sharedPrefs.getUser(); if (user != null) { return createSession(user); } return Future.value(null); } ); // Set custom endpoints if needed setEndpoints(apiEndpoint, chatEndpoint); } // Expected output: SDK initialized and ready for authentication ``` -------------------------------- ### CMake Build Configuration and Settings Source: https://github.com/connectycube/connectycube-flutter-samples/blob/master/p2p_call_sample/windows/CMakeLists.txt This snippet configures the minimum CMake version, project name, and binary name. It also sets up build configurations (Debug, Profile, Release) and applies standard compilation settings like C++17 support, warning levels, and exception handling. ```cmake cmake_minimum_required(VERSION 3.15) project(p2p_call_sample LANGUAGES CXX) set(BINARY_NAME "p2p_call_sample") cmake_policy(SET CMP0063 NEW) set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") # Configure build options. get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) if(IS_MULTICONFIG) set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" CACHE STRING "" FORCE) else() if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Flutter build mode" FORCE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Profile" "Release") endif() endif() set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") # Use Unicode for all projects. add_definitions(-DUNICODE -D_UNICODE) # Compilation settings that should be applied to most targets. function(APPLY_STANDARD_SETTINGS TARGET) target_compile_features(${TARGET} PUBLIC cxx_std_17) target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") target_compile_options(${TARGET} PRIVATE /EHsc) target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") endfunction() set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") # Flutter library and tool build rules. add_subdirectory(${FLUTTER_MANAGED_DIR}) # Application build add_subdirectory("runner") # Generated plugin build rules, which manage building the plugins and adding # them to the application. include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Load Main Dart JS with Service Worker Source: https://github.com/connectycube/connectycube-flutter-samples/blob/master/p2p_call_sample/web/index.html This script initializes the application by loading the main Dart JavaScript file. It first checks for service worker support, registering one if available to potentially improve loading performance and handle updates. If service workers are not supported or fail to activate within a timeout, it falls back to loading the script directly. ```javascript var serviceWorkerVersion = null; var scriptLoaded = false; function loadMainDartJs() { if (scriptLoaded) { return; } scriptLoaded = true; var scriptTag = document.createElement('script'); scriptTag.src = 'main.dart.js'; scriptTag.type = 'application/javascript'; document.body.append(scriptTag); } if ('serviceWorker' in navigator) { // Service workers are supported. Use them. window.addEventListener('load', function () { // Wait for registration to finish before dropping the