-
Notifications
You must be signed in to change notification settings - Fork 4
Example: Sending Data To The Client Once
Seppi edited this page Apr 26, 2016
·
1 revision
To send data to the client once, we request the server to do this. We send an empty request, and the server will respond appropriately.
In this example, we will ask the server what version it is running.
For the server:
lovernetlib = require('lovernet')
lovernet = lovernetlib.new{type=lovernetlib.mode.server}
lovernet:addOp('version')
lovernet:addProcessOnServer('version',function(self,peer,arg,storage)
return '1.0'
end)
function love.update(dt)
lovernet:update(dt)
end
For the client:
lovernetlib = require('lovernet')
lovernet = lovernetlib.new()
lovernet:addOp('version')
lovernet:pushData('version')
function love.update(dt)
if lovernet:getCache('version') then
assert( lovernet:getCache('version') == '1.0', 'Version Mismatch!' )
end
lovernet:update(dt)
end