I'm going to create a windows mobile runner for interactive fiction games implementing the following algorithm:
1. creating local tcp server
2. waiting for incoming connections on port 1111
3. running "iexplorer" (or any browser) with "http://localhost:1111"
4. executing http requests of a browser
Would it be possible with future FBA Creator? I think it needs some features implemented:
- tsr profile of a project
- onmainloop() that would be called with lost focus
- return-to-os() function
- switch-task-button support
- sleep() function
The program below gave expected "Hello, world!" page to iexplorer, but it required many operations: switching to today screen (switch-task-button didn't work, I used special *cheat* key =), running iexplorer with "http://localhost:1111", switching back to fba, clicking on fba to close it.
Code:
local socket = require("socket")
local localhost = socket.tcp()
localhost:bind("*", 1111)
localhost:settimeout(1)
localhost:listen(1)
local client
local http = [[
HTTP/1.1 200 OK
Content-type: text/html
Content-length: %d
%s]]
local msg = [[
<html>
<head>
<title>Hello, world!</title>
</head>
<body>
<big>Hello, world!</big>
</body>
</html>
]]
function onmainloop()
local list = socket.select( { localhost }, { }, 0 )
if #list == 1 then
client = localhost:accept()
end
if client then
list = socket.select( { client }, { }, 0 )
if #list == 1 then
client:send (http:format(#msg, msg))
client:close()
client = nil
end
end
if (mousedown() > 0) then
quit()
end
end