diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml
index 4122f36a..18087e82 100644
--- a/example/android/app/src/main/AndroidManifest.xml
+++ b/example/android/app/src/main/AndroidManifest.xml
@@ -3,6 +3,7 @@
+
+ 10.0.2.2
+ 127.0.0.1
+
+
\ No newline at end of file
diff --git a/example/src/App.tsx b/example/src/App.tsx
index 7bbc13ce..90eff776 100644
--- a/example/src/App.tsx
+++ b/example/src/App.tsx
@@ -1,18 +1,17 @@
import clsx from 'clsx';
import {useEffect, useState} from 'react';
import {SafeAreaView, ScrollView, Text, View} from 'react-native';
-import {BridgeServer} from 'react-native-http-bridge-refurbished';
import 'reflect-metadata';
import {constantsTests} from './tests/constants.spec';
import {registerHooksTests} from './tests/hooks.spec';
import {blobTests, dbSetupTests, queriesTests, runTests} from './tests/index';
import {preparedStatementsTests} from './tests/preparedStatements.spec';
import {reactiveTests} from './tests/reactive.spec';
+import {setServerResults, startServer, stopServer} from './server';
export default function App() {
const [results, setResults] = useState([]);
useEffect(() => {
- setResults([]);
runTests(
dbSetupTests,
queriesTests,
@@ -21,18 +20,15 @@ export default function App() {
preparedStatementsTests,
constantsTests,
reactiveTests,
- ).then(setResults);
-
- const server = new BridgeServer('http_service', true);
-
- server.get('/test_results', async (_req, _res) => {
- return {results};
+ ).then(results => {
+ setServerResults(results as any);
+ setResults(results);
});
- server.listen(10424);
+ startServer();
return () => {
- server.stop();
+ stopServer();
};
}, []);
diff --git a/example/src/server.ts b/example/src/server.ts
new file mode 100644
index 00000000..dd0e3b5b
--- /dev/null
+++ b/example/src/server.ts
@@ -0,0 +1,36 @@
+import {BridgeServer} from 'react-native-http-bridge-refurbished';
+let results: any[] = [];
+
+const server = new BridgeServer('http_service', true);
+
+server.get('/ping', async (_req, _res) => {
+ console.log("🟦 🟦🟦🟦🟦🟦🟦 🟦 Received request for '/ping'");
+ return {message: 'pong'};
+});
+
+server.get('/results', async (req, _res) => {
+ // console.log("🟦 🟦🟦🟦🟦🟦🟦 🟦 Received request for '/test_results'");
+ // console.log(req.type);
+ // console.log(req.data);
+ // console.log(req.url);
+ // if (results.length > 0) {
+ // return {results};
+ // } else {
+ // return {};
+ // }
+ return {results};
+});
+
+server.listen(9000);
+
+export function startServer() {
+ return server;
+}
+
+export function stopServer() {
+ server.stop();
+}
+
+export function setServerResults(r: any[]) {
+ results = r;
+}
diff --git a/scripts/poll-in-app-server.js b/scripts/poll-in-app-server.js
index 2aaf8ea9..92e6e540 100644
--- a/scripts/poll-in-app-server.js
+++ b/scripts/poll-in-app-server.js
@@ -7,9 +7,8 @@ async function pollInAppServer() {
while (Date.now() - startTime < maxDuration) {
try {
- const response = await makeHttpRequest(
- 'http://127.0.0.1:10424/test_results'
- );
+ const response = await makeHttpRequest('http://127.0.0.1:9000/results');
+
if (response !== null) {
let parsed_response = JSON.parse(response);
const allTestsPassed = parsed_response.results.reduce((acc, r) => {
diff --git a/scripts/test-android.sh b/scripts/test-android.sh
index 612ae1bd..04867bc0 100755
--- a/scripts/test-android.sh
+++ b/scripts/test-android.sh
@@ -1,6 +1,8 @@
JAVA_OPTS=-XX:MaxHeapSize=6g yarn turbo run run:android:release --cache-dir=.turbo/android
-adb reverse tcp:10424 tcp:10424
-echo "🟦 Android device address:"
+adb forward tcp:9000 tcp:9000
+# echo "🟦 Android device address:"
adb shell ip addr show
+# echo "📱 Android Emulator IP Address:"
+# adb shell ifconfig | grep "inet addr" | awk '{print $2}' | awk -F: '{print $2}'
echo "Polling in-app server..."
node ./scripts/poll-in-app-server.js
\ No newline at end of file