From 58018cd8e177dfbe316964e0466742a33893fcc6 Mon Sep 17 00:00:00 2001 From: Adriano Santos Date: Fri, 20 Oct 2023 18:36:51 -0300 Subject: [PATCH] Initial http client implementation --- lib/src/service.dart | 5 ----- lib/src/spawn_client.dart | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 lib/src/spawn_client.dart diff --git a/lib/src/service.dart b/lib/src/service.dart index c3c3639..019b2a6 100644 --- a/lib/src/service.dart +++ b/lib/src/service.dart @@ -18,11 +18,6 @@ class Service { 'content-type': 'application/octet-stream', }; - final _dartVersion = () { - final version = Platform.version; - return version.substring(0, version.indexOf(' ')); - }(); - late String spawnSystem; late Map spawnActorHandlers; diff --git a/lib/src/spawn_client.dart b/lib/src/spawn_client.dart new file mode 100644 index 0000000..fb4655e --- /dev/null +++ b/lib/src/spawn_client.dart @@ -0,0 +1,35 @@ +import 'dart:io'; + +import 'package:spawn_dart/src/actor_handler.dart'; + +class SpawnClient { + static final _client = HttpClient(); + static final _dartVersion = () { + final version = Platform.version; + return version.substring(0, version.indexOf(' ')); + }(); + static final String _registerUrlPath = "/api/v1/system"; + Map _actorHandlers = {}; + + String _proxyHost = Platform.environment["PROXY_HTTP_HOST"] ?? "0.0.0.0"; + int _proxyPort = int.parse(Platform.environment["PROXY_HTTP_PORT"] ?? "9001"); + + SpawnClient(Map actorHandlers) { + _actorHandlers = actorHandlers; + } + + SpawnClient.withConnectionParams( + String host, int port, Map actorHandlers) { + _proxyHost = host; + _proxyPort = port; + _actorHandlers = actorHandlers; + } + + String get proxyHost { + return _proxyHost; + } + + int get proxyPort { + return _proxyPort; + } +}