public void ServerUri2() { transport1.ServerUri().Returns(x => { throw new PlatformNotSupportedException(); }); transport2.ServerUri().Returns(new Uri("tcp4://myserver")); Assert.That(transport.ServerUri(), Is.EqualTo(new Uri("tcp4://myserver"))); }
/// <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>The message to be sent back to the client or null</returns> protected override ServerResponse ProcessRequest(ServerRequest request, IPEndPoint endpoint) { // In this case we don't do anything with the request // but other discovery implementations might want to use the data // in there, This way the client can ask for // specific game mode or something try { // this is an example reply message, return your own // to include whatever is relevant for your game return(new ServerResponse { serverId = ServerId, uri = transport.ServerUri() }); } catch (NotImplementedException) { logger.LogError($"Transport {transport} does not support network discovery"); throw; } }
public void ServerUri1() { transport1.ServerUri().Returns(new Uri("tcp4://myserver")); Assert.That(transport.ServerUri(), Is.EqualTo(new Uri("tcp4://myserver"))); }