Message.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using UnityEngine;
  2. using System;
  3. using Sfs2X.Entities.Data;
  4. public class Message
  5. {
  6. public const string LABEL_COMMAND = "c";
  7. public const string LABEL_DATA = "p";
  8. public const string LABEL_DATA_ARRAY = "a";
  9. public const string LABEL_SENDER = "sd";
  10. public const string LABEL_TIMESTAMP = "ts";
  11. public int sender = -1;
  12. public string cmd;
  13. public ISFSObject data;
  14. public bool isRoomMsg; // only use at cmd is MessageArray to check send to room or zone
  15. public Message()
  16. {
  17. }
  18. public Message (ISFSObject msg)
  19. {
  20. this.cmd = msg.GetUtfString (LABEL_COMMAND);
  21. this.data = msg.GetSFSObject (LABEL_DATA);
  22. }
  23. public Message (string cmd, ISFSObject data)
  24. {
  25. this.cmd = cmd;
  26. this.data = data;
  27. }
  28. public ISFSObject GetMessagePackage()
  29. {
  30. ISFSObject pack = new SFSObject();
  31. pack.PutUtfString(LABEL_COMMAND, cmd);
  32. pack.PutSFSObject(LABEL_DATA, data);
  33. return pack;
  34. }
  35. public virtual bool AttempOverride(Message msg)
  36. {
  37. return false;
  38. }
  39. public static void TraceSfsObject(ISFSObject obj)
  40. {
  41. Debuger.Log("GetDump : "+obj.GetDump());
  42. }
  43. }