UDPProvider.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using IFramework.Custom;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. public class UDPProvider : MonoBehaviour
  6. {
  7. public enum ProviderType
  8. {
  9. UDPClient,
  10. UDPServer,
  11. }
  12. //private UDPClientProvider clientProvider;
  13. //private UDPServerProvider serverProvider;
  14. public ProviderType providerType;
  15. public int port = 16898;
  16. private string ip = "127.0.0.1";
  17. void Start()
  18. {
  19. Init();
  20. }
  21. private void Init()
  22. {
  23. switch(providerType)
  24. {
  25. case ProviderType.UDPClient:
  26. //clientProvider = new UDPClientProvider();
  27. //clientProvider.Connect(ip, port);
  28. break;
  29. case ProviderType.UDPServer:
  30. //serverProvider = new UDPServerProvider();
  31. //serverProvider.StartServer(port);
  32. break;
  33. default:
  34. break;
  35. }
  36. }
  37. private void OnDestroy()
  38. {
  39. //serverProvider?.Dispose();
  40. //clientProvider?.Dispose();
  41. }
  42. }