Example #1
0
    def handle(self, channel, request):

        ckey = channel.getpeername()
        recData = comm.decodePacket(request)  #(协议号,内容)

        if not recData:  #参数异常
            channel._send("xxxx Wu ask send xxxx")
            return

        if not ckey in self.Clients:
            self.Clients[ckey] = {}
            self.Clients[ckey]['uid'] = 0
            self.Clients[ckey]['Channel'] = channel

        optId = recData[0]
        optKey = recData[1]
        para = recData[2]

        if 1001 <= optId <= 9999:  #系统内部预留
            if optId == 1001:  #聊天监控
                from sgLib.pyMcrypt import checkListenKey
                if checkListenKey(para.get('keyWord')):
                    print '聊天接入成功'
                    Gcore.setListenerData(ckey, channel,
                                          para.get('chatChannel'))
                    response = Gcore.out(1001)
                    channel._send(comm.json_encode(response))
                else:
                    print '聊天接入失败'

        else:
            if Cfg.TEST:  #获取开发人员指定用户ID
                uid_tmp = Setting.developer(ckey[0])
                if uid_tmp:
                    self.Clients[ckey]['uid'] = uid_tmp

            self.checkOpt(ckey, optId, optKey, para)
Example #2
0
    def handle(self, channel, request):

        ckey = channel.getpeername()
        
        recData = comm.decodePacket(request) #(协议号,内容)
        if not recData: #参数异常
            channel._send("xxxx Wu ask send xxxx") 
            return 
        
        if not ckey in self.Clients:
            self.Clients[ckey] = {}
            self.Clients[ckey]['uid'] = 0 
            self.Clients[ckey]['Channel'] = channel

        optId = recData[0]
        optKey = recData[1]
        para = recData[2]
        
        if 1001<=optId<=9999: #系统内部预留
            if optId == 1001: #聊天监控
                from sgLib.pyMcrypt import checkListenKey
                if checkListenKey(para.get('keyWord')):
                    print '聊天接入成功'
                    Gcore.setListenerData(ckey, channel, para.get('chatChannel'))
                    response = Gcore.out(1001)
                    channel._send( comm.json_encode(response) )
                else:
                    print '聊天接入失败'
                    
                
        else:
            if Cfg.TEST: #获取开发人员指定用户ID
                uid_tmp = Setting.developer(ckey[0]) 
                if uid_tmp:
                    self.Clients[ckey]['uid'] = uid_tmp
                  
            self.checkOpt(ckey, optId, optKey, para)