Skip to content

Scripting with one identity

noahsug edited this page Dec 13, 2012 · 13 revisions

One identity is a feature of CIRC that allows multiple devices to use the same IRC connection. One device acts as a server and the other devices act as clients. When scripting was introduced to CIRC, several issues arose of how to integrate with one identity.

Questions to consider

  • Should scripts run on only the server device? On all devices? On the device it was installed on?
  • When a script is installed, should we install it on all devices? If yes, then...
    • Do we save scripts in sync storage? Or send over a socket connection?
    • If a client connects to a server and both have different scripts, do we try to install all scripts on both?
  • Should scripts save data to local storage or sync storage. If sync then...
    • When do we remove the storage? What if another device is using it?
  • Should scripts run on all devices simultaneously, only on the server device, or only on the currently active device?

Chosen solution

The solution that was decided upon is to save scripts to local storage, but allow scripts to save information to sync storage. When a script is uninstalled, it's sync storage is removed, even if another device with the same script installed may have been using it. Only the server device runs the script.

This solution was chosen because it is simple, but also allows scripts to communicate across devices through sync storage. We don't need to deal with sending scripts over a socket or keeping track of which script is installed on which device. Ideally scripts would be saved to sync storage, however this option was avoided because of the space limitation. See details here: http://developer.chrome.com/extensions/storage.html#property-sync.

When an event happens on a client, the client sends the event to the server, the server passes it to the scripts, and then the server broadcasts the event that the scripts return. This was chosen because it is important for scripts that use sync storage that only one instance of the script process the event. Running the events on the server means the user only has to install scripts on one device. The downside to this solution is that there is additional lag between sending input and seeing the result.

Clone this wiki locally