Ejemplo n.º 1
0
 def put(self, buff):
     if SECRET_DATA_OPEN:
         buff = encode(buff, iszip=True)
     self._queue.put(buff)
Ejemplo n.º 2
0
        from sgLib.setting import Setting
        import gevent.socket
        import json
        s = gevent.socket.socket()
        port  = Setting.getGatewayPort()
        if not port:
            port = config.CFG_GATEWAYSERV_PORT
        else:
            port -= 1 #战斗端口起动的,上一个端口,调试才用到
        
        print 'config.CFG_GATEWAYSERV_HOST',config.CFG_GATEWAYSERV_HOST
        print 'port',port
        sock=(config.CFG_GATEWAYSERV_HOST, int(port) ) #8082 8888
        try:
            s.connect(sock)
        except gevent.socket.error, e:
            raise
        a = {"opt_id":optId, "para": para, "opt_key":''}
        buff = json.dumps(a)
        print '_notifyServer', buff
        if SECRET_DATA_OPEN:
            buff = encode(buff,iszip=True)
        packed_len = struct.pack(LEN_HEADER, len(buff))
        s.sendall(packed_len + buff)
        s.close()
        
if '__main__' == __name__:
    '''模块内测试'''
    c = MqManager()
    msg = {}
    c.checkOpt(msg)