01-20-2014, 12:14 AM
Is there anything in particular in LFS that you think the cFile API doesn't provide? I'd like to think that we already cover that one in MCS.
LuaSocket is a natural choice; however it doesn't play too well with MCS architecture, because it uses blocking IO, and MCS plugins cannot afford to block - they'd block the entire server. We need to implement our own socket library, built on asynchronous events, something like this:
As for threading, I was considering various alternatives, this one looks really good, we can make a similar interface in MCS. Instead of giving it a string of code to run, though, I would prefer giving it an entire disk file, how about that? Of course, the child thread won't have access to most MCS API, I think only the cFile API is safe enough, maybe cBlockArea (but without cWorld). It will be possible to "TryJoin" a thread that will join the thread if it has ended or return no value if the thread is still running.
LuaSocket is a natural choice; however it doesn't play too well with MCS architecture, because it uses blocking IO, and MCS plugins cannot afford to block - they'd block the entire server. We need to implement our own socket library, built on asynchronous events, something like this:
-- Client example: g_Socket = cSocket() local function OnConnect(a_Socket) a_Socket.Send("hello") end local function OnReceiveData(a_Socket, a_Data) LOGINFO("Received: " .. a_Data) end local function OnDisconnect(a_Socket) LOGINFO("Socket disconnected") end g_Socket:Connect("hostname", port, OnConnect, OnReceiveData, OnDisconnect) -- Server example: g_Socket = cSocket() -- TODO: Define the handler functions g_Socket:Bind("LocalIP", port, OnClientConnected, OnClientReceiveData, OnClientDisconnect)
As for threading, I was considering various alternatives, this one looks really good, we can make a similar interface in MCS. Instead of giving it a string of code to run, though, I would prefer giving it an entire disk file, how about that? Of course, the child thread won't have access to most MCS API, I think only the cFile API is safe enough, maybe cBlockArea (but without cWorld). It will be possible to "TryJoin" a thread that will join the thread if it has ended or return no value if the thread is still running.