Can someone show me the full sintax of a object message?

Post here your questions about the Unity / .Net / Mono / Windows 8 / Windows Phone 8 API for SFS2X

Moderators: Lapo, Bax

foxter888
Posts: 78
Joined: 10 Apr 2011, 05:52
Location: united states

Can someone show me the full sintax of a object message?

Postby foxter888 » 28 Sep 2011, 15:42

The c# api only shows the name of the method, I'm tired of asking for help and people never look at the api I'm seeing, they just tell me to look at it again?
get to work you slacker!!!
User avatar
Bax
Site Admin
Posts: 4522
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 29 Sep 2011, 06:52

Code: Select all

ISFSObject parameters = SFSObject.NewInstance();
parameters.putUtfString("myParam1", "foxter888");
parameters.putInt("myParam2", 888);

smartFox.Send( new ObjectMessageRequest(parameters) );
Paolo Bax
The SmartFoxServer Team
foxter888
Posts: 78
Joined: 10 Apr 2011, 05:52
Location: united states

Postby foxter888 » 29 Sep 2011, 08:58

that's right that's on the api, but what about the return? About receiving it? That's the main problem that's not on the api
get to work you slacker!!!
User avatar
Bax
Site Admin
Posts: 4522
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 29 Sep 2011, 10:29

This must be a candid camera... :shock:
In this post I pointed you to to exact API doc page containing an example... as this doesn't seem to be enough, I'll copy and paste the code snippet here:

Code: Select all

void someInitMethod()
{
    //....
    smartFox.AddEventListener(SFSEvent.OBJECT_MESSAGE, OnObjectMessage);
    //....
}

void OnObjectMessage(BaseEvent evt)
{
    ISFSObject obj = (SFSObject)evt.Params["message"];
   
    // dumps the data object
    Console.WriteLine("Received data: " + obj.GetDump());
}


(code snippet taken from this page of the C# API doc)
Paolo Bax
The SmartFoxServer Team
foxter888
Posts: 78
Joined: 10 Apr 2011, 05:52
Location: united states

Postby foxter888 » 29 Sep 2011, 12:13

I think that it was my browser that never showed the page correctly, I got that same syntax from the action script api, I write that like on a script to try to instantiate my player but it, never worked yet, I did a debug and I do get the sending but nothing on the return. I tried using something like put class and then get class, so I'm guessing out will only work with simple data, for example I cant use the unity engine game object to try to send it telling it to spawn. So, my guess would be if I use the object message just to send my position, how will the other client see it? I can figure out so I could spawn the playeyers on each clients by using the object message. Thanks for the help by the way. The fps tutorial its complicated for me to understand because of the authorative setup of it. I think I need to know how to get it to be non authorative in order to learn. Anyway you could explain me fully the object message? For example is I call the function that adds the event listener and do the .send method. Will the client automatically get it? Am I just sending the wrong info?
I don't know how much knowledge you might have using the unity engine but for example I'm trying to send variables that are not listed by smartfox, but so far I could work out the putclass method
get to work you slacker!!!
User avatar
Bax
Site Admin
Posts: 4522
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 03 Oct 2011, 07:04

This document describes the class serialization:
http://docs2x.smartfoxserver.com/AdvancedTopics/class-serialization
This is not a simple topic, so maybe you should start by sending basic data like integers, strings, booleans.
Paolo Bax
The SmartFoxServer Team
foxter888
Posts: 78
Joined: 10 Apr 2011, 05:52
Location: united states

Postby foxter888 » 03 Oct 2011, 09:08

I been having a hard time using smartfox, for example even if the server is on the admin tool won't load, I'm having troubles understanding the extension responses, I was trying to have it non authorative since sending collisions was weird, for now ask I can do I wait for some more video tuts to come out, I'm sorry for all the troubles I'm a hard learner
get to work you slacker!!!
foxter888
Posts: 78
Joined: 10 Apr 2011, 05:52
Location: united states

Postby foxter888 » 13 Oct 2011, 17:34

Hi I'm having a hard time trying to send at least a simple variable, my question would be where to start from? The fps tutorial I'm able to follow but its seems complicated since its using class serialization, and how would I go about debbugin a extension? Im trying to learn how to do trace. In able to install the extension.

And for some reason even using the correct syntax for object message it seems to not return. Pretty much the callback never gets fired of
get to work you slacker!!!
appels
Posts: 464
Joined: 28 Jul 2010, 02:12
Contact:

Postby appels » 14 Oct 2011, 01:31

foxter888 wrote:its seems complicated since its using class serialization


Nope, it has a 'world model' that is used.
There are 2 ways to attack it :
1. rip out all thats not needed, try and endup with only connecting and spawning. Thats already a big part of the model.

2. follow the path in the code that a client follows for each task.
example:
client sends a spawn request.
spawn request gets redirected from the roomextension to the spawnhandler.
from there it checks if the player is a new player or if it simply needs to be respawned. When checking in the model, it will check if the player exists or not, and if it doesn't it will create one, update some lists and execute some functions and then eventualy send the response back to all players.
Try and draw out the path a client follows through the code and you will see much more clear.

Return to “SFS2X C# API”

Who is online

Users browsing this forum: No registered users and 4 guests