19 lines
573 B
TypeScript
19 lines
573 B
TypeScript
import { SocketEvent } from '#application/enums';
|
|
import { BaseEvent } from '#application/base/baseEvent'
|
|
import WeatherManager from '#managers/weatherManager'
|
|
|
|
export default class Weather extends BaseEvent {
|
|
public listen(): void {
|
|
this.socket.on(SocketEvent.WEATHER, this.handleEvent.bind(this))
|
|
}
|
|
|
|
private async handleEvent(): Promise<void> {
|
|
try {
|
|
const weather = WeatherManager.getWeatherState()
|
|
this.socket.emit(SocketEvent.WEATHER, weather)
|
|
} catch (error: any) {
|
|
this.logger.error('weather error: ' + error.message)
|
|
}
|
|
}
|
|
}
|