'''
Created on 2012-8-14
@author: qs
'''
#from twisted.internet import epollreactor
#epollreactor.install()
from twisted.internet import selectreactor
selectreactor.install()
from twisted.internet.protocol import ClientFactory, Protocol
from twisted.internet import reactor
from buffer import Buffer
import struct
import sys
import threading
from msgqueue import MessageQueue
class Service(Protocol):
def __init__(self):
self.index = 0
self.identify = 0
def connectionMade(self):
print "new client come!"
self.factory.service_tick = self.factory.service_tick + 1
self.identify = self.factory.service_tick
self.factory.bind_service(self)
def connectionLost(self, reason):
print "new client lost"
self.factory.unbind_service(self)
def dataReceived(self, data):
message = struct.pack
用python的twisted做个简单游戏服务器原形--客户端连接monitor管理类
最新推荐文章于 2020-12-11 08:06:24 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)