node.js smartfox protocol

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

langxangvn
Posts: 4
Joined: 04 Jul 2011, 00:52

node.js smartfox protocol

Postby langxangvn » 22 Aug 2011, 18:08

We have a node.js server to do some task. Now we need this server can talk with Smartfox server. So I think I need to know the protocal to talk with the Smartfox server. Can I have protocal document or source code of client API to learn something. Thank you.
User avatar
Lapo
Site Admin
Posts: 23025
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 23 Aug 2011, 07:41

Implementing all the protocol is not an easy task, it's a quite long and laborious work. We wouldn't recommend that.
Additionally ... I am not familiar with "node.js" ... but if the js stands for JavaScript you won't even be able to implement the protocol because SFS2X uses raw sockets (hence manipulates data at the byte level) which is not possible in JS.

If you need server-to-server communication stick to a more common and painless communication via HTTP. XML over HTTP is usually a good choice if you can choose your own protocol, otherwise regular HTTP posts will work too.

Final recommendation, you will need to reconfigure the server threading to allow scalability using "slow" HTTP calls on the back end.
For more details on this, please read here:
http://docs2x.smartfoxserver.com/Advanc ... hreadModel
Lapo
--
gotoAndPlay()
...addicted to flash games
langxangvn
Posts: 4
Joined: 04 Jul 2011, 00:52

Postby langxangvn » 24 Aug 2011, 18:01

Thank for reply. We know that the implementing not is easy task. We're running a social website that using http://nodejs.org/ to process some specific JSON requests from the users. Some of them access the mini version of site from the mobile and only small of numbers play Flash games on PC. But the users using mobile want to communicate with their friends in case their friends are playing the game, such as seeing online status or sending small text message.

We can use the DB and polling to forward request but try to look for a better solution. I think we'll try to create a bridge Java Server the make Node.js and SmartFox server communicate via the network.
User avatar
Lapo
Site Admin
Posts: 23025
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 25 Aug 2011, 16:20

Hmmm... the picture is not entirely clear to me.
You have a PC/Mac client in Flash that uses SmartFox and it also communicates with your Node backend. Am I right up to here?

If so... then you also have mobile clients who need to talk to SFS via the Node servers?

Can you explain this part a little bit more in detail?
What language/platform is Node.js developed with? Java? .Net?
We provide API for both technologies... maybe you could integrate those API in your code and talk to SFS directly
Lapo

--

gotoAndPlay()

...addicted to flash games
langxangvn
Posts: 4
Joined: 04 Jul 2011, 00:52

Postby langxangvn » 26 Aug 2011, 18:21

Yes, I'll explain clearly. Our server is implemented with Node.js. Node.js is an event-driven I/O server-side JavaScript environment based on V8. So it's in server-side. Client talk to Node.js server using socket.io, an HTTP socket can use any number of transportation methods with fallback from WebSockets, Flash Sockets to AJAX long polling ...

We don't have SFS Client API for Node.js therefor we can't talk to SFS server as client. In the difference scenario, SFS server easily send a request to Node.js server.

1. Can I override the method receive the client request of SFS server. If the request use our protocal, we handle it; otherwise SFS do?
2. If I create a server socket and listen in the difference port in SFS extension, is there anything wrong?
User avatar
Lapo
Site Admin
Posts: 23025
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 26 Aug 2011, 19:43

1. Can I override the method receive the client request of SFS server. If the request use our protocal, we handle it; otherwise SFS do?

No it's not possible. SFS2X does not support custom protocols

2. If I create a server socket and listen in the difference port in SFS extension, is there anything wrong?

This would make more sense.
You could write an extension that runs it's own socket listening to a custom TCP port. The node.js server would then communicate with this port using your preferred protocol. From there you could access the server API and implement your custom logic. Sounds like a good way to go :)
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 57 guests