< > BotCompany Repo | #237
- Brain protocol, JSON version, v2
Everything takes place over TCP/sockets. Communication is always between a "client" and "brain" (server) which one or more TCP connections between them.
Each client or brain line is a one-line JSON array.
['answers', '#cmd1', [['#3', 'OK', 'ok'], ['#4', 'Int', '10']] -- asynchronous answers to a command, each object with type and desc
['error', 'copy of line', 'error text'] -- report error in the client line
['cmd', '#receiver', commandAsJSONArray] -- send command
['forget', ['#3', '#4']] -- discard object references
['exit'] -- complete this talk
Commands are numbered from 1 up per talk (#cmd1, #cmd2 etc), so there is no need for the client to transmit the ID.
There is always an initial object on the brain side called #start that the client can send commands to. #start has type "Start", description "start" and no help text.
(Having #start is a simpler approach than the initial-objects command in v1. It also makes making a facade easier because it can produce a #start object without any information on the brain it facades/will facade.)
The "info" command is not currently used. We can supercede it with ThingStandardCommands (_desc etc). It used to look like that:
--['info', ['#3']] -- get info on objects (type, description, pointers)
--['info', '#3'] -- shorter syntax for only one object
--['info', [['#3', 'OK', 'ok', 'a', 'b', 'c', 'd']]] -- answer to info request: id, type, desc, pointers
The protocol can be used bidirectionally if you like that sort of thing, with both parties being client and server (or the 'brain'). The two different 'info' lines (request vs answer) can be distinguished by the argument format (just id or id plus 3 more fields).
Using the protocol bidirectionally in one connection could also allow the client to introduce itself via an initial object. Whatever the format for that is. Maybe "#i-am" with type "IAm" and description "brain client bla version x running on this and that server".
download show line numbers
Travelled to 8 computer(s): aoiabmzegqzx, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, tslmcundralx, tvejysmllsmz
No comments. add comment
Image recognition results
||Brain protocol, JSON version, v2
|Eternal ID of this version:
||basic brain design :o)
|Public (visible to everyone):
|Archived (hidden from active list):
|Source code size:
||2077 bytes / 36 lines
|Pitched / IR pitched:
||No / Yes
|Views / Downloads:
||662 / 102
Formerly at http://tinybrain.de/237 & http://237.tinybrain.de