New Addon 1: LibRpc-0.2
LibRpc is an embeddable library for making remote procedure calls between WoW clients. An addon running on one client can call any global API on another client as long as the appropriate security permissions have been set using LibTrust. (Normal in-combat restrictions may also apply.) For example:
Code:
LibStub("LibRpc-0.2"):RemoteCall("Katator", nil, "SendChatMessage", "hello world")

LibRpc also supports registration for remote events:
(On Iaggo)
Code:
/script function printEvent(...) SendChatMessage(table.concat({...}, " ")) end
/script LibStub("LibRpc-0.2"):RegisterRemoteEvent("Katator","AUTOFOLLOW_BEGIN", printEvent)
(On Katator)
(On Iaggo)

Remote procedure calls can be made through a cmdline interface:
Code:
/rpc Katator SendChatMessage "hello world"
LibRpc uses AceComm-3.0 for RPC messages and AceSerializer-3.0 for marshalling function arguments. Any type that AceSerializer can handle should be usable as a function argument.
New Addon 2: LibTrust-0.1
LibTrust is an embeddable library for establishing trust relationships between characters. You don't want just anyone with LibRpc installed making WoW API calls on your toon -- they could mail all of your gold to another account, for example. LibRpc lets you say who you trust, presumably just your other characters.
LibTrust starts out with an empty database of permissions. To enable trust between your characters use the "/trust allow" command. There are also commands to deny trust and allow/deny on specific APIs. Type /trust for more info.
Installation:
1) Download the zip files for both addons: LibRpc-0.2, LibTrust-0.1
2) Unzip to [WoW]\Interface\AddOns
3) Close WoW and restart
You should see both LibRpc-0.2 and LibTrust-0.1 listed in your installed addons. Make sure they are enabled.
Configuration:
Log onto 2 of your toons. Let's call them Iaggo and Katator. Our goal will be to make Katator dance with Iaggo via a /rpc command:
(On Iaggo)
Code:
/rpc katator DoEmote dance Iaggo
Initially if you type this LibRpc will pop a LUA error on Katator: "RPC message from untrusted sender: Iaggo". Katator doesn't trust Iaggo, so she rejects the message. To fix this type the following:
(On Katator)
Now when you run the /rpc command above Katator will start dancing with Iaggo. However, you'll also get an error message on Iaggo: "RPC message from untrusted sender Katator". The second message is Katator sending back the return values from the DoEmote call. In this case the return value is empty, but there is still a message sent. To get rid of the error we need to tell Iaggo to trust Katator:
(On Iaggo)
Code:
/trust allow Katator
Now the /rpc command will work correctly with no errors.

Here's another example with a return value:
Code:
/rpc katator UnitArmor player

WTF Can I Do With This?
I started working on this for another mod, to be called MetaMacro. The idea is to reprogram macros on all of your clones dynamically, so you can easily switch which default totems your shaman clones drop, which characters are in your target macros, etc. I decided to release the RPC stuff first though because I want feedback and I thought that the /rpc command might be generally useful in macros.
Some other ideas:
<add here>
To Do:
- Upload to Ace SVN
- API documentation
- Improved configuration for LibTrust, possibly a GUI
- [s]LibRpc option to limit debugging spew[/s]
- [s]Support for remote event registration[/s]
- [s]Demo remote event registration[/s]
- Slash commands for events
- Require string id instead of self in API calls if LibRpc is used non-embedded (like CallbackHandler-1.0)
- Smart event unregistration on UI reoload
- Better way to get the source of a fired event
- /rpc party ... to avoid repetitive commands in macros
- Bucket events
- AceEvent message support (user events)
- Unit tests
Issues:
- [s]Callback function info does not include return value[/s]
- [s]Event args not being passed properly[/s]
- I have learned that embedded libs can't have saved vars, so LibRpc has to be an addon
- Event unregistration w/ multiple client addons may cause conflicts
Updates:
- 4/15/08: Fixed bug with callback function not geting return value, partial code for remote events
- 4/17/08: LibRpc-0.2, remote event support
- 4/18/08: Event args now passed correctly
- 4/23/08: Debuging messages off by default, "/rpc debug" to toggle
- 4/23/08: Removed overly picky error when calling UnregisterAllRemoteEvents with no events registered
- 4/26/08: Fixed embedding implementation for both libs, should now be embeddable
- 5/17/08: Fixed a LibTrust bug that garbled names containing out-of-locale characters (e.g., accented chars)
Connect With Us