mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 19:10:32 +00:00
85 lines
3.0 KiB
Plaintext
85 lines
3.0 KiB
Plaintext
|
using System.Net;
|
||
|
using Mirror;
|
||
|
using Mirror.Discovery;
|
||
|
|
||
|
/*
|
||
|
Discovery Guide: https://mirror-networking.com/docs/Guides/NetworkDiscovery.html
|
||
|
Documentation: https://mirror-networking.com/docs/Components/NetworkDiscovery.html
|
||
|
API Reference: https://mirror-networking.com/docs/api/Mirror.Discovery.NetworkDiscovery.html
|
||
|
*/
|
||
|
|
||
|
public class DiscoveryRequest : MessageBase
|
||
|
{
|
||
|
// Add properties for whatever information you want sent by clients
|
||
|
// in their broadcast messages that servers will consume.
|
||
|
}
|
||
|
|
||
|
public class DiscoveryResponse : MessageBase
|
||
|
{
|
||
|
// Add properties for whatever information you want the server to return to
|
||
|
// clients for them to display or consume for establishing a connection.
|
||
|
}
|
||
|
|
||
|
public class #SCRIPTNAME# : NetworkDiscoveryBase<DiscoveryRequest, DiscoveryResponse>
|
||
|
{
|
||
|
#region Server
|
||
|
|
||
|
/// <summary>
|
||
|
/// Reply to the client to inform it of this server
|
||
|
/// </summary>
|
||
|
/// <remarks>
|
||
|
/// Override if you wish to ignore server requests based on
|
||
|
/// custom criteria such as language, full server game mode or difficulty
|
||
|
/// </remarks>
|
||
|
/// <param name="request">Request comming from client</param>
|
||
|
/// <param name="endpoint">Address of the client that sent the request</param>
|
||
|
protected override void ProcessClientRequest(DiscoveryRequest request, IPEndPoint endpoint)
|
||
|
{
|
||
|
base.ProcessClientRequest(request, endpoint);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// Process the request from a client
|
||
|
/// </summary>
|
||
|
/// <remarks>
|
||
|
/// Override if you wish to provide more information to the clients
|
||
|
/// such as the name of the host player
|
||
|
/// </remarks>
|
||
|
/// <param name="request">Request comming from client</param>
|
||
|
/// <param name="endpoint">Address of the client that sent the request</param>
|
||
|
/// <returns>A message containing information about this server</returns>
|
||
|
protected override DiscoveryResponse ProcessRequest(DiscoveryRequest request, IPEndPoint endpoint)
|
||
|
{
|
||
|
return new DiscoveryResponse();
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region Client
|
||
|
|
||
|
/// <summary>
|
||
|
/// Create a message that will be broadcasted on the network to discover servers
|
||
|
/// </summary>
|
||
|
/// <remarks>
|
||
|
/// Override if you wish to include additional data in the discovery message
|
||
|
/// such as desired game mode, language, difficulty, etc... </remarks>
|
||
|
/// <returns>An instance of ServerRequest with data to be broadcasted</returns>
|
||
|
protected override DiscoveryRequest GetRequest()
|
||
|
{
|
||
|
return new DiscoveryRequest();
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// Process the answer from a server
|
||
|
/// </summary>
|
||
|
/// <remarks>
|
||
|
/// A client receives a reply from a server, this method processes the
|
||
|
/// reply and raises an event
|
||
|
/// </remarks>
|
||
|
/// <param name="response">Response that came from the server</param>
|
||
|
/// <param name="endpoint">Address of the server that replied</param>
|
||
|
protected override void ProcessResponse(DiscoveryResponse response, IPEndPoint endpoint) { }
|
||
|
|
||
|
#endregion
|
||
|
}
|