Profilo di DexterC# Network library proje...FotoBlogElenchi Strumenti Guida

Blog


01 settembre

Stop listening!

 
From my previous post, I already tackled how the server can be configure and to start it services, when the lobby server started it service, it doesnt mean it can already accept incomming  client connection, I need to to call first _Server.AcceptorMngr.StartAccepting() to start the acceptor manager for listening to any new incomming client connecting to server.
 
Some will argue, that once the server service started, it should start accepting client connection immediately. So, why I still need to call _Server.AcceptorMngr.StartAccepting() manually to be able to start accepting client connection,  the reason is, in my implementation it is capable to Start and Stop listening for new incomming client connection anytime I wish,  I can call _Server.AcceptorMngr.StartAccepting()  and _Server.AcceptorMngr.StopAccepting() anytime anywhere within the scope namespace, once the server service started.
 
For instance, if Im going to create a multiplayer RTS game with maximum of 8 players playing on local area network, once all 8 players already been filled and joined the game and the session started, it doesnt make sense that the server still need to listen for new connection, since the game was designed for maximum of 8 players only, once the game started I can call _Server.AcceptorMngr.StopAccepting() without loosing connection to already connected clients and at the end of the game session, back to game creation menu I can start calling again _Server.AcceptorMngr.StartAccepting()  Coz other player may wish to leave the game session and for other players to join for the new game session, and yes, running a lobby server type over th internet is a different story.
 
 
Here's the code from the previous post, just adding on how to start listening for a new incomming client connection:
 
 
// Using  ZNC = ZGDK.Net.Core;
// Using  ZNE  = ZGDK.Net.Enum;
// Using  ZNH  = ZGDK.Net.Helper;
 

 //!>> 1). Creating lobby server new instance.
 //
 ZNC.LobbyServer _Server = new ZNC.LobbyServer();
  
//!>>  2). Preparing server network configuration
//
ZNC.ServerConfig m_ServerConfig = new ZNC.ServerConfig();  m_ServerConfig.SetDefault();
//  
m_ServerConfig.Connection          = ZNE.ConnectionType.LAN;
m_ServerConfig.IPVersion            = ZNE.IPVersion.IPv4;
m_ServerConfig.Protocol              = ZNE.Protocol.UDP;
m_ServerConfig.SocketType         = ZNE.SocketType.Berkely; 
m_ServerConfig.IPAddress           = ZNH.GetMachineLocalIP();  
m_ServerConfig.ServerPort          = 60055;
//
m_ServerConfig.CasterPort           = 60057;
m_ServerConfig.CasterType          = ZNE.CasterType.Multicast;
m_ServerConfig.CasterGroup        = ZNE.CasterGroup.IPv4_WORKGROUP;
//
m_ServerConfig.AcceptorMode      = ZNE.SAcceptorMode.Thread;
m_ServerConfig.ReceiverMode      = ZNE.SReceiverMode.UdpThreadReceiver;
m_ServerConfig.SenderMode        = ZNE.SenderMode.Asynchronous;
//
m_ServerConfig.ApplicationName  = "Mech Rider-Z Alpha Rel. 0.002";
m_ServerConfig.LobbyName         = "Dexter Channel";
 

//!>>  3). Start lobby server service with custom network configuration.
//
 _Server.StartLobbyService( m_ServerConfig );
 
//!>>  4). Start accepting client connection.
//
 _Server.AcceptorMngr.StartAccepting();
 
 
 
Lobby server acceptor manager:
AcceptorMngr
 
 
I already discuss how to start and configure the lobby server service, and now how to start and stop listening for client connection, my next post will be on how the clients can automatically detect created game session or server within the local subnet and what kind of access I can grant to connecting client.
 
 Wink Hmmm, this blog of mine starting to look a tutorial on how to use Z-Communicator, than a work and process development blog.
 
NOTE: Blog contents may be slightly modified from time to time to comply with library's latest revision for future referencing.

Commenti

Attendere...
Il commento immesso è troppo lungo. Immetti un commento più breve.
Immissione non effettuata. Riprova.
Impossibile aggiungere il commento al momento. Riprova più tardi.
Per aggiungere un commento è necessaria l'autorizzazione di un genitore. Chiedi autorizzazione
I tuoi genitori hanno disattivato i commenti.
Impossibile eliminare il commento al momento. Riprova più tardi.
Hai raggiunto il numero massimo di commenti pubblicabili giornalmente. Riprova tra 24 ore.
Impossibile lasciare commenti. La funzionalità è stata disattivata perché i sistemi hanno rilevato una possibile attività di spamming dal tuo account. Se ritieni che il tuo account è stato disattivato per errore, contatta il supporto tecnico di Windows Live.
Esegui il seguente controllo di protezione per completare la pubblicazione del commento.
I caratteri digitati nel controllo di protezione devono corrispondere ai caratteri dell'immagine o della riproduzione audio.

Per aggiungere un commento, accedi con il tuo Windows Live ID (se utilizzi Hotmail, Messenger o Xbox LIVE possiedi già un Windows Live ID). Accedi


Non hai ancora un Windows Live ID? Registrati

Riferimenti

L'URL di riferimento per questo intervento è:
http://dexterz.spaces.live.com/blog/cns!9E6C0341ABD0C595!235.trak
Blog che fanno riferimento a questo intervento
  • Nessuno