improve server relay and client
This commit is contained in:
parent
9984583dd2
commit
fd0e2afddb
6 changed files with 461 additions and 109 deletions
|
|
@ -1,8 +1,28 @@
|
|||
package protocol
|
||||
|
||||
// MessageType ensures we only use valid protocol commands
|
||||
type MessageType string
|
||||
|
||||
const (
|
||||
// TypeLogin: Client -> Server (Handshake with Public Key)
|
||||
TypeLogin MessageType = "login"
|
||||
|
||||
// TypeIdentity: Server -> Client (Here is your Account Number)
|
||||
TypeIdentity MessageType = "identity"
|
||||
|
||||
// TypeLookup: Client -> Server (Who owns Account #10050?)
|
||||
TypeLookup MessageType = "lookup"
|
||||
|
||||
// TypeLookupResponse: Server -> Client (Here is the Public Key for #10050)
|
||||
TypeLookupResponse MessageType = "lookup_response"
|
||||
|
||||
// TypeMsg: Client -> Server -> Client (Encrypted Payload)
|
||||
TypeMsg MessageType = "msg"
|
||||
)
|
||||
|
||||
type Message struct {
|
||||
Type string `json:"type"`
|
||||
Sender string `json:"sender"`
|
||||
Target string `json:"target"`
|
||||
Content string `json:"content"`
|
||||
Type MessageType `json:"type"`
|
||||
Sender string `json:"sender"` // Hex Public Key
|
||||
Target string `json:"target"` // Hex Public Key (msg) or Account # (lookup)
|
||||
Content string `json:"content"`
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue