NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

notificationGenerator.py (2894B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\notifications\client\generator\notificationGenerator.py
      2 from __future__ import print_function
      3 from notifications.common.notification import Notification
      4 from notifications.client.generator.simpleRandomDistributor import SimpleRandomDistributer
      5 import blue
      6 
      7 class NotificationGenerator:
      8 
      9     def __init__(self):
     10         self.currentIndex = 0
     11         self.fakeThisSequence = [0,
     12          0,
     13          1,
     14          1,
     15          2,
     16          2,
     17          0,
     18          0,
     19          1,
     20          1,
     21          1,
     22          1]
     23         self.internalSequence = 0
     24         self.isGenerating = False
     25 
     26     def loadConfig(self, config):
     27         pass
     28 
     29     def Start(self):
     30         self.distributer = SimpleRandomDistributer(10, 20000, generateCallback=self.MakeFakeNotification, finishedCallback=self.OnDistributerFinished, nowTimeProviderFunction=blue.os.GetWallclockTime, step=10, oddsOfEventPerCheck=0.1, generateMax=100)
     31         self.distributer.Start()
     32         self.isGenerating = True
     33 
     34     def Stop(self):
     35         print('Aborting Generator')
     36         self.distributer.Abort()
     37         self.isGenerating = False
     38 
     39     def OnDistributerFinished(self):
     40         print('Generator finished')
     41         self.isGenerating = False
     42 
     43     def MakeFakeNotification(self, sequence):
     44         self.internalSequence = self.internalSequence + 1
     45         actualSequence = sequence + self.internalSequence
     46         self.currentIndex = self.currentIndex + 1
     47         type = self.fakeThisSequence[actualSequence % len(self.fakeThisSequence)]
     48         if type is 0:
     49             template = FakeNormalNotification()
     50         elif type is 2:
     51             template = FakeSkillNotification(sequence)
     52         else:
     53             template = FakeCharacterNotification()
     54         template.generate(actualSequence)
     55 
     56 
     57 class FakeSkillNotification:
     58 
     59     def __init__(self, sequenceNr):
     60         self.sequence = sequenceNr
     61 
     62     def generate(self, sequence):
     63         skillsvc = sm.StartService('skills')
     64         skillsvc.ShowSkillNotification([3300 + self.sequence], 10, True)
     65 
     66 
     67 class FakeCharacterNotification:
     68     flipbit = False
     69 
     70     def generate(self, sequence):
     71         FakeCharacterNotification.flipbit = not FakeCharacterNotification.flipbit
     72         if FakeCharacterNotification.flipbit:
     73             sm.ScatterEvent('OnContactLoggedOn', 90000001)
     74         else:
     75             sm.ScatterEvent('OnContactLoggedOff', 90000001)
     76 
     77 
     78 class FakeNormalNotification:
     79 
     80     def generate(self, sequence):
     81         newNotification = Notification(notificationID=-1, typeID=Notification.NORMAL_NOTIFICATION, senderID=90000001, receiverID=90000001, processed=False, created=blue.os.GetWallclockTime(), data={})
     82         newNotification.subject = 'Subject:' + str(sequence)
     83         newNotification.body = 'Body:' + str(sequence)
     84         sm.ScatterEvent('OnNewNotificationReceived', newNotification)