Torque3D Documentation / _generateds / SimpleNetObject

SimpleNetObject

consoledoc.h

A very simple example of a class derived from NetObject.

More...

Public Functions

void
setMessage(string msg)

Sets the internal message variable.

Detailed Description

A very simple example of a class derived from NetObject.

This object exists purely for instructional purposes. It is primarily geared toward developers that wish to understand the inner-working of Torque 3D's networking system. This is not intended for actual game development.

// On the server, create a new SimpleNetObject.  This is a ghost always
// object so it will be immediately ghosted to all connected clients.
$s = new SimpleNetObject();

// All connected clients will see the following in their console:
// 
// Got message: Hello World!

see:

NetObject for a full breakdown of this example object

Public Functions

setMessage(string msg)

Sets the internal message variable.

SimpleNetObject is set up to automatically transmit this new message to all connected clients. It will appear in the clients' console. Parameters:

msg

The new message to send

// On the server, create a new SimpleNetObject.  This is a ghost always
// object so it will be immediately ghosted to all connected clients.
$s = new SimpleNetObject();

// All connected clients will see the following in their console:
// 
// Got message: Hello World!

// Now again on the server, change the message.  This will cause it to
// be sent to all connected clients.
$s.setMessage("A new message from me!");

// All connected clients will now see in their console:
// 
// Go message: A new message from me!