Writing a Server¶
A server is generally made up of two parts:
- A subclass of
ServerFactory
. Under normal circumstances only oneServerFactory
is instantiated. This object represents your game server as a whole. - A subclass of
ServerProtocol
. Each object represents a connection with a client.
See also
Skeleton Server¶
By default quarry takes clients through the authentication process and then
switches into the “play” protocol mode. Normally at this point you would
implement player_joined()
to either
disconnect the client or start the process of spawning the player. In the
skeleton server below we don’t do either, which leaves the client on the
“Logging in…” screen. Please see the Examples for less pointless
servers.
from twisted.internet import reactor
from quarry.net.server import ServerFactory, ServerProtocol
class ExampleServerProtocol(ServerProtocol):
pass
class ExampleServerFactory(ClientFactory):
protocol = ExampleServerProtocol
factory = ExampleServerFactory()
factory.listen('127.0.0.1', 25565)
reactor.run()