Ver código fonte

add T2

master
peter 5 anos atrás
pai
commit
f26121d616

+ 0
- 98
src/backend/Components/Eventbus.ts Ver arquivo

@@ -1,98 +0,0 @@
1
-import { RPCExporter, SubscriptionResponse, ErrorResponse, SuccessResponse } from "rpclibrary";
2
-import { FrontworkAdmin } from "../Admin/Admin";
3
-import { TableDefinitionExporter } from "../Types/Interfaces";
4
-import { getLogger } from 'frontblock-generic/Types';
5
-
6
-import * as uuid from 'uuid/v4'
7
-import { TableDefiniton } from "../Types/Types";
8
-
9
-export type NotificationSeverity = 'Info' | 'Important' | 'Error'
10
-
11
-export type Notification = { 
12
-    ID?:number, 
13
-    severity: NotificationSeverity, 
14
-    topic: string,
15
-    message:string,
16
-    time?: number
17
-}
18
-
19
-export type EventbusIfc = {
20
-    Eventbus: {
21
-        getNotificationLog: () => Promise<Notification[]>
22
-        pushNotification: (notification:Notification) => Promise<void>
23
-        subscribeNotifications: (callback:Function) => Promise<SubscriptionResponse | ErrorResponse>
24
-    }
25
-} 
26
-
27
-const logger = getLogger("Eventbus", 'debug') 
28
-
29
-export class FrontworkEventBus 
30
-implements RPCExporter<EventbusIfc, "Eventbus">, TableDefinitionExporter {
31
-    name = "Eventbus" as "Eventbus" 
32
-    private subscriptions : { [uid in string]:Function } = {}
33
-
34
-    constructor(private admin: FrontworkAdmin){
35
-    }
36
-
37
-    async subscribeNotifications(callback) : Promise<SubscriptionResponse>{
38
-        const uid = uuid()
39
-        this.subscriptions[uid] = callback
40
-        return { result: 'Success', uuid: uid }
41
-    }
42
-
43
-    async getNotificationLog() : Promise<Notification[]>{
44
-        try{
45
-            return await this.admin.knex.select('*').from('notifications')
46
-        }catch(e){
47
-            logger.error(e)
48
-            throw e
49
-        }
50
-    }
51
-
52
-    async unsubscribeNotifications(uid:string) : Promise<SuccessResponse | ErrorResponse>{
53
-        if(!this.subscriptions[uid]) return { result: 'Error', message: "Unknown subscription" }
54
-        delete this.subscriptions[uid]
55
-        return { result: 'Success' }
56
-    }
57
-
58
-    async pushNotification(notification: Notification){
59
-        if(!notification.time) notification.time = Date.now()
60
-        logger.debug("inserting into notifications", notification)
61
-        try{
62
-            await this.admin.knex('notifications').insert(notification)
63
-        }catch(e){
64
-            logger.error(e)
65
-            throw e
66
-        }
67
- 
68
-        Object.values(this.subscriptions).forEach(callback => {
69
-            callback(notification)
70
-        })       
71
-    }
72
-
73
-    exportRPCs(){
74
-        return [{
75
-            name: 'getNotificationLog' as 'getNotificationLog',
76
-            call: this.getNotificationLog
77
-        },{
78
-            name: 'pushNotification' as 'pushNotification',
79
-            call: this.pushNotification
80
-        },{
81
-            name: 'subscribeNotificaitons' as 'subscribeNotifications',
82
-            hook: async (callback: Function) =>  await this.subscribeNotifications(callback)
83
-        }]
84
-    }
85
-
86
-    getTableDefinitions(): TableDefiniton[]{
87
-        return [{
88
-            name: 'notifications',
89
-            tableBuilder: (table) => {
90
-                table.increments('ID').primary();
91
-                table.string('severity');
92
-                table.string('topic');
93
-                table.string('message');
94
-                table.timestamp('time');
95
-            }
96
-        }]
97
-    }
98
-}

+ 1
- 1
src/backend/Components/PubSub/Interface.ts Ver arquivo

@@ -1,7 +1,7 @@
1 1
 import { SubscriptionResponse } from "rpclibrary"
2 2
 
3 3
 export class IPubSub<UpdateType>{
4
-    publish: (topic: string, p: UpdateType) => void
4
+    publish: (topic: string, p: UpdateType) => Promise<void>
5 5
     subscribe: (topic:string, callback: (p:UpdateType)=>any) => Promise<SubscriptionResponse>
6 6
     unsubscribe: (uuid: string) => Promise<void>
7 7
 }

+ 57
- 1
src/backend/Types/Items.ts Ver arquivo

@@ -135,7 +135,63 @@ export const T2:string[] = [
135 135
 "Band of Dark Dominion",
136 136
 "Draconic Avenger",
137 137
 "Interlaced Shadow Jerkin",
138
-"Ringo's Blizzard Boots"
138
+"Ringo's Blizzard Boots",
139
+"Scrolls of Blinding Light",
140
+"Rune of Metamorphosis",
141
+"Natural Alignment Crystal",
142
+"Mind Quickening Gem",
143
+"Lifegiving Gem",
144
+"Arcane Infused Gem",
145
+"The Black Book",
146
+"Venomous Totem",
147
+"Nemesis Spaulders",
148
+"Nemesis Robes",
149
+"Nemesis Bracers",
150
+"Nemesis Gloves",
151
+"Nemesis Belt",
152
+"Nemesis Boots",
153
+"Netherwind Mantle",
154
+"Netherwind Robes",
155
+"Netherwind Bindings",
156
+"Netherwind Gloves",
157
+"Netherwind Belt",
158
+"Netherwind Boots",
159
+"Bloodfang Spaulders",
160
+"Bloodfang Chestpiece",
161
+"Bloodfang Bracers",
162
+"Bloodfang Gloves",
163
+"Bloodfang Belt",
164
+"Bloodfang Boots",
165
+"Stormrage Pauldrons",
166
+"Stormrage Chestguard",
167
+"Stormrage Bracers",
168
+"Stormrage Handguards",
169
+"Stormrage Belt",
170
+"Stormrage Boots",
171
+"Dragonstalker's Spaulders",
172
+"Dragonstalker's Breastplate",
173
+"Dragonstalker's Bracers",
174
+"Dragonstalker's Guantlets",
175
+"Dragonstalker's Belt",
176
+"Dragonstalker's Greaves",
177
+"Judgement Spaulders",
178
+"Judgement Breastplate",
179
+"Judgement Bindings",
180
+"Judgement Guantlets",
181
+"Judgement Belt",
182
+"Judgement Sabatons",
183
+"Pauldrons of Transcendence",
184
+"Robes of Transcendence",
185
+"Bindings of Transcendence",
186
+"Handguards of Transcendence",
187
+"Belt of Transcendence",
188
+"Boots of Transcendence",
189
+"Pauldrons of Wrath",
190
+"Breastplate of Wrath",
191
+"Bracelets of Wrath",
192
+"Guantlets of Wrath",
193
+"Waistband of Wrath",
194
+"Sabatons of Wrath"
139 195
 ]
140 196
 
141 197
 export type AllItems = {

Carregando…
Cancelar
Salvar