A chat app
- Go 100%
| _data | ||
| cmd/server | ||
| internal | ||
| .gitignore | ||
| go.mod | ||
| go.sum | ||
| README.md | ||
Notes for planning Yapper
Features
- 1 on 1 conversations
- Group chats
- Calls
- Screen share
- Meetings/Call plannings
Endpoints
There should be 2 entry points, HTTP REST-like API, and the Websocket endpoint(s)
Websocket
Websockets will probably be a read-only stream of data? https://devcenter.heroku.com/articles/websocket-security
they live under the /ws/vX/... path
/ws/v1/authenticate -> token wss://{username}:{token}@/ws/v1/connect
Tokens can only be used once per connection, should only be used by the requesting session + ip
REST
Any interactions done by the user, eg sending messages, should be done through the REST API.
They live under the /api/vX/... path
/api/v1/message/create /api/v1/about/me
Events
The app should have an event loop that any handler can broadcast an event to any other part of the app
handler.SendEvent(UserMessage{
Content: "blah blah",
Author: user,
})
handler.SendEvent(UserOnline{
User: user,
})
handler.SendEvent(ChatCreated{
Group: group,
Kind: "directMessage", // directMessage, groupChat
})
for event <- handler.EventQueue {
switch e := event.type {
case UserMessage:
// blahblah
case ChatCreated:
// blahblah
}
}