Example #1
0
    def lost_connection(self, server, channel):
        ckey = channel.peername  #自改abu为channel加上此属性,因socket已不可用,不能getpeername
        msg = 'lost a connection:%s' % str(ckey)
        comm.trace(msg)
        if ckey in self.Clients:
            try:  #清空些用户的资料
                uid = self.Clients[ckey]['uid']
                if uid > 0:
                    Gcore.getMod('Login', uid).logout()  #更新
                    Gcore.onlineUser.pop(uid, None)  #用户落线
                Gcore.delUserStorage(uid)
            except Exception, e:
                print 'lost_connection >> ', e
            self.Clients.pop(ckey, None)

        Gcore.delListenerStorage(ckey)  #如果是监听者就清除

    def mqPush(self, ckey, optId, optKey, para):
        '''来自mqReceiver的消息,告诉玩家正在被打'''
        #print ' in mqPush',para
        Users = para.get('UserId')
        Type = para.get('Type')
        Data = para.get('Data', {})
        Gcore.push(105, Users, Data, Type)


def main():

    port = Setting.getGatewayPort()
    if not port:
        port = Cfg.CFG_GATEWAYSERV_PORT
Example #2
0
    def lost_connection(self, server, channel):
        ckey = channel.peername #自改abu为channel加上此属性,因socket已不可用,不能getpeername
        msg = 'lost a connection:%s' % str(ckey)
        comm.trace(msg)
        if ckey in self.Clients:
            try: #清空些用户的资料 
                uid = self.Clients[ckey]['uid']
                if uid > 0:
                    Gcore.getMod('Login', uid).logout() #更新
                    Gcore.onlineUser.pop(uid,None) #用户落线
                Gcore.delUserStorage(uid)
            except Exception,e:
                print 'lost_connection >> ',e
            self.Clients.pop(ckey,None) 
            
        Gcore.delListenerStorage(ckey) #如果是监听者就清除
    
    def mqPush(self,ckey,optId,optKey,para):
        '''来自mqReceiver的消息,告诉玩家正在被打'''
        #print ' in mqPush',para
        Users = para.get('UserId')
        Type = para.get('Type')
        Data = para.get('Data',{})
        Gcore.push(105, Users, Data, Type)
        


        
def main():
    
    port  = Setting.getGatewayPort()