Vizard 7 » Command Index » Vizard objects » network » <network>.send
7.6

<network>.send

This action will send data to the network object

<network>.send(  
*args  
**kwargs  
)  
*args
Any amount and type of data
**kwargs
Any amount and type of keyword arguments

Remarks

This action will send the data to the network object. The data is encoded using the Python pickle module.

If you are attempting to use the network object to communicate with a non-Python based application, then use the <network>.sendRaw command to send raw unpickled data.

This command will trigger a viz.NETWORK_EVENT on the receiving computer. A viz.NetworkEvent object is passed to the event callback with the following attributes:

Event attribute

sender

The name of the computer that sent the message.

address

The IP address of the computer that sent the message.

port

The port number the message was received on.

data

A tuple containing the positional data specified through the *args parameter.

<keyword>

The value of the specified keyword argument from the **kwargs parameter

Return Value

None

Example

network = viz.addNetwork('localhost')

def onKeyDown(key):
    if key == ' ':
        network.send(1,2,3,foo=4,bar=5)

viz.callback(viz.KEYDOWN_EVENT,onKeyDown)

def onNetwork(e):
    print('Positional data:',e.data)
    print(e.foo,e.bar)

viz.callback(viz.NETWORK_EVENT,onNetwork)

See also

<network>.sendRaw