INetworkSessionFactory.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Threading.Tasks;
  4. namespace Microsoft.Xna.Framework.Net
  5. {
  6. /// <summary>
  7. /// Factory abstraction for creating network sessions.
  8. /// Allows different networking backends (UDP, Steam, etc.) to be selected at runtime.
  9. /// </summary>
  10. public interface INetworkSessionFactory
  11. {
  12. /// <summary>
  13. /// Creates a new network session instance.
  14. /// </summary>
  15. /// <returns>A new INetworkSession instance.</returns>
  16. INetworkSession CreateSession();
  17. /// <summary>
  18. /// Finds available sessions for joining.
  19. /// </summary>
  20. /// <param name="sessionType">The type of session to search for.</param>
  21. /// <returns>A collection of available session information.</returns>
  22. Task<IEnumerable<SessionInfo>> FindSessionsAsync(NetworkSessionType sessionType);
  23. /// <summary>
  24. /// Gets the name/identifier of this networking backend.
  25. /// </summary>
  26. string BackendName { get; }
  27. }
  28. /// <summary>
  29. /// Information about a discoverable network session.
  30. /// </summary>
  31. public class SessionInfo
  32. {
  33. /// <summary>
  34. /// Gets or sets the unique identifier for this session.
  35. /// </summary>
  36. public string SessionId { get; set; }
  37. /// <summary>
  38. /// Gets or sets the address or identifier to use when joining.
  39. /// </summary>
  40. public string JoinAddress { get; set; }
  41. /// <summary>
  42. /// Gets or sets the name of the session host.
  43. /// </summary>
  44. public string HostName { get; set; }
  45. /// <summary>
  46. /// Gets or sets the current number of players in the session.
  47. /// </summary>
  48. public int CurrentPlayerCount { get; set; }
  49. /// <summary>
  50. /// Gets or sets the maximum number of players allowed.
  51. /// </summary>
  52. public int MaxPlayerCount { get; set; }
  53. /// <summary>
  54. /// Gets or sets whether the session requires a password to join.
  55. /// </summary>
  56. public bool IsPasswordProtected { get; set; }
  57. /// <summary>
  58. /// Gets or sets the session type.
  59. /// </summary>
  60. public NetworkSessionType SessionType { get; set; }
  61. }
  62. }