Official cwtch.im peer and server implementations. https://cwtch.im
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

198 lines
5.4KB

  1. package event
  2. // Type captures the definition of many common Cwtch application events
  3. type Type string
  4. // Defining Common Event Types
  5. const (
  6. StatusRequest = Type("StatusRequest")
  7. ProtocolEngineStatus = Type("ProtocolEngineStatus")
  8. PeerRequest = Type("PeerRequest")
  9. // Blocking Events both Block and Unblock have the same structure
  10. // attributes:
  11. // RemotePeer: [eg "chpr7qm6op5vfcg2pi4vllco3h6aa7exexc4rqwnlupqhoogx2zgd6qd"
  12. BlockPeer = Type("BlockPeer")
  13. UnblockPeer = Type("UnblockPeer")
  14. JoinServer = Type("JoinServer")
  15. ProtocolEngineStartListen = Type("ProtocolEngineStartListen")
  16. ProtocolEngineStopped = Type("ProtocolEngineStopped")
  17. InvitePeerToGroup = Type("InvitePeerToGroup")
  18. // a group invite has been received from a remote peer
  19. // attributes:
  20. // TimestampReceived [eg time.Now().Format(time.RFC3339Nano)]
  21. // RemotePeer: [eg "chpr7qm6op5vfcg2pi4vllco3h6aa7exexc4rqwnlupqhoogx2zgd6qd"]
  22. // GroupInvite: [eg "torv3....."]
  23. NewGroupInvite = Type("NewGroupInvite")
  24. // GroupID
  25. AcceptGroupInvite = Type("AcceptGroupInvite")
  26. SendMessageToGroup = Type("SendMessagetoGroup")
  27. //Ciphertext, Signature:
  28. EncryptedGroupMessage = Type("EncryptedGroupMessage")
  29. //TimestampReceived, TimestampSent, Data(Message), GroupID, Signature, PreviousSignature, RemotePeer
  30. NewMessageFromGroup = Type("NewMessageFromGroup")
  31. // an error was encountered trying to send a particular Message to a group
  32. // attributes:
  33. // GroupServer: The server the Message was sent to
  34. // Signature: The signature of the Message that failed to send
  35. // Error: string describing the error
  36. SendMessageToGroupError = Type("SendMessageToGroupError")
  37. SendMessageToPeer = Type("SendMessageToPeer")
  38. NewMessageFromPeer = Type("NewMessageFromPeer")
  39. // Peer acknowledges a previously sent message
  40. // attributes
  41. // EventID: The original event id that the peer is responding too.
  42. // RemotePeer: The peer associated with the acknowledgement
  43. PeerAcknowledgement = Type("PeerAcknowledgement")
  44. // attributes:
  45. // RemotePeer: [eg "chpr7qm6op5vfcg2pi4vllco3h6aa7exexc4rqwnlupqhoogx2zgd6qd"]
  46. // Error: string describing the error
  47. SendMessageToPeerError = Type("SendMessageToPeerError")
  48. // REQUESTS TO STORAGE ENGINE
  49. // a peer contact has been added
  50. // attributes:
  51. // RemotePeer [eg ""]
  52. PeerCreated = Type("PeerCreated")
  53. // a group has been successfully added or newly created
  54. // attributes:
  55. // Data [serialized *model.Group]
  56. GroupCreated = Type("GroupCreated")
  57. // RemotePeer
  58. DeleteContact = Type("DeleteContact")
  59. // GroupID
  60. DeleteGroup = Type("DeleteGroup")
  61. // change the .Name attribute of a profile (careful - this is not a custom attribute. it is used in the underlying protocol during handshakes!)
  62. // attributes:
  63. // ProfileName [eg "erinn"]
  64. SetProfileName = Type("SetProfileName")
  65. // request to store a profile-wide attribute (good for e.g. per-profile settings like theme prefs)
  66. // attributes:
  67. // Key [eg "fontcolor"]
  68. // Data [eg "red"]
  69. SetAttribute = Type("SetAttribute")
  70. // request to store a per-contact attribute (e.g. display names for a peer)
  71. // attributes:
  72. // RemotePeer [eg ""]
  73. // Key [eg "nick"]
  74. // Data [eg "erinn"]
  75. SetPeerAttribute = Type("SetPeerAttribute")
  76. // request to store a per-cwtch-group attribute (e.g. display name for a group)
  77. // attributes:
  78. // GroupID [eg ""]
  79. // Key [eg "nick"]
  80. // Data [eg "open privacy board"]
  81. SetGroupAttribute = Type("SetGroupAttribute")
  82. // RemotePeer
  83. // ConnectionState
  84. PeerStateChange = Type("PeerStateChange")
  85. // GroupServer
  86. // ConnectionState
  87. ServerStateChange = Type("ServerStateChange")
  88. /***** Application client / service messages *****/
  89. // ProfileName, Password
  90. CreatePeer = Type("CreatePeer")
  91. // service -> client: Identity(localId), Password, [Status(new/default=blank || from reload='running')]
  92. // app -> Identity(onion)
  93. NewPeer = Type("NewPeer")
  94. // Identity(onion), Data(pluginID)
  95. AddPeerPlugin = Type("AddPeerPlugin")
  96. // Password
  97. LoadProfiles = Type("LoadProfiles")
  98. // Client has reloaded, triggers NewPeer s then ReloadDone
  99. ReloadClient = Type("ReloadClient")
  100. ReloadDone = Type("ReloadDone")
  101. // Identity - Ask service to resend all connection states
  102. ReloadPeer = Type("ReloadPeer")
  103. // Identity(onion)
  104. ShutdownPeer = Type("ShutdownPeer")
  105. Shutdown = Type("Shutdown")
  106. // Error(err)
  107. PeerError = Type("PeerError")
  108. // Error(err)
  109. AppError = Type("AppError")
  110. // Progress, Status
  111. ACNStatus = Type("ACNStatus")
  112. )
  113. // Field defines common event attributes
  114. type Field string
  115. // Defining Common Field Types
  116. const (
  117. RemotePeer = Field("RemotePeer")
  118. Ciphertext = Field("Ciphertext")
  119. Signature = Field("Signature")
  120. PreviousSignature = Field("PreviousSignature")
  121. TimestampSent = Field("TimestampSent")
  122. TimestampReceived = Field("TimestampReceived")
  123. Identity = Field("Identity")
  124. GroupID = Field("GroupID")
  125. GroupServer = Field("GroupServer")
  126. GroupInvite = Field("GroupInvite")
  127. ProfileName = Field("ProfileName")
  128. Password = Field("Password")
  129. ConnectionState = Field("ConnectionState")
  130. Key = Field("Key")
  131. Data = Field("Data")
  132. Error = Field("Error")
  133. Progreess = Field("Progress")
  134. Status = Field("Status")
  135. EventID = Field("EventID")
  136. EventContext = Field("EventContext")
  137. )
  138. // Defining Common errors
  139. const (
  140. AppErrLoaded0 = "Loaded 0 profiles"
  141. )
  142. // Defining Protocol Contexts
  143. const (
  144. ContextAck = "im.cwtch.acknowledgement"
  145. ContextInvite = "im.cwtch.invite"
  146. ContextRaw = "im.cwtch.raw"
  147. )