When two servers.....

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

Moderators: Lapo, Bax

blindme
Posts: 7
Joined: 22 Nov 2013, 01:04

When two servers.....

Postby blindme » 10 Dec 2013, 00:52

hi^^.

I built a server as follows:

--------------------------------------------------------------------------------
client---load balancer --- real server 1 (smartfox 2x) ---- DB
             \               /
              \              /
            real server 2 (smartfox 2x)
--------------------------------------------------------------------------------

if user1 is in real server 1 and user2 is in real server 2, user1 can recognize ? whether user2 is in online or not.?

is there any service provided by smartfox 2x?

thanks for answer. :lol:
User avatar
Lapo
Site Admin
Posts: 21726
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: When two servers.....

Postby Lapo » 10 Dec 2013, 09:01

Hi,
out of the box no. But for example you have a database, so you can set a flag in your DB every time a user logs in and when they leave.
This way you can always know who's online and who isn't.

Hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games
grhwood
Posts: 116
Joined: 15 Mar 2011, 04:43

Re: When two servers.....

Postby grhwood » 10 Dec 2013, 18:54

Just curiously, what is your load balancer ?
blindme
Posts: 7
Joined: 22 Nov 2013, 01:04

Re: When two servers.....

Postby blindme » 11 Dec 2013, 02:21

thanks Lapo :lol:

I implemented a online recognition system

I have a another question!

if the both user 1 and user 2 are online,
these two users can exchange message in real time?


hi grhwood

I used ipvsadm on CentOS
User avatar
Lapo
Site Admin
Posts: 21726
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: When two servers.....

Postby Lapo » 11 Dec 2013, 08:42

In order to do that the two servers must be able to communicate.
This can be implemented in several ways, for example JMS (Java Message Service)or a library like Hazelcast

Personally I would probably choose the latter as it's quite easy to use for distributed events. It uses the same concept of "topics" like JMS and allows any node in the system to listen for any of those topics. You can check this example: http://www.hazelcast.com/docs/3.0/manua ... 02s04.html
It is pretty straightforward.

Back to your question, User Gonzo on Server1 can send a message to User Piggy on Server2 like this:

Code: Select all

Gonzo ---> message ----> Server1 ----> (publish HazelCast topic) ----> Server 2 ----> Piggy

And viceversa. In other words Server1 will receive the message for Piggy. It will realize that Piggy is not a local User and will then send a notification to anyone else in the system by saying "Hey everybody, I have a message for Miss Piggy, please relay it to her". All Servers will receive the notification and the one with Piggy will pass the message to her.

Makes sense?
cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
blindme
Posts: 7
Joined: 22 Nov 2013, 01:04

Re: When two servers.....

Postby blindme » 12 Dec 2013, 01:44

sorry...I don't understand T-T

Smartfox server 2x is installed in server computer 1 and 2.

Do I need to install another server? in server1 and server2 for hazelcast?

Can i implement a hazelcast in Extension class of Smartfox server?

I think that client have two connection. Smartfox and another connection for hazelcast. Is right?
User avatar
Lapo
Site Admin
Posts: 21726
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: When two servers.....

Postby Lapo » 12 Dec 2013, 09:02

Hi,
no Server1 and Server2 are your two servers with SFS installed on. You don't need more server machines.

Can i implement a hazelcast in Extension class of Smartfox server?

Yes, exactly

I think that client have two connection. Smartfox and another connection for hazelcast. Is right?

Hazelcast uses peer-to-peer communication so it will automatically discover other instances in the same network. You just need to integrate it in your Extension, deploy the Extension on the two SmartFoxServer instances and they will be able to see each other and send events to one another.

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: Aldenea, DavinVicy, DerikFent, JerodSa, Kevengar, Ricardofef and 24 guests