Game Development Reference
In-Depth Information
Figure 10-15. Properties of the Moai cloud service
Once we click Deploy Service, the service is available to use. Note the URL at the top; in this
example, it is set as http://services.moaicloud.com/USERNAME/test . You need to use the URL for
your own services. If you open a new browser window and navigate to that URL, you will see the
text "hello world!" displayed.
If you want to modify and create a better and more useful web service, you can click the Edit Files
link under Resources in the top-right corner, as shown in Figure 10-15 . This shall open the code
editor that allows you to work with Lua code. The only file present is main.lua , which has the
following code:
function main(web,req)
web:page('hello world!', 200, 'OK')
end
This is similar to the PHP and ASP environments for creating dynamic web pages, but we use the
Lua language for doing so. Documentation on how to use this can be found at http://getmoai.com/
wiki/index.php?title=MoaiCloud .
Consuming the Web Service
The web service is a simple HTTP-type service that is accessed via an URL. We shall try to access
the service we created from our Moai application. Our simple code would look something like this:
theURL = http://services.moaicloud.com/USERNAME/SERVICENAME
MoaiSim.openWindow("Consume Web Services", 320, 480)
 
Search WWH ::




Custom Search