| Home | Trees | Indices | Help |
|
|---|
|
|
object --+
|
netshared.NetworkEndpoint --+
|
Server
A server. To allow network clients to communicate with this class call listen() with a network address then periodically call update() to ensure data is kept flowing and connects/disconnects are handled.
| Instance Methods | |||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
Inherited from |
|||
| Class Variables | |
CONNECTED = 104
(Inherited from legume.netshared.NetworkEndpoint)
|
|
CONNECTING = 103
(Inherited from legume.netshared.NetworkEndpoint)
|
|
DISCONNECTED = 100
(Inherited from legume.netshared.NetworkEndpoint)
|
|
ERRORED = 101
(Inherited from legume.netshared.NetworkEndpoint)
|
|
LISTENING = 102
(Inherited from legume.netshared.NetworkEndpoint)
|
|
MTU = 1400
(Inherited from legume.netshared.NetworkEndpoint)
|
|
| Properties | |
|
peercount Number of connected peers. |
|
|
peers A list of connected peers. |
|
| OnMessage | |
| OnConnectRequest | |
| OnError | |
| OnDisconnect | |
| socket (Inherited from legume.netshared.NetworkEndpoint) | |
| state (Inherited from legume.netshared.NetworkEndpoint) | |
| timeout (Inherited from legume.netshared.NetworkEndpoint) | |
|
Inherited from |
|
| Method Details |
Create an instance of a new Server endpoint. Use the message_factory
parameter to specify an alternative to the global messages.message_factory
instance::
mf = legume.messages.MessageFactory()
server = legume.Server(message_factory=mf)
|
Disconnect a peer by specifying their address.
Equivalent to::
server.get_peer_by_address(peer_address).disconnect()
|
Begin listening for incoming connections.
address is a tuple of the format (hostname, port)
This method change the class state to LISTENING::
# Begin listening on port 4000 on all IP interfaces
server = legume.Server()
server.listen(('', 4000))
|
Pumps buffers and dispatches events. Call regularly to ensure
buffers do not overfill or connections time-out::
server = legume.Server()
server.listen(('', 4000))
while True:
server.update()
# Other update tasks here..
time.sleep(0.001)
|
Send a non-reliable packet to all connected peers.
packet is an instance of a legume.message.BaseMessage subclass::
message = ExampleMessage()
message.chat_message.value = "Hello!"
message.sender.value = "@X3"
server.send_message_to_all(message)
|
Send a reliable message to all connected peers. message is an instance of a legume.message.BaseMessage subclass. |
| Property Details |
peercountNumber of connected peers.
|
peersA list of connected peers.
|
OnMessage
|
OnConnectRequest
|
OnError
|
OnDisconnect
|
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Wed Jul 13 20:33:07 2011 | http://epydoc.sourceforge.net |