This is more for personal curiosity as to what I could do to optimize this code. It works as is, it's just wasted space.

I am opening three different sockets to the same connection; can I reduce this to one?

I've tried putting all the commands that I want to push together but it only ever executes the first POST and never the other two. I've tried putting CRLF's between them too, but to no avail, it still only does the first one.

Code:
alias newtip {
  var %sockone vMix.name
  var %socktwo vMix.qty
  var %sockthree vMix.play
  sockopen %sockone localhost 8088
  sockopen %socktwo localhost 8088
  sockopen %sockthree localhost 8088
}

on *:sockopen:vmix.name: {
  sockwrite -n vmix.name POST /API/?Function=SetText&Input=ea03e74f-86e3-48d4-84af-5623c39c9793&SelectedName=Description&Value= $+ %username
  sockwrite -n $sockname $crlf
}

on *:sockopen:vmix.qty: {
  var %qty $calc(%tqty / 2.4)
  if (%qty = 1) {
    var %qtymsg $eval(%2b,0) $+ 1 $+ $eval(%20,0) $+ tip!
  }
  else {
    var %qtymsg $eval(%2b,0) $+ %qty $+ $eval(%20,0) $+ tips!
  }
  sockwrite -n vmix.qty POST /API/?Function=SetText&Input=ea03e74f-86e3-48d4-84af-5623c39c9793&SelectedName=Text1&Value= $+ %qtymsg
  sockwrite -n $sockname $crlf
}

on *:sockopen:vmix.play: {
  sockwrite -n vmix.play POST /API/?Function=OverlayInput1&Input=ea03e74f-86e3-48d4-84af-5623c39c9793
  sockwrite -n $sockname $crlf
  splay -w tip_sound.wav
}

on *:sockread:vmix.name: {
  var %sockread
  sockread %sockread
  sockclose vmix.name
}

on *:sockread:vmix.qty: {
  var %sockread
  sockread %sockread
  sockclose vmix.qty
}

on *:sockread:vmix.play: {
  var %sockread
  sockread %sockread
  sockclose vmix.play
}

Last edited by Zebulan; 15/12/14 09:46 PM.