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

Blog


02 settembre

Auto discovery

 
My last post disscuss how Z-Communicator can start listening to clients, connecting to server, but how can a client knows,
that a particular machine created a game session or started a server for other machine station to join in, ok, this topic covers
multiplayer games on LAN or local subnet only.
 
Whether using UDP or TCP protocol type,  my implemenation are capable of announcing a game session or server accross
the local subnet, the caster manager will take care on how the game session can be announce accross the local subnet. 
 
The caster type below is using ZNE.CasterType.Multicast  broadcasting mechanism than pure ZNE.CasterType.Broadcast
mechanism, Broadcast type is I believed already been deprecated and not supported in IPv6, ZNE.CasterType.Multicast on
the other hand  works fine on both IPv4 and IPv6 protocol version implementation.
 
 
 
// 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.TCP;
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.TcpThreadPoll;
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();
 
 
//!>>  5). Start caster manager service and start announcing the game every 300Ms.
//
_Server.CasterMngr.StartCasterService();
//
_Server.CasterMngr.StartAnnouncingGame( 300 );
 
 
Lobby server caster manager:
CasterMngr
 
 
Well, that's it, the server caster manager already been started and the game announce the server availability accross
the local subnet for clients to join in or connect and login to server, the following code shows how the client can
automatically discover the announcing server/s.
 
//!>>> Client end, searching for local game/s E.g.  "Mech Rider-Z Alpha Rel. 0.002" for 1Sec or 1000ms.
//
ZNC.LocalGames[] m_LocalGames = ZNH.SearchLocalGames(  "Mech Rider-Z Alpha Rel. 0.002",  1000  );
 
 
Local games members:
LocalGames
 
Once a client find local game/s, yes game/s, it can search all available same game tittle creating game
session or running as a server within the local area network,  it can retrieve every game server information
such as computer name, server port,  lobby description and it's local IP address to connect to.
 
 
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!243.trak
Blog che fanno riferimento a questo intervento
  • Nessuno