Guest User

Untitled

a guest
Oct 16th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. // from the game instance
  2.  
  3. const master = new TLSClient({
  4. options: {
  5. ca: fs.readFileSync(config.API_CERT),
  6. },
  7. reconnectInterval: 2000,
  8. host: config.MASTER_API_HOST,
  9. port: config.MASTER_API_PORT,
  10. password: config.API_PASSWORD
  11. })
  12.  
  13. master.on('authenticated', () => {
  14. syncListing()
  15. })
  16.  
  17. master.on('message', message => { ... })
  18. master.on('close', () => { ... })
  19. master.on('error', err => { ... })
  20.  
  21. function syncListing() {
  22. master.send({
  23. type: 'list',
  24. listing: {
  25. version: config.GAME_VERSION,
  26. port: 8001,
  27. currentPlayers: 0, // these would be variables
  28. maxPlayers: 100,
  29. mode: 'idle',
  30. etc: 'anything'
  31. }
  32. })
  33. }
  34.  
  35. function updatePlayerCount() {
  36. master.send({
  37. type: 'list',
  38. listing: {
  39. currentPlayers: 10
  40. }
  41. })
  42. }
Add Comment
Please, Sign In to add comment