@@ -3,10 +3,34 @@ package main
3
3
import "github.com/mriceman/go-uml/sequence"
4
4
5
5
func main () {
6
- userStartsChatting ()
7
- userBIsNotPartOfChat ()
8
- UserBIsPartOfChat ()
6
+ userJoinsChat ()
7
+ }
8
+
9
+ func userJoinsChat () {
10
+ d := sequence .NewDiagram ("new_chat" )
11
+ userA := "userA (name could be quite longer)"
12
+ userB := "userB"
13
+ b := "backend"
14
+
15
+ d .SetTitle ("User starts a chat with someone (doesn't matter if new or not)" )
16
+
17
+ d .AddParticipants (userA , userB , b )
18
+
19
+ _ = d .AddDirectionalEdge (userA , b , `POST /inbox {"recipient": userID, "project": projectID, "projectType": challenge|solution}"` )
20
+ _ = d .AddDirectionalEdge (b , userA , "Response Status Code: 202, Body: Inbox{id, secret, recipient, ...}" )
21
+ _ = d .AddDirectionalEdge (userA , b , "WS connect" )
22
+ _ = d .AddDirectionalEdge (userA , b , `"{"action": "JOIN", "data": {"inboxId": str, "userId": "str", "inboxSecret": str}}"` )
23
+ _ = d .AddDirectionalEdge (b , b , "STORE_CONNECTION_ID(userA)" )
24
+ _ = d .AddDirectionalEdge (b , b , "sets unread inbox userA = 0" )
25
+ _ = d .AddDirectionalEdge (b , userA , `{"event": "new_message", "messages": [{"id": str, "inboxId": str, "content": str, "userId": str, "createdAt": str}]}` )
26
+ _ = d .AddDirectionalEdge (userA , b , `"{"action": "SEND_MESSAGE", "data": {"inboxId": str, "userId": "str", "inboxSecret": str, "content": "hi"}}"` )
27
+ _ = d .AddDirectionalEdge (b , b , "check connectionID userB" )
28
+ _ = d .AddUndirectionalEdge (b , b , "if connected: " )
29
+ _ = d .AddDirectionalEdge (b , userB , `{"event": "new_message", "messages": [{"id": str, "inboxId": str, "content": str, "userId": str, "createdAt": str}]}` )
30
+ _ = d .AddUndirectionalEdge (b , b , "else: " )
31
+ _ = d .AddUndirectionalEdge (b , b , "increment unread inbox userB" )
9
32
33
+ d .Render ()
10
34
}
11
35
12
36
func UserBIsPartOfChat () {
@@ -71,6 +95,7 @@ func userStartsChatting() {
71
95
d .AddParticipants (backend )
72
96
d .AddParticipants (db )
73
97
98
+ d .AddDirectionalEdge (client , backend , "GET /inbox/<TO_ID>" )
74
99
d .AddDirectionalEdge (client , backend , "PUT /chat/user/<TO_ID>" )
75
100
d .AddDirectionalEdge (backend , db , "checks or create inbox for user" )
76
101
d .AddDirectionalEdge (backend , db , "set all unread messages to read if existing" )
0 commit comments