Status page for GenSoc
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

28 lines
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. }