@@ -122,7 +122,6 @@ export default {
122
122
},
123
123
created () {
124
124
this .useStreamOrStaticData ();
125
- this .getMapString ();
126
125
},
127
126
computed: {
128
127
headers () {
@@ -239,8 +238,14 @@ export default {
239
238
async useStreamOrStaticData () {
240
239
// Template will contain v-rows/etc like on main Team page.
241
240
let matchData = await this .GetMatchData (this .match_id );
242
- if (matchData .end_time == null ) this .GetMapPlayerStatsStream (matchData);
243
- else this .GetMapPlayerStats (matchData);
241
+ if (matchData .end_time == null ) {
242
+ this .GetMapStatsStream (matchData);
243
+ this .GetMapPlayerStatsStream (matchData);
244
+ }
245
+ else {
246
+ this .getMapString (matchData);
247
+ this .GetMapPlayerStats (matchData);
248
+ }
244
249
},
245
250
async retrieveStatsHelper (serverResponse , matchData ) {
246
251
if (typeof serverResponse == " string" ) return ;
@@ -324,34 +329,51 @@ export default {
324
329
}
325
330
return ;
326
331
},
327
- async getMapString ( ) {
332
+ async GetMapStatsStream ( matchData ) {
328
333
try {
329
- let mapStats = await this .GetMapStats (this .match_id );
330
- if (typeof mapStats == " string" ) return ;
331
- mapStats .forEach ((singleMapStat , index ) => {
332
- this .arrMapString [index] = {};
333
- this .arrMapString [index].score =
334
- " Score: " +
335
- singleMapStat .team1_score +
336
- " " +
337
- this .GetScoreSymbol (
338
- singleMapStat .team1_score ,
339
- singleMapStat .team2_score
340
- ) +
341
- " " +
342
- singleMapStat .team2_score ;
343
- this .arrMapString [index].start =
344
- " Map Start: " + new Date (singleMapStat .start_time ).toLocaleString ();
345
- this .arrMapString [index].end =
346
- singleMapStat .end_time == null
347
- ? null
348
- : " Map End: " + new Date (singleMapStat .end_time ).toLocaleString ();
349
- this .arrMapString [index].map = " Map: " + singleMapStat .map_name ;
350
- this .arrMapString [index].demo = singleMapStat .demoFile ;
334
+ let sseClient = await this .GetEventMapStats (this .match_id );
335
+ await sseClient .connect ();
336
+ await sseClient .on (" mapstats" , async message => {
337
+ await this .retrieveMapStatsHelper (message,matchData);
351
338
});
352
339
} catch (error) {
353
- console .log (" String error " + error);
340
+ console .log (" Our error: " + error);
341
+ } finally {
342
+ this .isLoading = false ;
354
343
}
344
+ return ;
345
+ },
346
+ async getMapString (matchData ) {
347
+ try {
348
+ let res = await this .GetMapStats (this .match_id );
349
+ await this .retrieveMapStatsHelper (res, matchData);
350
+ } catch (error) {
351
+ console .log (" Our error: " + error);
352
+ } finally {
353
+ this .isLoading = false ;
354
+ }
355
+ return ;
356
+ },
357
+ async retrieveMapStatsHelper (serverResponse , matchData ) {
358
+ if (typeof serverResponse == " string" ) return ;
359
+ await serverResponse .forEach ((singleMapStat , index ) => {
360
+ this .$set (this .arrMapString [index], ' score' , " Score: " +
361
+ singleMapStat .team1_score +
362
+ " " +
363
+ this .GetScoreSymbol (
364
+ singleMapStat .team1_score ,
365
+ singleMapStat .team2_score
366
+ ) +
367
+ " " +
368
+ singleMapStat .team2_score );
369
+ this .$set (this .arrMapString [index], ' start' , " Map Start: " + new Date (singleMapStat .start_time ).toLocaleString ());
370
+ this .$set (this .arrMapString [index], ' end' , singleMapStat .end_time == null ?
371
+ null :
372
+ " Map End: " + new Date (singleMapStat .end_time ).toLocaleString ());
373
+ this .$set (this .arrMapString [index], ' map' , " Map: " + singleMapStat .map_name );
374
+ this .$set (this .arrMapString [index], ' demo' , singleMapStat .demoFile );
375
+ });
376
+ if (matchData .end_time != null ) this .isFinished = true ;
355
377
}
356
378
}
357
379
};
0 commit comments