K
k3xji
Hi all,
I am trying to develop a game-server in python. Design is as
following:
- ConnectionManager - 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.SocketServer import SocketServer
from testIOManager import testIOManager
from Base.Options import Options
from Base.ConnectionManager import ConnectionManager
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_SERVER
Servers = []
for i in range(serverCnt):
server = Server(i)
Servers.append(server)
cmgr = ConnectionManager(Servers, iomgr, opts)
cmgr.start()
With current design as server object is inheritable, I need to pass it
to ConnectionManager 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:
- ConnectionManager - 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.SocketServer import SocketServer
from testIOManager import testIOManager
from Base.Options import Options
from Base.ConnectionManager import ConnectionManager
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_SERVER
Servers = []
for i in range(serverCnt):
server = Server(i)
Servers.append(server)
cmgr = ConnectionManager(Servers, iomgr, opts)
cmgr.start()
With current design as server object is inheritable, I need to pass it
to ConnectionManager 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?