Author: remi
Date: 2009-03-12 22:01:56 +0100 (Thu, 12 Mar 2009)
New Revision: 4031
Modified:
software_suite_v2/tuxware/pytuxisalive/branches/0.3.0/src/tuxisalive/api/base/ApiBaseServer.py
Log:
* added a method to change server address.
>>> tux.server.changeServer('x.x.x.x', 270)
Modified:
software_suite_v2/tuxware/pytuxisalive/branches/0.3.0/src/tuxisalive/api/base/ApiBaseServer.py
===================================================================
---
software_suite_v2/tuxware/pytuxisalive/branches/0.3.0/src/tuxisalive/api/base/ApiBaseServer.py
2009-03-12 20:14:48 UTC (rev 4030)
+++
software_suite_v2/tuxware/pytuxisalive/branches/0.3.0/src/tuxisalive/api/base/ApiBaseServer.py
2009-03-12 21:01:56 UTC (rev 4031)
@@ -45,13 +45,13 @@
self.__port = port
self.__cmdUrlMutex = threading.Lock()
# Client field
- self.__clientName = None
+ self.__clientName = "MyName"
self.__clientPasswd = None
self.__clientId = "0"
self.__cmdUrl = "0/"
self.__clientLevel = CLIENT_LEVEL_FREE
# Sender field
- self.__sender = HttpRequester()
+ self.__sender = HttpRequester(self.__host, self.__port)
# Connection field
self.__conn = None
# Syndicated events list
@@ -286,6 +286,26 @@
return True
#
--------------------------------------------------------------------------
+ # Change the target server address.
+ #
--------------------------------------------------------------------------
+ def changeServer(self, host, port = 270):
+ """Change the target server address.
+ @host: Host address of the target server.
+ @port: Port of the target server.
+ """
+ autoConn = False
+ if self.__conn != None:
+ if self.__conn.getAutoConnected():
+ autoConn = True
+ self.__conn.disconnect()
+ time.sleep(1.0)
+ self.__host = host
+ self.__port = port
+ self.__sender.setServerAddress(self.__host, self.__port)
+ if autoConn:
+ self.autoConnect(self.__clientLevel, self.__clientName)
+
+ #
--------------------------------------------------------------------------
# Start the automatic connection/reconnection loop with the server.
#
--------------------------------------------------------------------------
def autoConnect(self, level, name, passwd = ""):
------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn