Multi User Communication Gadget API


Multi User Communication gadget API is a set of functions designed for Google Personalized Homepage that manages communication between gadgets from different users. This communication can be used by gadgets to play games or interact in any way with other users. The example gadget is the Tic Tac Toe game.

How it works

Messages sent between users are sent to a server that stores them. Gadgets check periodically if there’s a new messsage for them. This communication works even if the users are not connected at the same time to their igoogle page. You can create any turn-based application or game and store the status in user preferences. Messages sent while users are not connected will be received when they reconnect to igoogle page.

When a gadget sends a message it is sent to a server that stores it in a database. When a gadget checks if there’s any message it connects to the same server.

The messages server stores the messages for at least four weeks. If the user reconnects to the igoogle page before 4 weeks since the last time he will receive all the messages, but if the user doesn’t connect for longer that 4 weeks some messages could be lost.

How to program a gadget

This is part of the code of the Tic Tac Toe example. You can find the full code here. The resalted code are mandatory elements needed in the gadget.

<?xml version="1.0" encoding="UTF-8" ?> 
	<ModulePrefs title="Tic Tac Toe"
		author="Jorge Alvaro Rey" 
		author_location="Madrid, Spain" />
	<UserPref name="moduleId" datatype="hidden" default_value="" />
	<UserPref name="fromId" datatype="string" default_value="0_0" /> 
	<-- Game preferences -->
	<UserPref name="gameStatus" datatype="hidden" default_value="         " />
	<UserPref name="opponentModuleId" datatype="hidden" default_value="" />
	<UserPref name="turn" datatype="hidden" default_value="0" />
	<Content type="html"><CDATA[
		<!-- Multi User Communication Gadget Functions -->
		<script src="" type="text/javascript"></script> 
		function receiveMessage(sender, recipient, msg)
			// This is the function that will be called when a message arrives
		function play()
			// This method is used to send a message
			//	the first parameter is the module id of the recipient
			//	The second parameter is the message to send 
			// Note: This method can throw an Error if the message can't be sent. You should use it inside a try/catch block
			sendMessage(opponentModuleId, "START"); 
		// Initialize communication:
		//	the first parameter is the id to receive messages
		//	the second parameter is the function that will be called when a message arrives
		init(getModuleId(), receiveMessage); 

Available games

We will list here all the gadgets that use Multi User Communication Gadget API.

Tic Tac Toe gadget:

Hexaegon gadget:
Web: based in blog.txt theme by Scott Allan Wallick modified by montera34