As an example, here's an example of a message broker script. Let me know if this gets you closer.
The first script should be saved as a stay-open application. When launched it creates three new windows with separate ssh connections to the target. You can open as many connections as you need.
It also saves a reference to each connection for later use (here I use labels 'codec1', 'codec2' and 'codec3', but you can use anything you like).
global codec1win, codec2win, codec3win
on run
set theUsername to "me"
set theHostname to "shell.xyz123.com"
tell application "Terminal"
-- just open three connections -- extend as much as you like
set codec1win to do script "ssh " & theUsername & "@" & theHostname
set codec2win to do script "ssh " & theUsername & "@" & theHostname
set codec3win to do script "ssh " & theUsername & "@" & theHostname
end tell
end run
on idle {}
-- just a tickle to keep the app alive
return 60
end idle
on sendTo(theHost, theCommand)
if theHost = "codec1" then
tell application "Terminal" to do script theCommand in codec1win
else if theHost = "codec2" then
tell application "Terminal" to do script theCommand in codec2win
else if theHost = "codec3" then
tell application "Terminal" to do script theCommand in codec3win
end if
-- etc...
end sendTo
Then the script then sits idling in the background, doing nothing until it's told to by the second script.
This second script simply sends a message to the broker script and passes in the connection identifier and the command to run. The broker identifies the target and sends the appropriate command.
tell application "CodecBroker"
sendTo("codec1", "foo")
end tell
(here 'CodecBroker' is what I named my stay-open script. You can call it whatever you like).
You can duplicate the second script as many times as you like for as many connection/command combinations as you like. You may also be able to do something with BetterTouchTool to pass in parameters rather than hardcoding the commands in the script - that requires more knowledge of BetterTouchTool than I have.
This is only one approach, but it sounds like it's along the lines of what you were looking for.