Vizard 7 » Command Index » Vizard modules » viznet » <viznet:server>.sendClient
7.7

<viznet:server>.sendClient

Send an event to a connected client

<viznet:server>.sendClient(  
client  
id  
*args  
**kw  
)  
client
Name of client
id
Event ID
*args
Optional arguments to pass to the client
**kw
Optional keyword arguments to pass to the client

Remarks

This command will send an event only to the specified client. The client can register for the event as a normal callback. The event structure is the same as a network event structure.

Return Value

None

Example

Server:
import viznet

viznet.server.start()

MY_EVENT = viznet.id('MyEvent')

.
.
.

viznet.server.sendClient('CLIENT1',MY_EVENT,message='Hello')

Client:
import viznet

viznet.client.connect('ServerName')

MY_EVENT = viznet.id('MyEvent')

def onMyEvent(e):
    print('Received event from server with message:',e.message)
viz.callback(MY_EVENT,onMyEvent)