From: <Blu...@us...> - 2009-12-18 10:37:14
|
Revision: 322 http://virtplayground.svn.sourceforge.net/virtplayground/?rev=322&view=rev Author: BlueWolf_ Date: 2009-12-18 10:37:06 +0000 (Fri, 18 Dec 2009) Log Message: ----------- Added a small howto on how to use the VirtualCore in your program Modified Paths: -------------- trunk/client/core/__init__.py Modified: trunk/client/core/__init__.py =================================================================== --- trunk/client/core/__init__.py 2009-12-16 20:26:33 UTC (rev 321) +++ trunk/client/core/__init__.py 2009-12-18 10:37:06 UTC (rev 322) @@ -1,8 +1,3 @@ -""" -This is the client core for Virtual Playground. -You can use this by importing Client and Callback -""" - ## This file is part of Virtual Playground ## Copyright (c) 2009 Jos Ratsma + Koen Koning @@ -20,6 +15,47 @@ ## along with this program; if not, write to the Free Software ## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +""" +If you want to build your own Virtual Playground client and are using Python, +you can import this core for ready-to-use functions for the client. The core +will do all the work for you. The only thing you have to do is to make the user +interface. + +An example on how to connect to the server (as far it has been made): +>>> from core import Client, Callback +>>> import sha + +The Client is the core. You need to create your own callback class, which should +inherit the functions of Callback. You get feedback from your callback-class. +>>> class callback(Callback): +... def connect(self): +... print "Connect!" +... def logged_in(self, username, uid, cid): + print "I'm logged in!" + +Because it inherits all the (empty) functions from Callback, you don't have to +create all the functions yourself. Also, in help(Callback) you see all possible +callbacks along with their description. + +The next thing is the config. See help(Client) for all the available +config-options. +>>> config = { +... "app_name": "My awesome application", +... "app_version": "2.0" +... } + +Start the core. +>>> client = Client(config, callback()) +>>> client.connect("my.host.com", 1234, "Username", \ +... sha.new("Password").hexdigest()) + +If you have the server online and your login is correct, it will print: +Connect! +I'm now logged in! + +Congratulation! You have just made your first connection to your server! +""" + import client, callback Client = client.Client Callback = callback.Callback This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |