Page 1 of 1

extension to get users info

Posted: 12 Oct 2010, 22:16
by gsources75
Ok I know that there are tutorial for DataBase Extension but i don't understand..... sorry

OK i 'm developing a multi-rooms chat, the users is recorded in a Sql server database.

i have this code in config.xml

Code: Select all

<DatabaseManager active="true">

	<Driver>org.gjt.mm.mysql.Driver</Driver>
	<ConnectionString>jdbc:mysql://192.168.0.15:3306/sfsTest</ConnectionString>
	<UserName>myUserName</UserName>
	<Password>myPassword</Password>

	<TestSQL><![CDATA[SELECT COUNT(*) FROM users]]></TestSQL>

	<MaxActive>10</MaxActive>
	<MaxIdle>10</MaxIdle>


	<OnExhaustedPool>fail</OnExhaustedPool>
	<BlockTime>5000</BlockTime> 

</DatabaseManager>

Ok and after ?

I don't understand i can get all info of an user when smatfoxserver send all client.

I use this code to get all users in activeRoom

Code: Select all

	public function getUserRoom() : Array {
			var room : Room = smartFox.getRoom(smartFox.activeRoomId);
			var user_in_room : Array = room.getUserList();
			var all_users : Array = new Array();

			for (var u:String in user_in_room) {
				var user_fox:User=  user_in_room[u];
			
				all_users.push(user_fox);
			}

			return all_users;
		}
I want that inside SmartFox User class there are propieties such us avatar, age, and other info of complete profile of user logged

Posted: 12 Oct 2010, 23:08
by appels
in your extension you can build a database query to get all the info you need and put all the info into an object and send that to the client/clients.
to get all the users of a room :

Code: Select all

var zone = _server.getCurrentZone();
var userList = zone.getRoom(fromRoom).getAllUsers(); 
the 'fromRoom' is provided by the 'handleRequest' event.

Posted: 13 Oct 2010, 05:56
by gsources75
i don't understand that files i do must create...

Code: Select all

<DatabaseManager active="true"> 

   <Driver>org.gjt.mm.mysql.Driver</Driver> 
   <ConnectionString>jdbc:mysql://192.168.0.15:3306/sfsTest</ConnectionString> 
   <UserName>myUserName</UserName> 
   <Password>myPassword</Password> 

   <TestSQL><![CDATA[SELECT COUNT(*) FROM users]]></TestSQL> 

   <MaxActive>10</MaxActive> 
   <MaxIdle>10</MaxIdle> 


   <OnExhaustedPool>fail</OnExhaustedPool> 
   <BlockTime>5000</BlockTime> 

</DatabaseManager> 
this code in file config and after ?

Posted: 13 Oct 2010, 10:48
by appels
the databaseManager in the config xml is the config for smartfox to be able to access the database. In your extension you can just query the database.

Posted: 14 Oct 2010, 11:20
by gsources75
ok but i don't know how create extension and how get info in flash

Posted: 14 Oct 2010, 11:30
by appels
in the documentation, SFS Pro - Simple extension. It's all explained there.