sendObject / onObjectReceived in flash cs3

Need help with SmartFoxServer? You didn't find an answer in our documentation? Please, post your questions here!

Moderators: Lapo, Bax

Post Reply
don
Posts: 2
Joined: 07 Jun 2007, 17:18
Contact:

sendObject / onObjectReceived in flash cs3

Post by don »

I'm not getting any response with the sendObject method, though it may be the onObjectReceived method that isn't being triggered. I've read through the forums for people having similar problems and I can verify that I've already joined a room, and that the login, joining, roomlist, and connection have all happened in another frame, not the current frame.

for debugging I've also sent a public message along with my object, and this works handsomely. I've also checked the server administrator for data-in, I know that hitting refresh on the server-admin will increase your data-input, but it looks like the object is definitely coming in as well.

I'm not using the .swc, because I couldn't get that to install correctly. Instead I'm using the free download for smartfoxserver pro and the as3 api that lapo posted at http://forums.smartfoxserver.com/viewtopic.php?t=1424

Any help or insight would be GREATLY appreciated. Thank you.

/*the classes have been imported on frame1, and all the connections have been made on that frame as well. */

smartfox.addEventListener(SFSEvent.onAdminMessage, onAdminMessage);
smartfox.addEventListener(SFSEvent.onObjectReceived, onObj);
smartfox.addEventListener(SFSEvent.onPublicMessage, onPublicMessage);

box_mc.addEventListener(MouseEvent.MOUSE_DOWN, onMDown);
box_mc.addEventListener(MouseEvent.MOUSE_UP, onMUp);
box_mc.addEventListener(Event.ENTER_FRAME, onEnter);


function onAdminMessage (e:SFSEvent) {
admin_txt.text = e.params.message;
};


function onObj (e:SFSEvent):void {
trace ('something here!');
trace (e.params);
//server_txt.text = e.params.obj.px;
//server_txt.text = (e.params.message);
};

function onPublicMessage (e:SFSEvent) {
server_txt.appendText(e.params.message)
};

function onEnter (e:Event) {

real_txt.text = box_mc.x.toString();

//server_txt.text = //
};

function onMDown (e:MouseEvent) {
var o:Object = {px:box_mc.x};
smartfox.sendObject(o);

smartfox.sendPublicMessage('don rules');
box_mc.startDrag(false);

};

function onMUp (e:MouseEvent) {
box_mc.stopDrag();
};

stop();
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

Are you expecting the object response in the same client that sent the object?
In such case the behavior is correct.
Let me know
Lapo
--
gotoAndPlay()
...addicted to flash games
don
Posts: 2
Joined: 07 Jun 2007, 17:18
Contact:

client object received

Post by don »

I actually started to break this out in to the actual project I'm working on, I figured maybe I made a small typo that I wouldn't make again, or that I could send the data as a public message, but create a class to serialize the data myself.

Now that i'm testing it with multiple clients I can see that the object received function is actually firing like it's supposed to, just not in the client that sent the object. I suppose that's probably best, but I think my mistake was in thinking that the object was sent to everybody like a publc message.

Anyways thanks for taking the time to look over my post, Lapo. I know what a pain in the ass it is to look at other people's code.
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

Yep, you're right the sendObject method is slightly different because usually the client who sends the data doesn't have to react to it.

On the other hand public messages are usually shown on all clients, that's why even the sender receives it.
Lapo
--
gotoAndPlay()
...addicted to flash games
Post Reply