• Content count

  • Joined

  • Last visited

Community Reputation

151 Neutral

About dburner

  • Rank
  1. I've thought about what you said and coded a bit further(implemented like 99% of the lobby functions) and decided I'l just use the threads from the async methods because the only locks I think I will need are those on the playersList in the NetRoom when adding or removing clients. Since joining and leaving rooms are not very frequent(I think) those locks shouldn't cause many problems. Parsing the messages so far take very little time so I guess I dont have to worry about blocking the async threads too much. If I will get in trouble I will change the methods of calling the parsing functions quite easy. I still got the OnTick methods but they are kinda useless now. Thanks for the answer hplus0603[img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
  2. Hi, I'm currently working on a 2D Racing online game. I'm working on this game only because I want to practice my networking skills and for the fun of it, so the game wont actually be published(well who knows I might end up posting it somewhere) or played intensively but I want to make a strong design that could theoretically hold around 150-200players mabye more. The game and server are written in C#. I am using async TCP sockets on both client and server components. So far I made the gamedesign like this: Client side:[list] [*]client connects to the server and sends his nickname (multiple clients may have the same nickname doesn't really matter) [*]the client can chat with all the players connected to the server [*]the client can join or create a game room (set room name, set the max players, track, password) [*]the owner of the game room can start the game [*]and then the racing happens [/list] Server side (the tricky part):[list] [*]a basic client gets data asynchronously and puts it into a message queue [*]made a base class named NetRoom for 3 different room types : UnnamedLobby, MainLobby, GameRoom [*]a room may contain more clients [*]a NetRoom has a OnTick method and a OnMessageReceived method called by the OnTick that retrives a complete message from a client [*]when a client connects it is added to the UnnamedLobby until the server receives the client name, then the client is moved in the MainLobby (and I think I am going to get rid of this Room because client sends the name just after it connects) [*]in the MainLobby the clients can create GameRooms [*]the GameRoom handles clock sync, actual race game data, etc. [/list] [b] Here is the question: [/b]how do I call each room's OnTick method? a) one thread, one loop parsing all rooms and calling their OnTick b) one thread for each room c) one thread, one loop parsing all rooms BUT the OnTick calls the OnMessageReceived using ThreadPool d) on the ReceiveCallback from the client class call OnDataReceived using ThreadPool Also if anyone thinks there is room for improvement please tell me. Some of this stuff isn't coded yet(only 2 days of coding). EDIT: A game room should normally hold 4-8 players. And I want my server to be able to handle 30 game rooms simultaneous. EDIT2: Added d)
  3. I think there is another simple option for your problem. You could use ThreadPool class to send the data. [CODE]ThreadPool.QueueUserWorkItem( s=> (_udpSendSocket.SendTo(buffer, broadcastQueue[i].Count(), 0, (EndPoint)_myClientsList[client]._clientUDPEndPoint));[/CODE] EDIT: And set the number of worker threads at about 20(mabye even 30).