UDPProxyCommon.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Copyright (c) 2014, Oculus VR, Inc.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under the BSD-style license found in the
  6. * LICENSE file in the root directory of this source tree. An additional grant
  7. * of patent rights can be found in the PATENTS file in the same directory.
  8. *
  9. */
  10. #ifndef __UDP_PROXY_COMMON_H
  11. #define __UDP_PROXY_COMMON_H
  12. // System flow:
  13. /*
  14. UDPProxyClient: End user
  15. UDPProxyServer: open server, to route messages from end users that can't connect to each other using UDPForwarder class.
  16. UDPProxyCoordinator: Server somewhere, connected to by RakNet, to maintain a list of UDPProxyServer
  17. UDPProxyServer
  18. On startup, log into UDPProxyCoordinator and register self
  19. UDPProxyClient
  20. Wish to open route to X
  21. Send message to UDPProxyCoordinator containing X, desired timeout
  22. Wait for success or failure
  23. UDPProxyCoordinator:
  24. * Get openRouteRequest
  25. If no servers registered, return failure
  26. Add entry to memory
  27. chooseBestUDPProxyServer() (overridable, chooses at random by default)
  28. Query this server to StartForwarding(). Return success or failure
  29. If failure, choose another server from the remaining list. If none remaining, return failure. Else return success.
  30. * Disconnect:
  31. If disconnected system is pending client on openRouteRequest, delete that request
  32. If disconnected system is UDPProxyServer, remove from list. For each pending client for this server, choose from remaining servers.
  33. * Login:
  34. Add to UDPProxyServer list, validating password if set
  35. */
  36. // Stored in the second byte after ID_UDP_PROXY_GENERAL
  37. // Otherwise MessageIdentifiers.h is too cluttered and will hit the limit on enumerations in a single byte
  38. enum UDPProxyMessages
  39. {
  40. ID_UDP_PROXY_FORWARDING_SUCCEEDED,
  41. ID_UDP_PROXY_FORWARDING_NOTIFICATION,
  42. ID_UDP_PROXY_NO_SERVERS_ONLINE,
  43. ID_UDP_PROXY_RECIPIENT_GUID_NOT_CONNECTED_TO_COORDINATOR,
  44. ID_UDP_PROXY_ALL_SERVERS_BUSY,
  45. ID_UDP_PROXY_IN_PROGRESS,
  46. ID_UDP_PROXY_FORWARDING_REQUEST_FROM_CLIENT_TO_COORDINATOR,
  47. ID_UDP_PROXY_PING_SERVERS_FROM_COORDINATOR_TO_CLIENT,
  48. ID_UDP_PROXY_PING_SERVERS_REPLY_FROM_CLIENT_TO_COORDINATOR,
  49. ID_UDP_PROXY_FORWARDING_REQUEST_FROM_COORDINATOR_TO_SERVER,
  50. ID_UDP_PROXY_FORWARDING_REPLY_FROM_SERVER_TO_COORDINATOR,
  51. ID_UDP_PROXY_LOGIN_REQUEST_FROM_SERVER_TO_COORDINATOR,
  52. ID_UDP_PROXY_LOGIN_SUCCESS_FROM_COORDINATOR_TO_SERVER,
  53. ID_UDP_PROXY_ALREADY_LOGGED_IN_FROM_COORDINATOR_TO_SERVER,
  54. ID_UDP_PROXY_NO_PASSWORD_SET_FROM_COORDINATOR_TO_SERVER,
  55. ID_UDP_PROXY_WRONG_PASSWORD_FROM_COORDINATOR_TO_SERVER
  56. };
  57. #define UDP_FORWARDER_MAXIMUM_TIMEOUT (60000 * 10)
  58. #endif
粤ICP备19079148号