PageRenderTime 45ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/Utilities/Networking/BasicMessageTypes.cs

#
C# | 44 lines | 9 code | 2 blank | 33 comment | 0 complexity | dde090ca5b2efdac4fd43760c7582ba9 MD5 | raw file
Possible License(s): Apache-2.0
  1. namespace Delta.Utilities.Networking
  2. {
  3. /// <summary>
  4. /// Basic message types. Used for unit tests and even for the LogServer.
  5. /// Please note that you need to implement this in the ClientData class
  6. /// that is being used by the BaseServer and Client you are using. It could
  7. /// be easier to create types dynamically like for BaseControl in Scenes,
  8. /// but performance is very important for network messages and this types
  9. /// are extremely compact (just 1 byte) and very fast and still easy enough
  10. /// to use and extend for all kinds of networking code.
  11. /// </summary>
  12. public enum BasicMessageTypes : byte
  13. {
  14. /// <summary>
  15. /// Connect message from the client to the server once we connected. This
  16. /// does not contain any data by default, but if you enable cryptography
  17. /// this contains the random seed value for all decryption (can be resent
  18. /// by the server from time to time). For really secure transmissions you
  19. /// can optionally also use RSA cryptography by sending the AES seed value
  20. /// encrypted with a public RSA key that only the server can decrypt.
  21. /// Derived classes can also provide extra functionality if needed.
  22. /// Some servers like the log server just need a username, nothing else.
  23. /// </summary>
  24. Connect = 0,
  25. /// <summary>
  26. /// After the server has received the Connect message from the client, it
  27. /// should respond with the Login message telling the client if the login
  28. /// succeeded and any other data required for the login. This is the first
  29. /// message send from the server to the client and if the server rejects
  30. /// it, we are usually disconnected right away again (user not found,
  31. /// password wrong, decryption failed).
  32. /// </summary>
  33. Login = 1,
  34. /// <summary>
  35. /// Text message by the connected user, will be displayed together with the
  36. /// current time in this format: Time: Username: Message. Only used by
  37. /// simple services like the log server, usually overwritten with some
  38. /// other message types for more advanced servers.
  39. /// </summary>
  40. TextMessage = 2,
  41. }
  42. }