In order to send and receive objects over a network, the objects must be prepared for archiving and dearchiving as described in Saving and Loading Individual Objects the section called “Saving and Loading Individual Objects”. Read that section first to be certain that your objects will be properly encoded and decoded.
When sending an instance over the network, breve recreates the instance
on the server machine. It recreates the object and the state of all of
its variables, except that variables of type object
and pointer
can
not be automatically maintained without special treatment. The reason
for this and the solution are described in Saving and Loading
Individual Objects the section called “Saving and Loading Individual Objects”.
To send an object over the network, use the Object method send-over-network
with the server computer's
hostname and port:
response = ( self send-over-network to "myOtherComputer" on 31337 ).
The function send-over-network
may return
a response object if one is sent by the server. This is described in
more detail below.
If a NetworkServer receives an instance upload from another host, it
dearchives the object, adds it to the simulation, then informs the
controller of the newly added object with the callback method
accept-upload
. You should implement your
own accept-upload
with the following
method declaration:
+ to accept-upload of-instance newInstance (object) from-host clientHostname (string).
The newly created instance, and the hostname which sent the instance are passed in as arguments. This method may optionally return an object which will be encoded and returned to the host which initiated the network connection.