@figuredev/react-native-local-server
Advanced tools
Comparing version 0.3.0 to 0.4.0
@@ -64,2 +64,6 @@ "use strict"; | ||
_defineProperty(this, "getLocalIpAddress", () => { | ||
return (0, _rxjs.defer)(() => this.tcpServer.getLocalIpAddress()); | ||
}); | ||
this.serverId = id; | ||
@@ -66,0 +70,0 @@ this.handler$ = new _rxjs.Subject(); |
@@ -38,7 +38,6 @@ "use strict"; | ||
_defineProperty(this, "start", async configuration => { | ||
_defineProperty(this, "getLocalIpAddress", async () => { | ||
var _this$logger; | ||
(_this$logger = this.logger) === null || _this$logger === void 0 ? void 0 : _this$logger.log(`TCPServer [${this.getId()}] - start`, configuration); | ||
this.config = configuration; | ||
(_this$logger = this.logger) === null || _this$logger === void 0 ? void 0 : _this$logger.log(`TCPServer [${this.getId()}] - getLocalIpAddress`); | ||
@@ -48,9 +47,31 @@ try { | ||
const ip = await _module.TCPServerModule.getLocalIpAddress(); | ||
(_this$logger2 = this.logger) === null || _this$logger2 === void 0 ? void 0 : _this$logger2.log(`TCPServer [${this.getId()}] - getLocalIpAddress - success`, { | ||
ip: ip | ||
}); | ||
return Promise.resolve(ip); | ||
} catch (e) { | ||
var _this$logger3; | ||
(_this$logger3 = this.logger) === null || _this$logger3 === void 0 ? void 0 : _this$logger3.error(`TCPServer [${this.getId()}] - getLocalIpAddress - error`, e); | ||
return Promise.reject(e); | ||
} | ||
}); | ||
_defineProperty(this, "start", async configuration => { | ||
var _this$logger4; | ||
(_this$logger4 = this.logger) === null || _this$logger4 === void 0 ? void 0 : _this$logger4.log(`TCPServer [${this.getId()}] - start`, configuration); | ||
this.config = configuration; | ||
try { | ||
var _this$logger5; | ||
await _module.TCPServerModule.createServer(this.getId(), this.config.port); | ||
(_this$logger2 = this.logger) === null || _this$logger2 === void 0 ? void 0 : _this$logger2.log(`TCPServer [${this.getId()}] - start - success`); | ||
(_this$logger5 = this.logger) === null || _this$logger5 === void 0 ? void 0 : _this$logger5.log(`TCPServer [${this.getId()}] - start - success`); | ||
return Promise.resolve(); | ||
} catch (e) { | ||
var _this$logger3; | ||
var _this$logger6; | ||
(_this$logger3 = this.logger) === null || _this$logger3 === void 0 ? void 0 : _this$logger3.error(`TCPServer [${this.getId()}] - start - error`, e); | ||
(_this$logger6 = this.logger) === null || _this$logger6 === void 0 ? void 0 : _this$logger6.error(`TCPServer [${this.getId()}] - start - error`, e); | ||
return Promise.reject(e); | ||
@@ -61,5 +82,5 @@ } | ||
_defineProperty(this, "sendData", async (connectionId, data) => { | ||
var _this$logger4; | ||
var _this$logger7; | ||
(_this$logger4 = this.logger) === null || _this$logger4 === void 0 ? void 0 : _this$logger4.log(`TCPServer [${this.getId()}] - sendData`, { | ||
(_this$logger7 = this.logger) === null || _this$logger7 === void 0 ? void 0 : _this$logger7.log(`TCPServer [${this.getId()}] - sendData`, { | ||
connectionId: connectionId, | ||
@@ -70,11 +91,11 @@ data: data | ||
try { | ||
var _this$logger5; | ||
var _this$logger8; | ||
await _module.TCPServerModule.send(this.getId(), connectionId, data); | ||
(_this$logger5 = this.logger) === null || _this$logger5 === void 0 ? void 0 : _this$logger5.log(`TCPServer [${this.getId()}] - sendData - success`); | ||
(_this$logger8 = this.logger) === null || _this$logger8 === void 0 ? void 0 : _this$logger8.log(`TCPServer [${this.getId()}] - sendData - success`); | ||
return Promise.resolve(); | ||
} catch (e) { | ||
var _this$logger6; | ||
var _this$logger9; | ||
(_this$logger6 = this.logger) === null || _this$logger6 === void 0 ? void 0 : _this$logger6.error(`TCPServer [${this.getId()}] - sendData - error`, e); | ||
(_this$logger9 = this.logger) === null || _this$logger9 === void 0 ? void 0 : _this$logger9.error(`TCPServer [${this.getId()}] - sendData - error`, e); | ||
return Promise.reject(e); | ||
@@ -85,5 +106,5 @@ } | ||
_defineProperty(this, "closeConnection", async connectionId => { | ||
var _this$logger7; | ||
var _this$logger10; | ||
(_this$logger7 = this.logger) === null || _this$logger7 === void 0 ? void 0 : _this$logger7.log(`TCPServer [${this.getId()}] - closeConnection`, { | ||
(_this$logger10 = this.logger) === null || _this$logger10 === void 0 ? void 0 : _this$logger10.log(`TCPServer [${this.getId()}] - closeConnection`, { | ||
connectionId: connectionId | ||
@@ -93,11 +114,11 @@ }); | ||
try { | ||
var _this$logger8; | ||
var _this$logger11; | ||
await _module.TCPServerModule.closeConnection(this.getId(), connectionId); | ||
(_this$logger8 = this.logger) === null || _this$logger8 === void 0 ? void 0 : _this$logger8.log(`TCPServer [${this.getId()}] - closeConnection - success`); | ||
(_this$logger11 = this.logger) === null || _this$logger11 === void 0 ? void 0 : _this$logger11.log(`TCPServer [${this.getId()}] - closeConnection - success`); | ||
return Promise.resolve(); | ||
} catch (e) { | ||
var _this$logger9; | ||
var _this$logger12; | ||
(_this$logger9 = this.logger) === null || _this$logger9 === void 0 ? void 0 : _this$logger9.error(`TCPServer [${this.getId()}] - closeConnection - error`, e); | ||
(_this$logger12 = this.logger) === null || _this$logger12 === void 0 ? void 0 : _this$logger12.error(`TCPServer [${this.getId()}] - closeConnection - error`, e); | ||
return Promise.reject(e); | ||
@@ -108,16 +129,16 @@ } | ||
_defineProperty(this, "stop", async () => { | ||
var _this$logger10; | ||
var _this$logger13; | ||
(_this$logger10 = this.logger) === null || _this$logger10 === void 0 ? void 0 : _this$logger10.log(`TCPServer [${this.getId()}] - stop`); | ||
(_this$logger13 = this.logger) === null || _this$logger13 === void 0 ? void 0 : _this$logger13.log(`TCPServer [${this.getId()}] - stop`); | ||
try { | ||
var _this$logger11; | ||
var _this$logger14; | ||
await _module.TCPServerModule.stopServer(this.getId()); | ||
(_this$logger11 = this.logger) === null || _this$logger11 === void 0 ? void 0 : _this$logger11.log(`TCPServer [${this.getId()}] - stop - success`); | ||
(_this$logger14 = this.logger) === null || _this$logger14 === void 0 ? void 0 : _this$logger14.log(`TCPServer [${this.getId()}] - stop - success`); | ||
return Promise.resolve(); | ||
} catch (e) { | ||
var _this$logger12; | ||
var _this$logger15; | ||
(_this$logger12 = this.logger) === null || _this$logger12 === void 0 ? void 0 : _this$logger12.error(`TCPServer [${this.getId()}] - stop - error`, e); | ||
(_this$logger15 = this.logger) === null || _this$logger15 === void 0 ? void 0 : _this$logger15.error(`TCPServer [${this.getId()}] - stop - error`, e); | ||
return Promise.reject(e); | ||
@@ -124,0 +145,0 @@ } |
@@ -41,2 +41,6 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
_defineProperty(this, "getLocalIpAddress", () => { | ||
return defer(() => this.tcpServer.getLocalIpAddress()); | ||
}); | ||
this.serverId = id; | ||
@@ -43,0 +47,0 @@ this.handler$ = new Subject(); |
@@ -27,7 +27,6 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
_defineProperty(this, "start", async configuration => { | ||
_defineProperty(this, "getLocalIpAddress", async () => { | ||
var _this$logger; | ||
(_this$logger = this.logger) === null || _this$logger === void 0 ? void 0 : _this$logger.log(`TCPServer [${this.getId()}] - start`, configuration); | ||
this.config = configuration; | ||
(_this$logger = this.logger) === null || _this$logger === void 0 ? void 0 : _this$logger.log(`TCPServer [${this.getId()}] - getLocalIpAddress`); | ||
@@ -37,9 +36,31 @@ try { | ||
const ip = await TCPServerModule.getLocalIpAddress(); | ||
(_this$logger2 = this.logger) === null || _this$logger2 === void 0 ? void 0 : _this$logger2.log(`TCPServer [${this.getId()}] - getLocalIpAddress - success`, { | ||
ip: ip | ||
}); | ||
return Promise.resolve(ip); | ||
} catch (e) { | ||
var _this$logger3; | ||
(_this$logger3 = this.logger) === null || _this$logger3 === void 0 ? void 0 : _this$logger3.error(`TCPServer [${this.getId()}] - getLocalIpAddress - error`, e); | ||
return Promise.reject(e); | ||
} | ||
}); | ||
_defineProperty(this, "start", async configuration => { | ||
var _this$logger4; | ||
(_this$logger4 = this.logger) === null || _this$logger4 === void 0 ? void 0 : _this$logger4.log(`TCPServer [${this.getId()}] - start`, configuration); | ||
this.config = configuration; | ||
try { | ||
var _this$logger5; | ||
await TCPServerModule.createServer(this.getId(), this.config.port); | ||
(_this$logger2 = this.logger) === null || _this$logger2 === void 0 ? void 0 : _this$logger2.log(`TCPServer [${this.getId()}] - start - success`); | ||
(_this$logger5 = this.logger) === null || _this$logger5 === void 0 ? void 0 : _this$logger5.log(`TCPServer [${this.getId()}] - start - success`); | ||
return Promise.resolve(); | ||
} catch (e) { | ||
var _this$logger3; | ||
var _this$logger6; | ||
(_this$logger3 = this.logger) === null || _this$logger3 === void 0 ? void 0 : _this$logger3.error(`TCPServer [${this.getId()}] - start - error`, e); | ||
(_this$logger6 = this.logger) === null || _this$logger6 === void 0 ? void 0 : _this$logger6.error(`TCPServer [${this.getId()}] - start - error`, e); | ||
return Promise.reject(e); | ||
@@ -50,5 +71,5 @@ } | ||
_defineProperty(this, "sendData", async (connectionId, data) => { | ||
var _this$logger4; | ||
var _this$logger7; | ||
(_this$logger4 = this.logger) === null || _this$logger4 === void 0 ? void 0 : _this$logger4.log(`TCPServer [${this.getId()}] - sendData`, { | ||
(_this$logger7 = this.logger) === null || _this$logger7 === void 0 ? void 0 : _this$logger7.log(`TCPServer [${this.getId()}] - sendData`, { | ||
connectionId: connectionId, | ||
@@ -59,11 +80,11 @@ data: data | ||
try { | ||
var _this$logger5; | ||
var _this$logger8; | ||
await TCPServerModule.send(this.getId(), connectionId, data); | ||
(_this$logger5 = this.logger) === null || _this$logger5 === void 0 ? void 0 : _this$logger5.log(`TCPServer [${this.getId()}] - sendData - success`); | ||
(_this$logger8 = this.logger) === null || _this$logger8 === void 0 ? void 0 : _this$logger8.log(`TCPServer [${this.getId()}] - sendData - success`); | ||
return Promise.resolve(); | ||
} catch (e) { | ||
var _this$logger6; | ||
var _this$logger9; | ||
(_this$logger6 = this.logger) === null || _this$logger6 === void 0 ? void 0 : _this$logger6.error(`TCPServer [${this.getId()}] - sendData - error`, e); | ||
(_this$logger9 = this.logger) === null || _this$logger9 === void 0 ? void 0 : _this$logger9.error(`TCPServer [${this.getId()}] - sendData - error`, e); | ||
return Promise.reject(e); | ||
@@ -74,5 +95,5 @@ } | ||
_defineProperty(this, "closeConnection", async connectionId => { | ||
var _this$logger7; | ||
var _this$logger10; | ||
(_this$logger7 = this.logger) === null || _this$logger7 === void 0 ? void 0 : _this$logger7.log(`TCPServer [${this.getId()}] - closeConnection`, { | ||
(_this$logger10 = this.logger) === null || _this$logger10 === void 0 ? void 0 : _this$logger10.log(`TCPServer [${this.getId()}] - closeConnection`, { | ||
connectionId: connectionId | ||
@@ -82,11 +103,11 @@ }); | ||
try { | ||
var _this$logger8; | ||
var _this$logger11; | ||
await TCPServerModule.closeConnection(this.getId(), connectionId); | ||
(_this$logger8 = this.logger) === null || _this$logger8 === void 0 ? void 0 : _this$logger8.log(`TCPServer [${this.getId()}] - closeConnection - success`); | ||
(_this$logger11 = this.logger) === null || _this$logger11 === void 0 ? void 0 : _this$logger11.log(`TCPServer [${this.getId()}] - closeConnection - success`); | ||
return Promise.resolve(); | ||
} catch (e) { | ||
var _this$logger9; | ||
var _this$logger12; | ||
(_this$logger9 = this.logger) === null || _this$logger9 === void 0 ? void 0 : _this$logger9.error(`TCPServer [${this.getId()}] - closeConnection - error`, e); | ||
(_this$logger12 = this.logger) === null || _this$logger12 === void 0 ? void 0 : _this$logger12.error(`TCPServer [${this.getId()}] - closeConnection - error`, e); | ||
return Promise.reject(e); | ||
@@ -97,16 +118,16 @@ } | ||
_defineProperty(this, "stop", async () => { | ||
var _this$logger10; | ||
var _this$logger13; | ||
(_this$logger10 = this.logger) === null || _this$logger10 === void 0 ? void 0 : _this$logger10.log(`TCPServer [${this.getId()}] - stop`); | ||
(_this$logger13 = this.logger) === null || _this$logger13 === void 0 ? void 0 : _this$logger13.log(`TCPServer [${this.getId()}] - stop`); | ||
try { | ||
var _this$logger11; | ||
var _this$logger14; | ||
await TCPServerModule.stopServer(this.getId()); | ||
(_this$logger11 = this.logger) === null || _this$logger11 === void 0 ? void 0 : _this$logger11.log(`TCPServer [${this.getId()}] - stop - success`); | ||
(_this$logger14 = this.logger) === null || _this$logger14 === void 0 ? void 0 : _this$logger14.log(`TCPServer [${this.getId()}] - stop - success`); | ||
return Promise.resolve(); | ||
} catch (e) { | ||
var _this$logger12; | ||
var _this$logger15; | ||
(_this$logger12 = this.logger) === null || _this$logger12 === void 0 ? void 0 : _this$logger12.error(`TCPServer [${this.getId()}] - stop - error`, e); | ||
(_this$logger15 = this.logger) === null || _this$logger15 === void 0 ? void 0 : _this$logger15.error(`TCPServer [${this.getId()}] - stop - error`, e); | ||
return Promise.reject(e); | ||
@@ -113,0 +134,0 @@ } |
@@ -23,2 +23,3 @@ import { Observable } from "rxjs"; | ||
setLogger(logger: Logger | null): void; | ||
getLocalIpAddress: () => Observable<string | null>; | ||
private getSourceData; | ||
@@ -25,0 +26,0 @@ private sendMessage; |
@@ -15,2 +15,3 @@ import type { TCPServerConfiguration } from "./types"; | ||
getConfiguration: () => TCPServerConfiguration | null; | ||
getLocalIpAddress: () => Promise<string | null>; | ||
start: (configuration: TCPServerConfiguration) => Promise<void>; | ||
@@ -17,0 +18,0 @@ sendData: (connectionId: string, data: string) => Promise<void>; |
{ | ||
"name": "@figuredev/react-native-local-server", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "Library for creating a local server on the device running React Native.", | ||
@@ -30,4 +30,4 @@ "main": "lib/commonjs/index", | ||
"test:ts:ci": "jest --ci --runInBand --reporters=default --reporters=jest-junit", | ||
"test:android": "cd android && ./gradlew testDebugUnitTest", | ||
"test:ios": "sh ./scripts/run-ios-tests.sh", | ||
"test:android": "bundle exec fastlane android test", | ||
"test:ios": "bundle exec fastlane ios test", | ||
"build:ts": "yarn tsc --project tsconfig.build.json", | ||
@@ -34,0 +34,0 @@ "prepare": "bob build", |
@@ -141,2 +141,6 @@ import { defer, from, Observable, of, Subject, Subscription } from "rxjs" | ||
getLocalIpAddress = (): Observable<string | null> => { | ||
return defer(() => this.tcpServer.getLocalIpAddress()) | ||
} | ||
private getSourceData(connectionId: string): MessageSource { | ||
@@ -143,0 +147,0 @@ const config = this.getConfig() |
@@ -33,2 +33,14 @@ import type { TCPServerConfiguration } from "./types" | ||
getLocalIpAddress = async (): Promise<string | null> => { | ||
this.logger?.log(`TCPServer [${this.getId()}] - getLocalIpAddress`) | ||
try { | ||
const ip: string | null = await TCPServerModule.getLocalIpAddress() | ||
this.logger?.log(`TCPServer [${this.getId()}] - getLocalIpAddress - success`, { ip: ip }) | ||
return Promise.resolve(ip) | ||
} catch (e) { | ||
this.logger?.error(`TCPServer [${this.getId()}] - getLocalIpAddress - error`, e) | ||
return Promise.reject(e) | ||
} | ||
} | ||
start = async (configuration: TCPServerConfiguration): Promise<void> => { | ||
@@ -35,0 +47,0 @@ this.logger?.log(`TCPServer [${this.getId()}] - start`, configuration) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
523414
317
3160