Bind tildefriends HTTP to an arbitrary port, write it to a file, and have the Android activity notice that file write and load the correct URL.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4233 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2023-03-18 12:28:48 +00:00
parent 63615747a7
commit d6be2f7d54
4 changed files with 102 additions and 12 deletions

View File

@ -555,7 +555,17 @@ let kBacklog = 8;
let kHost = "0.0.0.0"
let socket = new Socket();
socket.bind(kHost, tildefriends.http_port).then(function() {
socket.bind(kHost, tildefriends.http_port).then(function(port) {
print("bound to", port);
print("checking", tildefriends.args.out_http_port_file);
if (tildefriends.args.out_http_port_file) {
print("going to write the file");
File.writeFile(tildefriends.args.out_http_port_file, port.toString() + '\n').then(function(r) {
print("wrote port file", tildefriends.args.out_http_port_file, r);
}).catch(function() {
print("failed to write port file");
});
}
let listenResult = socket.listen(kBacklog, async function() {
try {
let client = await socket.accept();