Status page for GenSoc
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 

28 rindas
711 B

  1. import * as R from 'ramda';
  2. import * as MumblePing from 'mumble-ping';
  3. interface MumbleStatus {
  4. online: boolean,
  5. currentUsers?: number,
  6. maxUsers?: number,
  7. }
  8. const offlineStatus: MumbleStatus = { online: false };
  9. export default function getMumbleStatus(host: string, port: number = 64738): PromiseLike<MumbleStatus> {
  10. return new Promise((resolve) => {
  11. let connected = false;
  12. MumblePing(host, port, (err, res) => {
  13. connected = true;
  14. if (!err) {
  15. resolve({ online: true, maxUsers: res.maxUsers, currentUsers: res.users })
  16. } else {
  17. resolve(offlineStatus);
  18. }
  19. });
  20. setTimeout(() => {
  21. if (!connected) resolve(offlineStatus);
  22. }, 1000);
  23. });
  24. }