diff options
author | Sam T <pxqr.sta@gmail.com> | 2013-05-19 08:50:59 +0400 |
---|---|---|
committer | Sam T <pxqr.sta@gmail.com> | 2013-05-19 08:50:59 +0400 |
commit | 179351029766b6003db50758fbfd61488f56eb51 (patch) | |
tree | c060e5bd39b38bd720c6d3fbe0f2ba3564d7f51a /src | |
parent | 71333831b3da64bee6030e537f4aba1c1c4b73e2 (diff) |
~ Document message types
Diffstat (limited to 'src')
-rw-r--r-- | src/Remote/KRPC/Protocol.hs | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/src/Remote/KRPC/Protocol.hs b/src/Remote/KRPC/Protocol.hs index 36a1e38a..4fbe517c 100644 --- a/src/Remote/KRPC/Protocol.hs +++ b/src/Remote/KRPC/Protocol.hs | |||
@@ -53,8 +53,14 @@ import Network.Socket hiding (recvFrom) | |||
53 | import Network.Socket.ByteString | 53 | import Network.Socket.ByteString |
54 | 54 | ||
55 | 55 | ||
56 | -- TODO Text -> ByteString | 56 | -- | Errors used to signal that some error occurred while processing a |
57 | -- TODO document that it is and how transferred | 57 | -- procedure call. Error may be send only from server to client but |
58 | -- not in the opposite direction. | ||
59 | -- | ||
60 | -- Errors are encoded as bencoded dictionary: | ||
61 | -- | ||
62 | -- { "y" : "e", "e" : [<error_code>, <human_readable_error_reason>] } | ||
63 | -- | ||
58 | data KError | 64 | data KError |
59 | -- | Some error doesn't fit in any other category. | 65 | -- | Some error doesn't fit in any other category. |
60 | = GenericError { errorMessage :: ByteString } | 66 | = GenericError { errorMessage :: ByteString } |
@@ -107,7 +113,14 @@ serverError = ServerError . BC.pack . show | |||
107 | type MethodName = ByteString | 113 | type MethodName = ByteString |
108 | type ParamName = ByteString | 114 | type ParamName = ByteString |
109 | 115 | ||
110 | -- TODO document that it is and how transferred | 116 | -- | Query used to signal that caller want to make procedure call to |
117 | -- callee and pass arguments in. Therefore query may be only sent from | ||
118 | -- client to server but not in the opposite direction. | ||
119 | -- | ||
120 | -- Queries are encoded as bencoded dictionary: | ||
121 | -- | ||
122 | -- { "y" : "q", "q" : "<method_name>", "a" : [<arg1>, <arg2>, ...] } | ||
123 | -- | ||
111 | data KQuery = KQuery { | 124 | data KQuery = KQuery { |
112 | queryMethod :: MethodName | 125 | queryMethod :: MethodName |
113 | , queryArgs :: Map ParamName BEncode | 126 | , queryArgs :: Map ParamName BEncode |
@@ -136,7 +149,15 @@ kquery name args = KQuery name (M.fromList args) | |||
136 | 149 | ||
137 | type ValName = ByteString | 150 | type ValName = ByteString |
138 | 151 | ||
139 | -- TODO document that it is and how transferred | 152 | -- | KResponse used to signal that callee successufully process a |
153 | -- procedure call and to return values from procedure. KResponse should | ||
154 | -- not be sent if error occurred during RPC. Thus KResponse may be only | ||
155 | -- sent from server to client. | ||
156 | -- | ||
157 | -- Responses are encoded as bencoded dictionary: | ||
158 | -- | ||
159 | -- { "y" : "r", "r" : [<val1>, <val2>, ...] } | ||
160 | -- | ||
140 | newtype KResponse = KResponse { | 161 | newtype KResponse = KResponse { |
141 | respVals :: Map ValName BEncode | 162 | respVals :: Map ValName BEncode |
142 | } deriving (Show, Read, Eq, Ord) | 163 | } deriving (Show, Read, Eq, Ord) |