From 0e755398ddd1c4306d3298f3e34c76702600b93c Mon Sep 17 00:00:00 2001 From: Jordan Orelli Date: Sat, 3 Jan 2015 00:14:12 -0500 Subject: [PATCH] renaming things --- auth.go | 4 ++-- client.go | 2 +- key.go | 2 +- message.go | 2 +- note.go | 4 ++-- request.go | 2 +- server.go | 8 ++++---- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/auth.go b/auth.go index 6a8db8c..cec0c3d 100644 --- a/auth.go +++ b/auth.go @@ -4,11 +4,11 @@ import ( "crypto/rsa" ) -type Auth struct { +type AuthRequest struct { Nick string Key *rsa.PublicKey } -func (a *Auth) Kind() string { +func (a *AuthRequest) Kind() string { return "auth" } diff --git a/client.go b/client.go index c2e1237..d80f9be 100644 --- a/client.go +++ b/client.go @@ -152,7 +152,7 @@ func (c *Client) handleListNotes(raw json.RawMessage) error { } func (c *Client) handshake() error { - r := &Auth{Nick: c.nick, Key: &c.key.PublicKey} + r := &AuthRequest{Nick: c.nick, Key: &c.key.PublicKey} c.info("authenticating as %s", c.nick) promise, err := c.sendRequest(r) if err != nil { diff --git a/key.go b/key.go index ccc5d78..8b8bb88 100644 --- a/key.go +++ b/key.go @@ -119,7 +119,7 @@ func getPublic() { type KeyRequest string func (k KeyRequest) Kind() string { - return "key" + return "get-key" } func (k KeyRequest) Nick() string { diff --git a/message.go b/message.go index 62b14fb..632c204 100644 --- a/message.go +++ b/message.go @@ -10,7 +10,7 @@ type Message struct { } func (m Message) Kind() string { - return "message" + return "send-message" } type ListMessages struct { diff --git a/note.go b/note.go index 5029c61..1cdc003 100644 --- a/note.go +++ b/note.go @@ -50,7 +50,7 @@ type ListNotes struct { } func (l ListNotes) Kind() string { - return "list-notes" + return "list-notes-request" } type ListNotesResponseItem struct { @@ -62,5 +62,5 @@ type ListNotesResponseItem struct { type ListNotesResponse []ListNotesResponseItem func (l ListNotesResponse) Kind() string { - return "list-notes" + return "list-notes-response" } diff --git a/request.go b/request.go index 56554c2..5790438 100644 --- a/request.go +++ b/request.go @@ -64,7 +64,7 @@ func decodeRequest(conn net.Conn) (request, error) { } switch env.Kind { case "auth": - var auth Auth + var auth AuthRequest if err := json.Unmarshal(env.Body, &auth); err != nil { return nil, fmt.Errorf("unable to unmarshal auth request: %v", err) } diff --git a/server.go b/server.go index b230e8c..9e274a0 100644 --- a/server.go +++ b/server.go @@ -48,11 +48,11 @@ func (s *serverConnection) handleRequest(request Envelope) error { return s.handleNoteRequest(request.Id, request.Body) case "get-note": return s.handleGetNoteRequest(request.Id, request.Body) - case "list-notes": + case "list-notes-request": return s.handleListNotesRequest(request.Id, request.Body) - case "key": + case "get-key": return s.handleKeyRequest(request.Id, request.Body) - case "message": + case "send-message": return s.handleMessageRequest(request.Id, request.Body) case "get-message": return s.handleGetMessageRequest(request.Id, request.Body) @@ -64,7 +64,7 @@ func (s *serverConnection) handleRequest(request Envelope) error { } func (s *serverConnection) handleAuthRequest(requestId int, body json.RawMessage) error { - var auth Auth + var auth AuthRequest if err := json.Unmarshal(body, &auth); err != nil { return fmt.Errorf("bad auth request: %v", err) }