examples: Add chat example that also doesn't work properly yet
This commit is contained in:
70
examples/chat/protocol.md
Normal file
70
examples/chat/protocol.md
Normal file
@@ -0,0 +1,70 @@
|
||||
# Chat Protocol
|
||||
|
||||
This document describes a simple chat protocol. To re-generate the source files,
|
||||
run `go run ./cmd/hopp-generate examples/chat/protocol.md examples/chat/protocol`
|
||||
|
||||
## Messages
|
||||
|
||||
### 0000 Error
|
||||
| Tag | Name | Type | Required |
|
||||
| --: | ----------- | ------ | -------- |
|
||||
| 0 | Code | U16 | Yes |
|
||||
| 1 | Description | String | No |
|
||||
|
||||
Error is sent by a party when the other party has done something erroneous. The
|
||||
valid error codes are:
|
||||
|
||||
- 0: General, unspecified error
|
||||
|
||||
The description field, if specified, determines a human-readable error to be
|
||||
shown to the user. The sending party must immediately close the transaction
|
||||
after this message is sent.
|
||||
|
||||
### 0001 Success
|
||||
Success is sent by a party when it has successfully completed a task given to it
|
||||
by the other party. The sending party must immediately close the transaction
|
||||
after this message is sent.
|
||||
|
||||
### 0100 UpdateProfile
|
||||
| Tag | Name | Type | Required |
|
||||
| --: | -------- | ------ | -------- |
|
||||
| 0 | Nickname | String | No |
|
||||
|
||||
UpdateProfile is sent by the client in a new transaction to update the profile
|
||||
details that will be shown to other connected clients.
|
||||
|
||||
### 0200 Join
|
||||
| Tag | Name | Type | Required |
|
||||
| --: | -------- | ------ | -------- |
|
||||
| 0 | Room | String | Yes |
|
||||
|
||||
Join is sent by the client when it wishes to join a room. It must begin a new
|
||||
transaction, and that transaction will persist while the user is in that room.
|
||||
Messages having to do with the room will be sent along this transaction. To
|
||||
leave the room, the client must close the transaction.
|
||||
|
||||
### 0201 Chat
|
||||
| Tag | Name | Type | Required |
|
||||
| --: | -------- | ------ | -------- |
|
||||
| 0 | Nickname | String | No |
|
||||
| 1 | Content | String | Yes |
|
||||
|
||||
Chat is sent by the client when it wishes to post a message to the room. It is
|
||||
also relayed by the server to other clients to notify them of the message. It
|
||||
must be sent within a room transaction.
|
||||
|
||||
### 0300 JoinNotify
|
||||
| Tag | Name | Type | Required |
|
||||
| --: | -------- | ------ | -------- |
|
||||
| 0 | Nickname | String | No |
|
||||
|
||||
JoinNotify is sent by the server when another client joins the room. It must be
|
||||
sent within a room transaction.
|
||||
|
||||
### 0301 LeaveNotify
|
||||
| Tag | Name | Type | Required |
|
||||
| --: | -------- | ------ | -------- |
|
||||
| 0 | Nickname | String | No |
|
||||
|
||||
LeaveNotify is sent by the server when another client leaves the room. It must
|
||||
be sent within a room transaction.
|
||||
Reference in New Issue
Block a user