WoWPad

What is it?

WoWPad is a simple proof of concept app that lets the user controll a WoW-client running on a Mac with a iPhone/iPod Touch.
Its main purpose was to see if the latency in a wifi network would be low enough to allow controlling games over wifi devices.

How does it work?

It's a simple client/server model. The server runs on your Mac where also the World of Warcraft client is running.

When the server process receives commands it parses them and sends appropriate commands to the WoW gameclient. This can be done either over AppleScript or over Apple Events. The AppleScript path is easy to implement but it's really slow. (Tough it's fast enough for World of Warcraft!). Apple Events on the other hand are faster but they take more work to implement and debug. As this is just a proof of concept I decided to use Applescript. (Applescript takes care of launching and bringing WoW to front - which you would have do yourself when using Apple Events)

The client app for the iPhone is really simple. It just looks on the local net for servers (with Bonjour) and connects to the first found server. On a button tap the app sends simple commands over a socket to the server. There is no sophisticated biderectional communication. The server just answers with an OK if the command was executed.

That's all.

Where is the source code?

You can get the source code from: http://github.com/jsz/WoWPad

More about AppleScript

  1. There is no magic in the AppleScript. It justs emulates key presses. WoW does not export any AppleScript stuff. We just let the SystemEvents object know that we want the WoW window to receive some keypresses.
  2. The AppleScript approach is really (really!) slow. Just sending Apple Events over the C-API is more than 5000 times faster.
  3. The AppleScript code is a mess. It's just a fast hack to get things running. A big script library is loaded on server startup into a string. This string contains some AppleScript functions to wrap common tasks (like pressing a key for a time, jumping (in wow), etc). When a command is sent to WoW this library string is copied and your command is appended to this copy and then sent to the Applescript API to execute this.
  4. Yep, it's a real mess. Don't do this if you ever want to release such an app into the public!

More about the network code

I wanted things get done so I used NSFileHandle for network data transfer. This is a hack and you should not do this in release applications. NSFileHandle data transfer is not really thread safe (thus the classes are named ServerThread, etc. but they're not multi threaded!) and was only intended to handle Distributed Objects data traffic. You should use real sockets for this stuff. There are great socket wrappers for Obj-C. (In retrospect I should have used them as debugging the NSFileHandle stuff did cost me more time than using BSD sockets.)

What to do better for a release app?

  1. Ditch AppleScript in favour of Apple Events.
  2. Implement networking with BSD sockets
  3. Make the app multi threaded
  4. Read the WoW's process memory to send feedback to the client. (Chatlog, char position, health, inventory, etc)

Hardware used

Server: iMac 24" early 2008 with 4gb of RAM.
Client: iPod touch 1st gen
Network: 54g wlan network with a linksys wrt54gl AP

License

See the LICENSE file. In short: It's a BSD license with attribution. (Means: If you derive from this work you have to mention my name)

I want to make this a commercial iPhone app.

Good luck with that. It's most likely that Activision Blizzard's legal departmen will send you a cease and desist letter. They did it already for non commercial iPhone apps that used their official web APIs. So I think they won't stop at a somewhat hacky approach to remote controll their game.

But if you like to gamble and need a developer to do all the work for you just contact me. (Nope, I won't work for free.)