As long as you have both Raspberry Pis connected to a WiFi router, then you can do it. I don't think you can just communicate between two WiFi devices without a router (that is, the router can receive/send all the signals, the Pis can only communicate with a router).
Here is a post on the raspberrypi forum that talks about that issue. They do mention about an AdHoc mode which I would imagine is what you're interested in. It's probably quite a bit of work to make it functional.
First I'd test with a router and make it work that way, then I'd look at making the AdHoc version if you're still interested...
As for the communication, SSH uses TCP, so any TCP or UDP sockets would be enough to communicate. It depends on whether you want to have encryption. If so, then using an HTTPS could be one of the simplest way (i.e. the encryption comes free to you). It's a bit heavier because of the rather large header, but it's a small price to pay for the mostly complete interface.
As CoderMike mentioned, there is also websockets. This is an extension of HTTP which is a permanent bi-directional connection.