_server.joinRoom hates me! :(

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

Sparticus
Posts: 217
Joined: 27 Feb 2006, 17:44
Location: Canada
Contact:

_server.joinRoom hates me! :(

Postby Sparticus » 01 Mar 2006, 22:26

I have been reading all the documentation on how to join a room from the server side. The following example tries to join a room called "Kitchen" (which does exists already)... the following code keeps failing saying :

Error in extension [ dbExtension.as ]: TypeError: Cannot call method "warning" of undefined (dbExtension.as#359) Line: -595 (MainLib line: 359)

Please help me! Thanx a bunch!


Code: Select all

function handleInternalEvent(evt)
{
   if (evt.name == "loginRequest")
        {

               // I removed some database queries and password check here... they work perfectly

               // Get what I think is the user id?  I traced it and it is empty??
               var u = evt["user"]
               var ok = _server.joinRoom([u],-1,false,"Kitchen")
        }

}
User avatar
Virusescu
Posts: 260
Joined: 07 Sep 2005, 09:36
Location: [RO]Bucharest
Contact:

Postby Virusescu » 02 Mar 2006, 13:02

You pass an array to the joinRoom method. In the docs it states that you should pass the userObject that you want to join a room.
I haven't tryed yet the Beta of SFS 1.4, but it seems to me preety obvious after taking a glance at the documentation.
User avatar
Virusescu
Posts: 260
Joined: 07 Sep 2005, 09:36
Location: [RO]Bucharest
Contact:

Postby Virusescu » 02 Mar 2006, 13:05

and BTW, you first need to issue an _server.loginUser(nick, pass, chan) command. If not, your user is identified by his comunication channel and hence your u variable is not a user object.

Acutally you don't even get an user.. so yep.. that is empty because the properties you recieve on the evt object for a loginRequest call are only the following
var nick = evt.nick
var pass = evt.pass
var chan = evt.chan
So .. there's no user.
User avatar
Lapo
Site Admin
Posts: 21588
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 02 Mar 2006, 14:27

yep,
Virusescu is right :)
Lapo
--
gotoAndPlay()
...addicted to flash games
Sparticus
Posts: 217
Joined: 27 Feb 2006, 17:44
Location: Canada
Contact:

Postby Sparticus » 02 Mar 2006, 15:26

Ok, I actually do use the _server.loginUser in that code (I removed it when I pasted it here to make the post shorter. This is what it do :


Code: Select all

_server.loginUser(nick, pass, chan)
var u = user.getUserId()
trace(u);
var ok = _server.joinRoom(u,"-1",false,"Kitchen")


which is obviously wrong... how do i get the "user object" I need after I log in the user?

P.S. I read the documentaton but there is a bug in it. The documentation has an example on how to use _server.loginUser() but actually doesn't even use it once....

(I am compiling a list of bugs I have found... and will release them all at once....)
User avatar
Lapo
Site Admin
Posts: 21588
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 02 Mar 2006, 15:41

Code: Select all

var ok = _server.joinRoom(u,"-1",false,"Kitchen")


I see two errors here

"-1" should be -1, a Number
"Kitchen" is wrong, you should pass the id of the room, not its name

hope it helps
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
Virusescu
Posts: 260
Joined: 07 Sep 2005, 09:36
Location: [RO]Bucharest
Contact:

Postby Virusescu » 02 Mar 2006, 16:30

I read the documentaton but there is a bug in it. The documentation has an example on how to use _server.loginUser() but actually doesn't even use it once...

That seems like a bug :roll:
Check this link to the loginRequest example.

Hope this helps
User avatar
Lapo
Site Admin
Posts: 21588
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 02 Mar 2006, 16:46

Example in the docs updated! :)
( clear your browser cache if it doesn't update )
Lapo

--

gotoAndPlay()

...addicted to flash games
Sparticus
Posts: 217
Joined: 27 Feb 2006, 17:44
Location: Canada
Contact:

Postby Sparticus » 02 Mar 2006, 17:06

Yes! I read over the updated docs and found the line of code I have been search for all day :

var u = _server.instance.getUserByChannel(chan)

I could never seem to find a way to get the user object.

thanx for the update :)
Sparticus
Posts: 217
Joined: 27 Feb 2006, 17:44
Location: Canada
Contact:

Postby Sparticus » 02 Mar 2006, 17:15

Hmm... I thought I had it... I must be so close....

I sucessfully log in ... then I issue this command

Code: Select all

var u = _server.instance.getUserByChannel(chan)
var ok = _server.joinRoom(u,-1,false,2)


it it says :

Error in extension [ dbExtension.as ]: TypeError: Cannot call method "warning" of undefined (dbExtension.as#359) Line: -595 (MainLib line: 359)

everything seems okay to me. I even did a u.getUserId() and traced it... it returned a postive number... so the getUserByChannel must be working...

Last question for today I promise! Thanx for any help you can give! :)
User avatar
Lapo
Site Admin
Posts: 21588
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 02 Mar 2006, 17:32

The problem is there's a little bug in the mainlib.as file.
Your joinRoom fails but that bug prevents the server from telling you what problem you have.

Quick fix:
open the mainlib.as from the lib/ folder

go to line 359 and substitute whatever you find with:
this.logger.warning(exception.toString())


This should fix the logging problem and you'd be able to see the error

let me know how it goes :)
Lapo

--

gotoAndPlay()

...addicted to flash games
Sparticus
Posts: 217
Joined: 27 Feb 2006, 17:44
Location: Canada
Contact:

Postby Sparticus » 02 Mar 2006, 17:54

omg something must be wrong with me. Nothing is working :(

I tried what you said... I opened mainLib and went to line 359 and repleaced :

this._logger.warning(exception.toString())

with

this.logger.warning(exception.toString())

now I completly shut down the server and tried to start it.... it won't start... at all. it does this :

Code: Select all

+------------------------------------------------------------+
+            SmartFoxServer - Multiuser Server               +
+                      version 1.4.0b3                       +
+                                                            +
+                                                            +
+     (c) 2005 gotoAndPlay() - www.smartfoxserver.com        +
+------------------------------------------------------------+

+----------------------[ System Info ]-----------------------+

System CPU(s): 2
VM Max memory: 66 MB

os.name: Windows XP
os.arch: x86
os.version: 5.1
java.version: 1.5.0_06
java.vendor: Sun Microsystems Inc.
java.vendor.url: http://java.sun.com/
java.vm.specification.version: 1.0
java.vm.version: 1.5.0_06-b05
java.vm.vendor: Sun Microsystems Inc.
java.vm.name: Java HotSpot(TM) Client VM

+--------------------[ Licence Loaded ]----------------------+

Licence Type: PRO
Licenced to : --== Free Demo Licence ==--
Max. Clients: 20


+---------------------[ Zones & Rooms ]----------------------+

        DB Manager Activated ( org.postgresql.Driver )
Zone: dbZone

        MainRoom            (id: 1, max: 10, pass:N)
        Kitchen             (id: 2, max: 10, pass:N)


and it sits there.... doesn't continue loading. Now if I go back into mainLib and put the underscore back into like 359... it the server still won't start.... as if I corrupted the file or something. I used flash 8 to edit the file the first time... then retried with wordpad... both didn't work.

I was able to get the server to start again only by overwriting mainLib with the original mainLib I downloaded.

what is wrong with me? lol
User avatar
Lapo
Site Admin
Posts: 21588
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 02 Mar 2006, 17:57

do not use Flash! It will convert the file to UTF-8 (with BOM) and the server will have problems parsing it.

Just redo the change using a texteditor like notepad, notepad++ or UltraEdit
Lapo

--

gotoAndPlay()

...addicted to flash games
Sparticus
Posts: 217
Joined: 27 Feb 2006, 17:44
Location: Canada
Contact:

Postby Sparticus » 02 Mar 2006, 18:06

Ok, downloaded notepad++ and made the change you suggested. The server started properly this time but when I tried the _server.joinRoom function it says :

11:11:23.812 - [ WARNING ] > InternalError: Can't find method it.gotoandplay.sma
rtfoxserver.extensions.ExtensionHelper.joinRoom(it.gotoandplay.smartfoxserver.da
ta.User,number,number,boolean,undefined,undefined,undefined). (dbExtension.as#34
6)
Sparticus
Posts: 217
Joined: 27 Feb 2006, 17:44
Location: Canada
Contact:

Postby Sparticus » 02 Mar 2006, 20:39

I just tried reinstalling everything.... re-edited all the files from scratch making sure that I used notepad++ for everything. I made the changes requested and it still give the same error message that I described in my previous post.

I am so lost.... I'm sure it's something simple I'm missing....

Anyone?

Return to “Server Side Extension Development”

Who is online

Users browsing this forum: No registered users and 15 guests