Skip to content

Commit

Permalink
Merge pull request #722 from CyBear-Jinni/Changing_grpc
Browse files Browse the repository at this point in the history
Hub support
  • Loading branch information
guyluz11 authored Jan 27, 2024
2 parents b7c2920 + 9b40e05 commit 91f54b5
Show file tree
Hide file tree
Showing 74 changed files with 1,225 additions and 2,804 deletions.
44 changes: 31 additions & 13 deletions lib/domain/connections_service.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
import 'dart:async';
import 'dart:collection';
import 'dart:convert';
import 'dart:io';

import 'package:cbj_integrations_controller/integrations_controller.dart';
import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:cybearjinni/infrastructure/core/injection.dart';
import 'package:cybearjinni/infrastructure/core/logger.dart';
import 'package:cybearjinni/infrastructure/network_utilities_flutter.dart';
import 'package:dartz/dartz.dart';
import 'package:flutter/foundation.dart';
import 'package:grpc/grpc.dart';
import 'package:location/location.dart';
import 'package:network_info_plus/network_info_plus.dart';
import 'package:network_tools_flutter/network_tools_flutter.dart';
import 'package:permission_handler/permission_handler.dart'
as permission_handler;
import 'package:rxdart/rxdart.dart';

part 'package:cybearjinni/infrastructure/connection_service/app_connection_service.dart';
part 'package:cybearjinni/infrastructure/connection_service/hub_connection_service.dart';
part 'package:cybearjinni/infrastructure/connection_service/demo_connection_service.dart';
part 'package:cybearjinni/infrastructure/connection_service/none_connection_service.dart';
part 'package:cybearjinni/infrastructure/connection_service/remote_pipes_connection_service.dart';

enum ConnectionType {
appAsHub,
Expand All @@ -26,39 +42,41 @@ abstract interface class ConnectionsService {

static ConnectionType _currentConnectionType = ConnectionType.appAsHub;

static void setCurrentConnectionType(ConnectionType? connectionType) {
static void setCurrentConnectionType(ConnectionType connectionType) {
if (connectionType == _currentConnectionType) {
return;
}
final ConnectionsService? oldInstance = _instance;
_instance?.dispose();

_currentConnectionType = connectionType;

switch (connectionType) {
case ConnectionType.appAsHub:
_instance = _AppConnectionService();
_currentConnectionType = ConnectionType.appAsHub;
case ConnectionType.demo:
case ConnectionType.hub:
_instance = _HubConnectionService();
case ConnectionType.remotePipes:
_instance = _RemotePipesConnectionService();
case ConnectionType.demo:
_instance = _DemoConnectionService();
_currentConnectionType = ConnectionType.demo;
case ConnectionType.none:
case null:
_instance = _NoneConnectionService();
_currentConnectionType = ConnectionType.none;
}
oldInstance?.dispose();
}

static ConnectionType getCurrentConnectionType() => _currentConnectionType;

Future<bool> connect({String? address});

Future searchDevices();

void setEntityState(ActionObject action);
void setEntityState(RequestActionObject action);

Future setEtitiesToArea(String areaId, HashSet<String> entities);

Future<HashMap<String, DeviceEntityBase>> get getAllEntities;
Future<HashMap<String, DeviceEntityBase>> get getEntities;

Future<HashMap<String, AreaEntity>> get getAllAreas;
Future<HashMap<String, AreaEntity>> get getAreas;

Stream<MapEntry<String, DeviceEntityBase>> watchEntities();

Expand All @@ -68,13 +86,13 @@ abstract interface class ConnectionsService {

Future setNewArea(AreaEntity area);

Future<HashMap<String, SceneCbjEntity>> getScenes();
Future<HashMap<String, SceneCbjEntity>> get getScenes;

Future activateScene(String id);

Future addScene(SceneCbjEntity scene);

Future<void> loginVendor(VendorLoginEntity value);
Future loginVendor(VendorLoginEntity value);

Future<List<VendorEntityInformation>> getVendors();
}
14 changes: 0 additions & 14 deletions lib/domain/device/devices_errors.dart

This file was deleted.

35 changes: 0 additions & 35 deletions lib/domain/device/devices_failures.dart

This file was deleted.

88 changes: 0 additions & 88 deletions lib/domain/device/devices_validators.dart

This file was deleted.

145 changes: 0 additions & 145 deletions lib/domain/device/i_device_repository.dart

This file was deleted.

Loading

0 comments on commit 91f54b5

Please sign in to comment.