AntiIdle

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

Moderators: Lapo, Bax

Post Reply
FunTime
Posts: 10
Joined: 02 Oct 2007, 20:32

AntiIdle

Post by FunTime »

I've been trying to make some anti-idle code but putting in a simple Ping/Pong event.

However, I'm very new to all of this, and for somereason the client never seems to get the ping event:
I got this set to run every minute, and gives no erros, but doesn't seem to send anything either, what am I doing wrong?

Also what is the r value for in the body tag?

Code: Select all

function AntiIdleFunction()
{
        var AntiIdleMsg = '<msg t="sys"><body action="ping" r="-1"><time>'
        AntiIdleMsg += getTimer()
        AntiIdleMsg += '</time></body></msg>'
        _server.sendGenericMessage(AntiIdleMsg, null, _server.getCurrentZone().getUserList())
//      trace("AntiIdle Msg Sent to zone " + _server.getCurrentZone().getName() + ": " + AntiIdleMsg);
}
[/code]
potmo
Posts: 154
Joined: 02 Feb 2007, 14:28
Location: Stockholm Sweden
Contact:

Post by potmo »

i guess its cos youre sending a 'sys' message (but thats just a guess). try sending to an extension instead.

Can you see if anything are sent? Or whats happening?

I would also say that its better that the server sends the ping and the client responds with the pong. I think its nice when the server is the one thats takes action and the client are very "thin" and just responds.
Nisse Bergman
Raketspel
FunTime
Posts: 10
Joined: 02 Oct 2007, 20:32

Post by FunTime »

what types of messages are there, I was just going by some example code to get sys, however, the client doesn't even seem to see it anyways, so I'm not really sure if that is the problem or not.
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

If you want to create a "keep-alive" type system you don't need necessarily need to send data from server to client.

The simplest way is that the client sends an Extension request every 1 minute or so, sending a very small packet of data. (use JSON or raw format)

The Extension will just discard that, but the server will update the client timeout counter and it won't kill the connection.
Lapo
--
gotoAndPlay()
...addicted to flash games
FunTime
Posts: 10
Joined: 02 Oct 2007, 20:32

Post by FunTime »

I suppose I could do that, but it still makes my wonder why my function doesn't work..

Heck, it doesn't give an error or anything, just for some reason the client just never seems to get the message.
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

Because you're trying to send a "ping" request marked as a "sys" type message, which the client does not recognize.
So it's being discarded.
Lapo
--
gotoAndPlay()
...addicted to flash games
FunTime
Posts: 10
Joined: 02 Oct 2007, 20:32

Post by FunTime »

OK, without being told what kind of message or action types I should be sending, or can send, I changed my function a bit:

Code: Select all

function AntiIdleFunction()
{
        var AntiIdleMsg = '<msg t="xt"><body action="xtRes" r="-1">'
        AntiIdleMsg +='<dataObj><var n=&apos;time&apos; t=&apos;s&apos;>' + getTimer() + '</var&gt<var n=&apos;_cmd&apos;t=&apos;s&apos;>ping</var></dataObj>'

        AntiIdleMsg +='</body></msg>'
        _server.sendGenericMessage(AntiIdleMsg, null, _server.getCurrentZone().getUserList())
        trace("AntiIdle Msg Sent to zone " + _server.getCurrentZone().getName() + ": " + AntiIdleMsg);
}

However, it still does not seem to work, and for the life of me I can not figure out why...some reason putting AES encryption in for the client and server for a custom log-in was MUCH easier. :(
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

:shock: :shock: :shock:
Question: why are you building the XML manually?? When you just need to use the _server.sendResponse() method?
:shock: :shock: :shock:
...some reason putting AES encryption in for the client and server for a custom log-in was MUCH easier.
:?:
It's not clear...
If you need an encrypted login system we already provide that out of the box, check the documentation. Chapter 8.9
Lapo
--
gotoAndPlay()
...addicted to flash games
FunTime
Posts: 10
Joined: 02 Oct 2007, 20:32

Post by FunTime »

I didn't use the _server.sendResponse() because I could not find a simple method of sending it to all users, where as it seemed really easy the other way. Plus no one is telling me what is wrong with my XML either.

As for the encrpytion, my server does not store plan text passwords, that being the only way your provided custom logings would of worked, so I needed something the server could decrypt in the end, and if AES style encryption is good enough for the goverment, then it's good enough for me too. :P
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

I didn't use the _server.sendResponse() because I could not find a simple method of sending it to all users, where as it seemed really easy the other way. Plus no one is telling me what is wrong with my XML either.
How about:
_server.sendResponse(responseObj, rId, null, room.getAllUsers())
:wink: :)
As for the encrpytion, my server does not store plan text passwords, that being the only way your provided custom logings would of worked,
The way you keep passwords in your DB is out of our reach :) You can keep them in whatever format you want, including AES or any other encryption technique.
Our provided solution for secure logins is independent from that and way simpler than using a full fledged encryption algorithm.
That would involve lots more complicated operations, and support on for the enc/dec system on the client side, and Flash is not too good with large numbers math (especially AS 2)
Lapo
--
gotoAndPlay()
...addicted to flash games
FunTime
Posts: 10
Joined: 02 Oct 2007, 20:32

Post by FunTime »

Code: Select all

_server.sendResponse(responseObj, rId, null, room.getAllUsers())
Would work good to send to all users in a room, but does not work for all users in a zone.

And all of the ways I could find to get all users in a zone does not seem to work with _server.sendResponse, something I found kind of odd, because I think there should be one.
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

Cycle all rooms in the zone and using the getAllUsers() method build a list of recipients.
Lapo
--
gotoAndPlay()
...addicted to flash games
Post Reply