Time for action – Initializing the client connection
The first thing we need to do is to initialize our connection. We will store it in a static variable, as follows:
class ZooCommander { public static var cnx : haxe.remoting.Connection; public static function main() { //Create the connection cnx = haxe.remoting.HttpConnection.urlConnect("http://localhost:8888/ZooKeeper.phpdir/index.php"); } }
What just happened?
We have simply created a connection over HTTP to our server by passing its address as the parameter.
Now, let's create our two functions.
The createAnimal function
We will create a createAnimal
function, which will be called by the main menu when the user chooses to add an animal to the list.
It will first ask for the required information and then make the request to the server:
public static function createAnimal() { //Ask the user for the Animal's name neko.Lib.println("Enter animal's name"); var name = neko.io.File.stdin().readLine...