Hi all,
I am trying to develop a game-server in python. Design is as
following:
- ConnectionManag er - handling/distributing incoming connections
- IOManager - handling IO recv/send operations on sockets.
(inheritable)
- Socket - basic async socket object
- SocketServer - handling multiple socket object requests.
(inheritable)
- Options - holds the server options (inheritable)
I want this code to be extensible as it can be. So I have developed it
like this. I f one is going to implement some new feature, all needs
to be done is to inherit IOManager or Server object to do it.
Inheritable objects are IOManager, SocketServer and Options.
But there is some feeling about this design that it can be better.
Here is the main.py which I am using to execute the server:
from Base.SocketServ er import SocketServer
from testIOManager import testIOManager
from Base.Options import Options
from Base.Connection Manager import ConnectionManag er
iomgr = testIOManager()
opts = Options()
# calculate how many server objects to create
# according to the maximum allowed client count.
serverCnt = opts.MAX_CLIENT _COUNT / opts.MAX_CLIENT _COUNT_PER_SERV ER
Servers = []
for i in range(serverCnt ):
server = Server(i)
Servers.append( server)
cmgr = ConnectionManag er(Servers, iomgr, opts)
cmgr.start()
With current design as server object is inheritable, I need to pass it
to ConnectionManag er object. I just have a feeling that above design
is bad in the sense of readability.
Is there any paradigms. patterns specifically in Python for above like
situations, where in a library, we design some objects to be abstract
as possbile and other non-inheritable objects using the functions?
Or just any feedback on this Design structure?
I am trying to develop a game-server in python. Design is as
following:
- ConnectionManag er - handling/distributing incoming connections
- IOManager - handling IO recv/send operations on sockets.
(inheritable)
- Socket - basic async socket object
- SocketServer - handling multiple socket object requests.
(inheritable)
- Options - holds the server options (inheritable)
I want this code to be extensible as it can be. So I have developed it
like this. I f one is going to implement some new feature, all needs
to be done is to inherit IOManager or Server object to do it.
Inheritable objects are IOManager, SocketServer and Options.
But there is some feeling about this design that it can be better.
Here is the main.py which I am using to execute the server:
from Base.SocketServ er import SocketServer
from testIOManager import testIOManager
from Base.Options import Options
from Base.Connection Manager import ConnectionManag er
iomgr = testIOManager()
opts = Options()
# calculate how many server objects to create
# according to the maximum allowed client count.
serverCnt = opts.MAX_CLIENT _COUNT / opts.MAX_CLIENT _COUNT_PER_SERV ER
Servers = []
for i in range(serverCnt ):
server = Server(i)
Servers.append( server)
cmgr = ConnectionManag er(Servers, iomgr, opts)
cmgr.start()
With current design as server object is inheritable, I need to pass it
to ConnectionManag er object. I just have a feeling that above design
is bad in the sense of readability.
Is there any paradigms. patterns specifically in Python for above like
situations, where in a library, we design some objects to be abstract
as possbile and other non-inheritable objects using the functions?
Or just any feedback on this Design structure?
Comment