Forum C# Need To Know ServerSide Code Concept

Need To Know ServerSide Code Concept

Postby kidkid » December 17th, 2010, 9:05 am

Hi, lasttime I has read somewhere that the server side code will be excute in many other server.
So If I have the code as below :

Code: Select all
public void TimeTick()
{
            Broadcast("NewEvent", param1,param2);
}


And currently, there are two room, room 1 in server 1, room 2 in server 2
Will this code broadcast "NewEvent" message to two room ?

Or I should join to 2 rooms and excute that above code ?

I also confuse the way PlayerIO do with server side code.
I currently "know" that
The server side code in dll will be copy to many server, and in each server it runs and create its room.

so if I want to collect how many users are playing, I should join to all of room and count it.

Is my know right ?

Thanks.
kidkid
 
Posts: 54
Joined: December 1st, 2010, 4:43 am

Re: Need To Know ServerSide Code Concept

Postby TobiasW » December 17th, 2010, 10:08 am

Hey,

every room will has its own instance of your Server, and they don't know of each other. So if you use "Broadcast", it only broadcasts to all players in the room.

Cheers,
Tobias
User avatar
TobiasW
 
Posts: 59
Joined: August 29th, 2010, 12:31 am

Re: Need To Know ServerSide Code Concept

Postby kidkid » December 17th, 2010, 11:57 am

So If I want to Broad Cast To All Rooms.
Could I do like that :
1. Create a webservice ( or something like that)
2. Use Get/Post to active it.
3. In this I call this function:

BroadcastAllRoom():
foreach(room in PlayerIO.listAllRoom)
{
ConnectRoom(room)
Broacast
LeaveRoom
}

Is it ok ? Anything cause problem ?

Thanks.
kidkid
 
Posts: 54
Joined: December 1st, 2010, 4:43 am

Re: Need To Know ServerSide Code Concept

Postby Oliver » December 17th, 2010, 12:11 pm

That's perfectly acceptable.
User avatar
Oliver
.IO
 
Posts: 1159
Joined: January 12th, 2010, 8:29 am

Re: Need To Know ServerSide Code Concept

Postby TobiasW » December 17th, 2010, 12:25 pm

There is a limit of 45 players per room though, so remember to only allow 44 regular players.

Also, your webservice could just stay in each room instead of joining/leaving in each time. Would make the response time faster and also solve the room limit problem.
User avatar
TobiasW
 
Posts: 59
Joined: August 29th, 2010, 12:31 am

Re: Need To Know ServerSide Code Concept

Postby Benjaminsen » December 17th, 2010, 12:26 pm

I have a similar use case whenever I release a new version of Everybody Edits. Basically what I want to do is get everybody to update their clients.

However instead of having a service that connects to all the rooms I simply just change a version number in BigDB.
The servers loads this entry in BigDB every 30 secounds, if the servers version number is below the one in BigDB. The server broadcasts an "update message" and disconnects all clients.

A similar system could be used for something that needs to be broadcasted to everyone.
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark


Return to C#