Open topic with navigation
<viztask>.waitNetwork
Wait for a network event
<viztask>.waitNetwork( |
|
sender = None |
address = None |
port = None |
) |
|
sender = None
Name of sender, list of names, or None to allow any sender
address = None
IP address of sender, list of addresses, or None to allow any address
port = None
Port number, list of ports, or None to allow any port
Remarks
This command creates a Condition object that will wait for a network event from the specified sender, address , and port.
The yielded command returns a
viz.Data object with the following information about the condition:
events | A list of network events that were received |
Return Value
viztask.Condition object
Example
import viz
import vizact
import viztask
viz.go()
def WaitNetworkTask():
while True:
# Wait for network event from localhost
data = yield viztask.waitNetwork(address='127.0.0.1')
# Process events
for e in data.events:
print(e.frame,e.message)
viztask.schedule( WaitNetworkTask() )
network = viz.addNetwork('localhost')
def SendData():
network.send( message='hello world', frame=viz.getFrameNumber() )
vizact.onkeydown(' ',SendData)
See also