Skip to content

Commit 737b0fc

Browse files
committed
Comments: improve app-level protocol doc
1 parent 7e663b9 commit 737b0fc

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

unpythonic/net/server.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -182,30 +182,30 @@ class ClientExit(Exception):
182182
self.decoder = MessageDecoder(socketsource(self.sock))
183183
self.paired_repl_session_id = None
184184
while True:
185-
# The control server follows a request-reply application-level protocol,
186-
# layered on top of the `unpythonic.net.msg` protocol, layered on top
187-
# of a TCP socket.
185+
# The control server follows a request-reply application-level
186+
# protocol, which is essentially a remote procedure call
187+
# interface. We use ApplevelProtocolMixin, which allows us to
188+
# transmit the function name, arguments and return values in
189+
# a dictionary format.
188190
#
189-
# A message sent by the client contains exactly one request.
190-
# A request is a UTF-8 encoded JSON dictionary with one
191-
# compulsory field: "command". It must contain one of the
192-
# recognized command names as `str`.
191+
# A request from the client is a dictionary, with str keys. It
192+
# must contain the field "command", with its value set to one
193+
# of the recognized command names as an `str`.
193194
#
194195
# Existence and type of any other fields depends on each
195196
# individual command. This server source code is the official
196197
# documentation of this small app-level protocol.
197198
#
198-
# For each request received, the server sends a reply.
199-
# A reply is a UTF-8 encoded JSON dictionary with one
200-
# compulsory field: "status". Upon success, it must contain
201-
# the string "ok". The actual return value(s) (if any) may
202-
# be provided in arbitrary other fields, defined by each
203-
# individual command.
199+
# For each request received, the server sends a reply, which is
200+
# also a dictionary with str keys. It has one compulsory field:
201+
# "status". Upon success, it must contain the string "ok". The
202+
# actual return value(s) (if any) may be provided in arbitrary
203+
# other fields, defined by each individual command.
204204
#
205-
# Upon failure, the "status" must contain the string "failed".
206-
# An optional (and recommended!) "reason" field may contain
207-
# a short description about the failure. More information
208-
# may be included in arbitrary other fields.
205+
# Upon failure, the "status" field must contain the string
206+
# "failed". An optional (but strongly recommended!) "reason"
207+
# field may contain a short description about the failure.
208+
# More information may be included in arbitrary other fields.
209209
request = self._recv()
210210
if not request:
211211
server_print("Socket for {} closed by client.".format(client_address_str))

0 commit comments

Comments
 (0)