Files
react-native-http-bridge/httpServer.js
T

29 lines
753 B
JavaScript
Raw Permalink Normal View History

2017-02-06 16:40:44 +03:00
/**
* @providesModule react-native-http-server
*/
'use strict';
import {DeviceEventEmitter} from 'react-native';
import {NativeModules} from 'react-native';
var Server = NativeModules.HttpServer;
module.exports = {
2017-05-24 12:18:31 +03:00
start: function (port, serviceName, callback) {
2017-02-07 14:03:16 +03:00
if (port == 80) {
2017-02-06 16:40:44 +03:00
throw "Invalid server port specified. Port 80 is reserved.";
}
2017-05-24 12:18:31 +03:00
Server.start(port, serviceName);
2017-02-07 14:24:35 +03:00
DeviceEventEmitter.addListener('httpServerResponseReceived', callback);
2017-02-06 16:40:44 +03:00
},
stop: function () {
Server.stop();
2017-02-07 14:24:35 +03:00
DeviceEventEmitter.removeListener('httpServerResponseReceived');
},
respond: function (requestId, code, type, body) {
Server.respond(requestId, code, type, body);
2017-02-06 16:40:44 +03:00
}
}