#!/usr/bin/env python
# -*- coding: utf-8 -*-
#服务器接口测试程序。使用socket连接
import QueueObjs
import copy
from ThreadManger import ThreadManger
from QueueManger import QueueManger
#python拆包实例
#http://www.linuxidc.com/Linux/2014-02/97158.htm
class ClientIOManger():
    def __init__(self):
        self.threadmanger = ThreadManger.GetInstance()                                  #线程管理器
        #self.threadmanger.createNewMysqlThread()
        self.ququmanger = QueueManger.GetInstance()                                     #列队管理器
        self.connectQueue = self.threadmanger.getConnectCacheThreadQueue()              #客户端请求列队
        self.connectThreadName = self.threadmanger.connectThreadName                    #连接线程名
        self.mainThreadName = self.threadmanger.mainThreadName                          #主线程名
    def request(self,dat,clientIP,clientsocket):                                        #此方法是线程安全的，因为没有对内部数据进行操作
        clientconnectobj = QueueObjs.ClientConnectObj(dat,clientIP,clientsocket)
        queueobj = QueueObjs.QueueMangerObj(clientconnectobj,QueueObjs.Flog_ClientConnectObj,self.mainThreadName,self.connectThreadName)
        self.connectQueue.put(copy.deepcopy(queueobj))
    def getConnectQueue(self):
        return self.connectQueue