- class gadgets.sockets.Addresses(host='localhost', in_port=6111, out_port=6112, req_port=6113)[source]¶
Addresses is a helper class that lets Broker and Sockets easily connect to the correct url and port.
A Gadgets system can be distributed across multiple computers. You must decide which instance is the master, and use the default ‘localhost’ as the host name. The subsequent instances can then be given the ip address of the master system. Then all Gadgets instances will be able to communicate with each other and behave as one system.
- class gadgets.sockets.Sockets(addresses=None, events=[], bind_to_request=False)[source]¶
Every subclass of Gadget uses this class for all of its communication. You can also use this class if you wish to communicate with the system without a Gadget subclass (on the command line for example).
Sockets wraps two zeromq sockets and uses them to receive incoming messages and send messages out to the rest of the system. It uses zmq.SUB and zmq.PUB so each Gadget can subscribe to only the incoming events that it needs. The events argument in __init__ determines what events will be received.
- __init__(addresses=None, events=[], bind_to_request=False)[source]¶
addresses: an instance of gadgets.address:Address events: a list of events to subscribe to. Only
messages that start with the events in this list will be received.
- NOTE: If you subscribe to ‘update’
- you will receive messages like ‘update temperature’
- __weakref__¶
list of weak references to the object (if defined)