Module driver.network
This is the network module which holds the MasterServer and the
Connection objects and handles all socket interface things.
It handles connections and disconnections as well as user input. It
kicks off appropriate hooks and events accordingly.
A connection<handling connections> happens
whenever the master socket is tickled.
Connections are handled this way:
-
the Master socket gets tickled and generates a Connection object
which wraps around the socket object
-
the network thread tosses a HookEvent onto the event queue which
will send a message to the "connect" Hook with the
connection as an argument
-
(some time passes...)
-
the HookEvent is executed and sends a message to the
"connect" Hook with the connection as an
argument--functions that don't want the connection to happen will
mark the Connection object as such with a _do_not_connect = 1
-
at the end of the hook (the last item), the network checks for the
_do_not_connect flag:
if _do_not_connect == 0:
1. locks the connections list
2. adds the connection to the list
3. unlocks the connections list
else:
1. sends a HookEvent for "disconnect" with the Connection object
A disconnect<handling disconnects> can happen
for a variety of reasons:
-
they drop their connection (linkdeath) which causes an Exception
in the network thread
-
they quit out which happens in the event handling thread
-
a connection occurs, but someone marks it as _do_not_connect so it
immediately gets disconnected
When a disconnect happens:
-
a HookEvent is created with the Connection disconnecting and why
it's being disconnected (QUIT or LINKDEATH)
-
(some time passes...)
-
at the beginning of the hook (the first item), the network removes
the connection from the list
-
the mudlib does whatever it does with disconnects
Classes |
Connection |
The connection object handles dealing with the user on a socket
level. |
MasterServer |
The MasterServer handles all the incoming network connections and
holds a series of Connection objects. |
_MASTER_SOCKET
-
- Type:
-
str
- Value:
|