NetworkServer
<< previous | Chapter 17. The Built-In breve Class APIs | next >>

## NetworkServer

Description for class NetworkServer:

> NetworkServer sets up a breve simulation to listen on a port to accept connections from other breve engines or from web browsers. To start a NetworkServer, use the method listen.

> There are two ways to use the NetworkServer object, and a single instance can simultaneously handle both kinds of functionality.

> - breve-to-breve object transfer

> - web-based control of breve simulations

> breve-to-breve object transfer: once the network server is running, users can send objects from one breve simulation to another using the Object method OBJECTObject:send-over-network. The instance is automatically added to the server's simulation. In addition, the server's controller object (or any other desired object--see the method set-upload-recipient) will receive a call to the method "accept-upload". This method must be implemented by the user with the following prototype:

>     + to accept-upload of-instance i (object) from-host h (string):

> Determining how an object is to be sent over the network is a bit complicated and is determined by the object's "dependencies". These are described in detail in the documentation dealing with archiving and dearchiving objects.

> web-based control of breve simulations: the NetworkServer object can also accept connections from regular web-browsers. To get the address that clients should connect to, use the method get-url. When users connect to the server, they can either execute a method in the controller instance or request an HTML file.

> To execute a method in the controller instance, simply append the method name to the end of the URL. If you wish to pass in either int or double arguments, they can be added afterwards, delimited by underscores. Other types may currently not be passed via the web interface. Here are some examples:http://myserver:33333/turn-agent-bluehttp://myserver:33333/set-agent-color_.2_.4_.6

> If the text at the end of the URL contains the string "html", it is presumed to be a request for an HTML file. If the file is found, it is sent to the web-browser. By writing your own HTML files, and including your own breve-compatible links (described above), you can provide novel interfaces to users.

> If a method is executed, it may return a string which, depending on the presence of the string "html", is either interpreted as raw HTML output, or as a filename that should be served to the browser. So when the user clicks on a link to execute a command, they can be directed to an HTML file of your choosing.

> Credit for implementing a great deal of the networking functionality is due to Seth Raphael, Poornima Muralidhar and William Taysom.

Inherits from Abstract

Full API documentation for the class NetworkServer:

- steve language documentation

- Python language documentation

<< previous | Up | next >>
MultiBody | Table of Contents | NeuralNetwork