Network API - Printable Version +- Cuberite Forum (https://forum.cuberite.org) +-- Forum: Cuberite (https://forum.cuberite.org/forum-4.html) +--- Forum: Development (https://forum.cuberite.org/forum-13.html) +--- Thread: Network API (/thread-1700.html) |
RE: Network API - NiLSPACE - 01-27-2015 I tried testing it, but when I used restart to update the webadmin users I got this error: After that the server wasn't responding to anything. RE: Network API - xoft - 01-27-2015 Nice catch. Both errors (socket not freed and server not aborting on error) should be fixed in 0edf7ceb28b289f96314bb9b2f7030b61ba4f313. RE: Network API - NiLSPACE - 01-28-2015 Great, everything worked for me exept that. RE: Network API - xoft - 01-28-2015 I've rebased the branch on top of current master. I guess I'll start a parallel branch with the Lua API in the meantime, until we have more confirmations that the migration is working properly. RE: Network API - xoft - 01-28-2015 Ooooh, that was quite fast The first actual usage of the Lua API is working: Code: [8863cdd6|14:26:22] Startup complete, took 6040ms! And this is the complete code from the plugin: function HandleConsoleNetClient(a_Split) -- Get the address to connect to: local Host = a_Split[3] or "google.com" local Port = a_Split[4] or 80 -- Create the callbacks "personalised" for the address: local Callbacks = { OnConnected = function (a_Link) LOG("Connected to " .. Host .. ":" .. Port .. ". Sending HTTP request for front page.") a_Link:Send("GET / HTTP/1.0\r\nHost: " .. Host .. "\r\n\r\n") end, OnError = function (a_ErrorCode, a_ErrorMsg) LOG("Connection to " .. Host .. ":" .. Port .. " failed: " .. a_ErrorCode .. " (" .. a_ErrorMsg .. ")") end, OnReceivedData = function (a_Data) LOG("Received data from " .. Host .. ":" .. Port .. ":\r\n" .. a_Data) end, } -- Queue a connect request: local res = cNetwork:Connect(Host, Port, Callbacks) if not(res) then LOGWARNING("cNetwork:Connect call failed immediately") return true end return true, "Client connection request queued." end RE: Network API - NiLSPACE - 01-29-2015 That's awesome RE: Network API - xoft - 01-29-2015 I pushed all the code in a new PR. The cNetwork::Connect() function and cTCPLink class are more or less complete. I also pushed the network plugin test code as a new plugin, NetworkTest. RE: Network API - wudles - 01-29-2015 (01-29-2015, 12:19 AM)xoft Wrote: I pushed all the code in a new PR. The cNetwork::Connect() function and cTCPLink class are more or less complete. I also pushed the network plugin test code as a new plugin, NetworkTest. Sweet! RE: Network API - xoft - 01-30-2015 I've got server functionality exported as well, it seems to work nicely. I have written two servers, the traditional Echo server, and a Text-Fortune server. There's only one problem that I've run into now. Object ownership. Sometimes we want Lua to own the object (so that it is garbage-collected), and sometimes we want the same object to direct its own lifetime. This will need some detailed thinking. RE: Network API - xoft - 01-31-2015 I think it should be all sorted out, I've been testing with the NetworkTest plugin and it all seems to work. Feel free to review and comment on the PR: https://github.com/mc-server/MCServer/pull/1718 There's still an issue of missing documentation for the new classes. That will be a tough one, with the callback tables being returned in a callback from a table Bah! It still doesn't compile on Linux |