com.py
changeset 1 2e65c867022c
parent 0 fb00185487d4
     1.1 --- a/com.py	Thu May 27 17:14:56 2010 +0200
     1.2 +++ b/com.py	Sun Jun 06 00:29:30 2010 +0200
     1.3 @@ -1,5 +1,11 @@
     1.4  import grid
     1.5  
     1.6 +commands = {}
     1.7 +
     1.8 +def help(socket, client):
     1.9 +	socket.sendto("\n".join([key + ": " + value[1] 
    1.10 +		for key, value in commands.iteritems()]) + "\n", client)
    1.11 +
    1.12  def createGrid(socket, client, (name,)):
    1.13  	grid.createGrid(name)
    1.14  	#print "grid %s created" % name
    1.15 @@ -36,10 +42,12 @@
    1.16  	grid = lookupGrid(socket, client, gridName)
    1.17  	if grid:
    1.18  		grid.addObserver(socket, client)
    1.19 +		socket.sendto("observer added: " + str(client) + "\n", client)
    1.20  		
    1.21 -commands = {"create grid": createGrid,
    1.22 -	"list grids": listGrids,
    1.23 -	"set cell": setCell,
    1.24 -	"list cells": listCells,
    1.25 -	"iterate": iterate,
    1.26 -	"add observer": addObserver}
    1.27 +commands = {"help": (help, "help"),
    1.28 +	"create grid": (createGrid, "creates grid"),
    1.29 +	"list grids": (listGrids, "lists all grids"),
    1.30 +	"set cell": (setCell, "sets the value of a cell"),
    1.31 +	"list cells": (listCells, "lists all cells of a grid"),
    1.32 +	"iterate": (iterate, "iterates"),
    1.33 +	"add observer": (addObserver, "adds an observer to a grid's events")}