Using db connection of the zone level in the room level.
-
yuvallahav
- Posts: 247
- Joined: 07 Oct 2008, 13:03
- Location: Rome, Italy
- Contact:
Using db connection of the zone level in the room level.
Hello.
Can I use a connection to a db I have created on the zone level inside a dynamically created room, and if so, how?
Thanks.
Yuval.
Can I use a connection to a db I have created on the zone level inside a dynamically created room, and if so, how?
Thanks.
Yuval.
-
Bosskafett
- Posts: 41
- Joined: 24 Jan 2012, 00:04
db
I suppose you blend db zone with your wanted zone.

if(_global.is_rocketsnail == 1){
mc.snail._visible = true;
smartfox.setUserVariables({snl:1, init:false})
}
The Re-creator of Old Games ;D
mc.snail._visible = true;
smartfox.setUserVariables({snl:1, init:false})
}
The Re-creator of Old Games ;D
-
yuvallahav
- Posts: 247
- Joined: 07 Oct 2008, 13:03
- Location: Rome, Italy
- Contact:
Yeah, this makes no sense to me, sorry, was that a joke or am I missing something?
Anyway, I really need an answer for this, do I need to create a new connection to the db in my room level extension, even if I already have an open connection to my db set up on my zone level? and if I can use that zone level connection, how would I go about doing so.
Anyone? please?
Yuval.
Anyway, I really need an answer for this, do I need to create a new connection to the db in my room level extension, even if I already have an open connection to my db set up on my zone level? and if I can use that zone level connection, how would I go about doing so.
Anyone? please?
Yuval.
-
Bosskafett
- Posts: 41
- Joined: 24 Jan 2012, 00:04
db
Ah yes this is possible, dig out dbExtentionAdvanced.as in sfsExtentions and include that in your zone. Also use the functions inside the db examples fla within your actionscript. Such as getData() would fetch from a database.
I hope this matches what you need,
Bosska
I hope this matches what you need,
Bosska
if(_global.is_rocketsnail == 1){
mc.snail._visible = true;
smartfox.setUserVariables({snl:1, init:false})
}
The Re-creator of Old Games ;D
mc.snail._visible = true;
smartfox.setUserVariables({snl:1, init:false})
}
The Re-creator of Old Games ;D
-
yuvallahav
- Posts: 247
- Joined: 07 Oct 2008, 13:03
- Location: Rome, Italy
- Contact:
I see you misunderstand my question.
I know how to use a db, I know how to set up a connection to it, I'm using my own db, not the built in db that comes with smartfox, there is no problem there.
My problem is that I need to use a db connection in a ROOM level, and not in a ZONE level, where my db connection was initially set up, the question is if there is a way for me to use the connection I set up in my zone level to read/write information with from my ROOM level (a room a create dynamically, and has it's own room level extension), or do I need to create a new connection instance also on the ROOM level.
Yuval.
I know how to use a db, I know how to set up a connection to it, I'm using my own db, not the built in db that comes with smartfox, there is no problem there.
My problem is that I need to use a db connection in a ROOM level, and not in a ZONE level, where my db connection was initially set up, the question is if there is a way for me to use the connection I set up in my zone level to read/write information with from my ROOM level (a room a create dynamically, and has it's own room level extension), or do I need to create a new connection instance also on the ROOM level.
Yuval.
-
yuvallahav
- Posts: 247
- Joined: 07 Oct 2008, 13:03
- Location: Rome, Italy
- Contact:
Hi.
My suggestion is to just have 1 connection in your Zone extension, which will be the only extension to be able to manage the db.
Despite not being much documented, in the extensions you have a method called handleInternalRequest, which is used for communicating between extensions. In this case, I suggest you to, in the Room extension, when you need to access the database, you call that handleInternalRequest method of the Zone extension, this way you only need 1 connection to the db.
For more information regarding the handleInternalRequest method, I suggest you to read this chapter of the docs, as well as the Server-Side Java Documentation, as the ActionScript one is a little outdated but AS Extensions support the same methods as Java ones.
My suggestion is to just have 1 connection in your Zone extension, which will be the only extension to be able to manage the db.
Despite not being much documented, in the extensions you have a method called handleInternalRequest, which is used for communicating between extensions. In this case, I suggest you to, in the Room extension, when you need to access the database, you call that handleInternalRequest method of the Zone extension, this way you only need 1 connection to the db.
For more information regarding the handleInternalRequest method, I suggest you to read this chapter of the docs, as well as the Server-Side Java Documentation, as the ActionScript one is a little outdated but AS Extensions support the same methods as Java ones.
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
-
yuvallahav
- Posts: 247
- Joined: 07 Oct 2008, 13:03
- Location: Rome, Italy
- Contact:
Hey there rjgtav, as always, you come to the rescue, I was talking from the start about the need to have only the one zone level connection to be used by all rooms I create in that zone, and I was looking for the way to "talk" to that zone level connection from the room extension, as you said, I didn't know I can invoke the zone's "handleInternalRequest" but I will try that, can I do the same from the zone to the room? I mean, use the "handleInternalRequest" if the room extension invoked by the zone with any replay from the db I will get there?
-
yuvallahav
- Posts: 247
- Joined: 07 Oct 2008, 13:03
- Location: Rome, Italy
- Contact:
Hehe thanks
.
Yes you can also invoke that method of the Room extension. But, in the handleInternalRequest() method of the Zone, if you at the end return an object, it will be returned to the Room Extension. To retrieve that object (from the room extension), you do something like:
And on the Zone Extension you have:
Yes you can also invoke that method of the Room extension. But, in the handleInternalRequest() method of the Zone, if you at the end return an object, it will be returned to the Room Extension. To retrieve that object (from the room extension), you do something like:
Code: Select all
var myObject = myZone.getExtension("extensionName").handleInternalRequest(myParams);Code: Select all
function handleInternalRequest(params){
//super complex logic here
var resObj = {};
resObj.dummyValue = 1;
return resObj;
}Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
-
yuvallahav
- Posts: 247
- Joined: 07 Oct 2008, 13:03
- Location: Rome, Italy
- Contact:
It looks like you're needing a rest
.
This method I'm talking about is the handleInternalRequest, which is specifically used to communicate between different extensions.
The handleInternalEvent is another method, used by the server, as you said, to handle internal events.
So no, handleInternalRequest method is totally independent form the handleInternalEvent, and everything will work correctly
This method I'm talking about is the handleInternalRequest, which is specifically used to communicate between different extensions.
The handleInternalEvent is another method, used by the server, as you said, to handle internal events.
So no, handleInternalRequest method is totally independent form the handleInternalEvent, and everything will work correctly
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
-
yuvallahav
- Posts: 247
- Joined: 07 Oct 2008, 13:03
- Location: Rome, Italy
- Contact:
I do need a rest, but the show must go on, and I must show my boss some results by, I hope, tomorrow morning, I'm trying this right now, stay tuned for an update in a minute.
Last edited by yuvallahav on 26 Jan 2012, 22:58, edited 1 time in total.
-
yuvallahav
- Posts: 247
- Joined: 07 Oct 2008, 13:03
- Location: Rome, Italy
- Contact:
Ahah no problem
Good night for you too, happy coding
Good night for you too, happy coding
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.