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.
 
 
 

189 lines
5.1 KiB

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