NetLogo Models Library:
This template contains code that can serve as a starting point for creating new HubNet activities. It shares many of the basic procedures used by other HubNet activities, which are required to connect to and communicate with clients in Disease-like activities.
In activities like Disease, each client controls a single turtle on the server. These turtles are a breed called STUDENTS. When a client logs in we create a new student turtle and set it up with the default attributes. Students own a variable for every widget on the client that holds a state, that is, sliders, switches, choosers, and input boxes. Whenever a user changes one of these elements on the client, a message is sent to the server. The server catches the message and stores the result. In this example a slider is used to demonstrate this behavior. You can also send messages to the client-side widgets using
hubnet-send. Monitors on clients must be updated manually by the model, that is you must send a message to a monitor every time you want the value displayed to change. For example, if you have a monitor that displays the current location of the client's avatar, you must send a message to the client like this:
hubnet-send user-id "location" (word xcor " " ycor)
whenever the client moves. Buttons on the client side send but do not receive messages. When a user presses a button, a message is sent to the server. The server catches the message and executes the appropriate commands. In this case, the commands should always be turtle commands since the clients control only a single turtle.
To start the activity press the GO button. Ask students to login using the HubNet client or you can test the activity locally by pressing the LOCAL button in the HubNet Control Center. To see the view in the client interface check the Mirror 2D view on clients checkbox. The clients can use the UP, DOWN, LEFT, and RIGHT buttons to move their avatar and change the amount they move each step by changing the STEP-SIZE slider.