NetworkEvents.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. //
  2. // Copyright (c) 2008-2020 the Urho3D project.
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. #pragma once
  23. #include "../Core/Object.h"
  24. namespace Urho3D
  25. {
  26. /// Server connection established.
  27. URHO3D_EVENT(E_SERVERCONNECTED, ServerConnected)
  28. {
  29. }
  30. /// Server connection disconnected.
  31. URHO3D_EVENT(E_SERVERDISCONNECTED, ServerDisconnected)
  32. {
  33. }
  34. /// Server connection failed.
  35. URHO3D_EVENT(E_CONNECTFAILED, ConnectFailed)
  36. {
  37. }
  38. /// Server connection failed because its already connected or tries to connect already.
  39. URHO3D_EVENT(E_CONNECTIONINPROGRESS, ConnectionInProgress)
  40. {
  41. }
  42. /// New client connection established.
  43. URHO3D_EVENT(E_CLIENTCONNECTED, ClientConnected)
  44. {
  45. URHO3D_PARAM(P_CONNECTION, Connection); // Connection pointer
  46. }
  47. /// Client connection disconnected.
  48. URHO3D_EVENT(E_CLIENTDISCONNECTED, ClientDisconnected)
  49. {
  50. URHO3D_PARAM(P_CONNECTION, Connection); // Connection pointer
  51. }
  52. /// Client has sent identity: identity map is in the event data.
  53. URHO3D_EVENT(E_CLIENTIDENTITY, ClientIdentity)
  54. {
  55. URHO3D_PARAM(P_CONNECTION, Connection); // Connection pointer
  56. URHO3D_PARAM(P_ALLOW, Allow); // bool
  57. }
  58. /// Client has informed to have loaded the scene.
  59. URHO3D_EVENT(E_CLIENTSCENELOADED, ClientSceneLoaded)
  60. {
  61. URHO3D_PARAM(P_CONNECTION, Connection); // Connection pointer
  62. }
  63. /// Unhandled network message received.
  64. URHO3D_EVENT(E_NETWORKMESSAGE, NetworkMessage)
  65. {
  66. URHO3D_PARAM(P_CONNECTION, Connection); // Connection pointer
  67. URHO3D_PARAM(P_MESSAGEID, MessageID); // int
  68. URHO3D_PARAM(P_DATA, Data); // Buffer
  69. }
  70. /// About to send network update on the client or server.
  71. URHO3D_EVENT(E_NETWORKUPDATE, NetworkUpdate)
  72. {
  73. }
  74. /// Network update has been sent on the client or server.
  75. URHO3D_EVENT(E_NETWORKUPDATESENT, NetworkUpdateSent)
  76. {
  77. }
  78. /// Scene load failed, either due to file not found or checksum error.
  79. URHO3D_EVENT(E_NETWORKSCENELOADFAILED, NetworkSceneLoadFailed)
  80. {
  81. URHO3D_PARAM(P_CONNECTION, Connection); // Connection pointer
  82. }
  83. /// Remote event: adds Connection parameter to the event data.
  84. URHO3D_EVENT(E_REMOTEEVENTDATA, RemoteEventData)
  85. {
  86. URHO3D_PARAM(P_CONNECTION, Connection); // Connection pointer
  87. }
  88. /// Server refuses client connection because of the ban.
  89. URHO3D_EVENT(E_NETWORKBANNED, NetworkBanned)
  90. {
  91. }
  92. /// Server refuses connection because of invalid password.
  93. URHO3D_EVENT(E_NETWORKINVALIDPASSWORD, NetworkInvalidPassword)
  94. {
  95. }
  96. /// When LAN discovery found hosted server.
  97. URHO3D_EVENT(E_NETWORKHOSTDISCOVERED, NetworkHostDiscovered)
  98. {
  99. URHO3D_PARAM(P_ADDRESS, Address); // String
  100. URHO3D_PARAM(P_PORT, Port); // int
  101. URHO3D_PARAM(P_BEACON, Beacon); // VariantMap
  102. }
  103. /// NAT punchtrough succeeds.
  104. URHO3D_EVENT(E_NETWORKNATPUNCHTROUGHSUCCEEDED, NetworkNatPunchtroughSucceeded)
  105. {
  106. URHO3D_PARAM(P_ADDRESS, Address); // String
  107. URHO3D_PARAM(P_PORT, Port); // int
  108. }
  109. /// NAT punchtrough fails.
  110. URHO3D_EVENT(E_NETWORKNATPUNCHTROUGHFAILED, NetworkNatPunchtroughFailed)
  111. {
  112. URHO3D_PARAM(P_ADDRESS, Address); // String
  113. URHO3D_PARAM(P_PORT, Port); // int
  114. }
  115. /// Connecting to NAT master server failed.
  116. URHO3D_EVENT(E_NATMASTERCONNECTIONFAILED, NetworkNatMasterConnectionFailed)
  117. {
  118. }
  119. /// Connecting to NAT master server succeeded.
  120. URHO3D_EVENT(E_NATMASTERCONNECTIONSUCCEEDED, NetworkNatMasterConnectionSucceeded)
  121. {
  122. }
  123. /// Disconnected from NAT master server.
  124. URHO3D_EVENT(E_NATMASTERDISCONNECTED, NetworkNatMasterDisconnected)
  125. {
  126. }
  127. }