server.py 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  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. from AIRepository import AIRepository
  7. # initialize the engine
  8. base = ShowBase(windowType='none')
  9. # the main server class
  10. class GameServerRepository(ServerRepository):
  11. """The server repository class"""
  12. def __init__(self):
  13. """initialise the server class"""
  14. # get the port number from the configuration file
  15. # if it doesn't exist, we use 4400 as the default
  16. tcpPort = ConfigVariableInt('server-port', 4400).getValue()
  17. # list of all needed .dc files
  18. dcFileNames = ['../direct.dc', 'sample.dc']
  19. # initialise a threaded server on this machine with
  20. # the port number and the dc filenames
  21. ServerRepository.__init__(self, tcpPort, dcFileNames=dcFileNames, threadedNet=True)
  22. # start the server
  23. GameServerRepository()
  24. AIRepository()
  25. base.run()