server.py 986 B

12345678910111213141516171819202122232425262728293031
  1. # all imports needed by the engine itself
  2. from direct.showbase.ShowBase import ShowBase
  3. # all imports needed by the server
  4. from direct.distributed.ServerRepository import ServerRepository
  5. from panda3d.core import ConfigVariableInt
  6. # initialize the engine
  7. base = ShowBase(windowType='none')
  8. # the main server class
  9. class GameServerRepository(ServerRepository):
  10. """The server repository class"""
  11. def __init__(self):
  12. """initialise the server class"""
  13. # get the port number from the configuration file
  14. # if it doesn't exist, we use 4400 as the default
  15. tcpPort = ConfigVariableInt('server-port', 4400).getValue()
  16. # list of all needed .dc files
  17. dcFileNames = ['../direct.dc']
  18. # initialise a threaded server on this machine with
  19. # the port number and the dc filenames
  20. ServerRepository.__init__(self, tcpPort, dcFileNames=dcFileNames, threadedNet=True)
  21. # start the server
  22. GameServerRepository()
  23. base.run()