Page 1 of 1

anyone knows of a simple way of sending messages?

Posted: 26 Sep 2011, 08:34
by foxter888
so far using unity 3d version 3.4.1 i'm able to connect to smartfox all from scratch now my main problem would be learning how to send messages between the server and the client, any way of doint it withouth a extension like a non authorative setup? the fps tutorial doesn't goes in detail very much and class serialization seems pretty hard to understand, i can't manage to make it so the client spawns the player and such.

this is just a simple asteroids game by the way. trying to learn smartfox somehow.

Posted: 26 Sep 2011, 09:30
by Bax
Please read the client API documentation. You have a number of Requests you can use to exchange messages among the clients, without the need of an Extension.

Posted: 26 Sep 2011, 11:13
by foxter888
i'm a bit confused, so far every one always guides you to the manual, but no help about it. i'm asking here because the manual doesn't seem easy enough to understand and the fps tutorials doesn't seems enough.

so far all i know is that you need isfsobjects to send messages back and forth and class serialization but seems kind of weird to get the concept. so that's why i asked about trying to find somehow a way of making it to where i shouldn't have to code the extension. so far the most i can get is connecting to the zone and the room and of course login but then after that how can i send my transform? spawn and etc? withouth having to make or try to figure out how to make a server world model and such. pretty much i mean that the fps tutorial seems to advanced for me. i'm trying to learn from the ground up. it's hard trying to see both the server code and the unity client code already.

Posted: 26 Sep 2011, 11:23
by foxter888
so far the only thing about sending messages are about things like chatting such as public message and the rest is sfsobjectswhich seems to need some kind of extension to work, even the api manual seems a bit empty like it doesn't show examples of usage or anything.

but still i'm just trying to figure out how to send messages back and for between the clients withouth having to use an extension and i don't only mean chatting i mean pretty much having it a non authorative set up at least for learning purposes

Posted: 26 Sep 2011, 14:26
by Bax
If you need to send custom data from one client to one or more others, you can use the ObjectMessageRequest from the Sfs2X.Requests namespace (see the API documentation here).
It doesn't require you to create a server-side Extension, or use class serialization (which, by the way, it is mainly used to send custom classes from the client to the server, not from the client to other clients).

Posted: 26 Sep 2011, 16:53
by foxter888
A question would be that once I send the object message to the server, how will the clients receive the data? Appreciate the help by the way.

Posted: 26 Sep 2011, 17:59
by foxter888
i saw the api about sending object messages, now i need some explanations on the usage, the api seems rather vague, it doesn't even shows the syntax on how to use it, and a question would be how the clients revieve the message?

Posted: 26 Sep 2011, 20:16
by foxter888
So far I can get the sintax right since the api for c# doesn't show the full example of how to implement it, I tried looking at the other apis but they are way different from each other, any way you can show me and example of the object message pleas

Posted: 27 Sep 2011, 05:29
by appels
post what you've got up till now and we'll try to help.

Posted: 27 Sep 2011, 05:30
by Bax
If you take some time to read the documentation at http://docs2x.smartfoxserver.com/ you will have a better understanding of how SFS works.
In particular mani Requests have their counterpart Event. So when you send an ObjectMessageRequest, the other clients will receive a SFSEvent of type OBJECT_MESSAGE. You have to listen to that event and take the appropriate actions.
About the SFSObject instance you have to use to pass data, read this document: http://docs2x.smartfoxserver.com/DevelopmentBasics/sfsobject-sfsarray
Even if examples show a different language, the usage is exactly the same on all the platforms.

Posted: 27 Sep 2011, 11:03
by foxter888
That's what I'm trying to explain, I can't get the counterpart working at all
I tried putting a debug on the counter part and i.don't get a return.

Posted: 28 Sep 2011, 07:18
by Bax
Are you sure you registered the event listener properly? Maybe you should show the piece of code where you register your listener for the OBJECT_MESSAGE event type.

Posted: 28 Sep 2011, 09:08
by foxter888
could you show me the sintax? For c# for both sending and returning?

Posted: 28 Sep 2011, 09:32
by Bax
You keep complaining about people telling you to read the doc, but it seems you are not doing it at all!

In the C# API doc, SFSEvent class, OBJECT_MESSAGE field (link to API doc), you have a clear example about handling the mentioned event.

Also, all the examples (starting from the most basic ones up to the FPS tutorial) show that all the requests - just like the ObjectMessageRequest (link to API doc) - must be sent using the SmartFox.send method (link to API doc).

After all it seems there is a reason why we keep telling you to READ THE DOC and check the basic examples provided in the SFS2X package!

Posted: 28 Sep 2011, 12:02
by foxter888
Have you ever look at the c# api yourself? Why you think I'm here, asking for help? When someone is going to get that fact?