Guest User

Untitled

a guest
Dec 9th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. const {CasparCG} = require("casparcg-connection");
  2. const {CasparCGSocketStatusEvent} = require("casparcg-connection");
  3.  
  4. let host = process.argv[2] || 'localhost';
  5. let port = process.argv[3] || '5250';
  6. let check = process.argv[4] || 'info';
  7. let file = process.argv[5] || null;
  8.  
  9. let connection = new CasparCG({host: host, port: port, autoConnect: false});
  10.  
  11.  
  12. let checks = {
  13. threads: async () => {
  14. try {
  15. let command = await connection.infoThreads();
  16. if (command.response.data.length) {
  17. console.log(command.response.data.length);
  18. }
  19.  
  20. } catch (e) {
  21. console.log('FAIL');
  22. } finally {
  23. connection.disconnect();
  24. clearTimeout(limit);
  25. }
  26. },
  27. info: async () => {
  28. //console.log('in info check');
  29. try {
  30. let command = await connection.info(1,1);
  31. if (command.response && command.response.raw === '201 INFO OK') {
  32. console.log(command.response);
  33. }
  34. else {
  35. console.log('FAIL');
  36. }
  37. } catch (e) {
  38. // Deal with the fact the chain failed
  39. console.log('FAIL')
  40. } finally {
  41. setTimeout(checks['info'], 20)
  42. }
  43. },
  44. load: async (layer) => {
  45. console.log('in load');
  46. try {
  47. if (layer >= 5) layer = 1;
  48. let clip = (layer % 2 === 0) ? file ;
  49. let command = await connection.loadbg(1, layer, clip);
  50.  
  51. if (command.response) {
  52. console.log(command.response);
  53. }
  54. else {
  55. console.log('FAIL');
  56. }
  57. } catch (e) {
  58. // Deal with the fact the chain failed
  59. console.log('FAIL')
  60. } finally {
  61.  
  62. layer++;
  63. setTimeout(checks['load'], 100, layer)
  64. }
  65. }
  66.  
  67.  
  68. };
  69.  
  70.  
  71. connection.connect();
  72.  
  73. (
  74. checks[check]
  75. )(1);
Add Comment
Please, Sign In to add comment