File: protocol.txt

package info (click to toggle)
storm-lang 0.7.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 52,028 kB
  • sloc: ansic: 261,471; cpp: 140,432; sh: 14,891; perl: 9,846; python: 2,525; lisp: 2,504; asm: 860; makefile: 678; pascal: 70; java: 52; xml: 37; awk: 12
file content (90 lines) | stat: -rw-r--r-- 4,087 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
Protocol
=========

All messages start with a null byte. Everything else is interpreted as text and outputted verbatim to the output.

The first four bytes of each message (following the null byte) contain the total length of the
message, encoded as a number.

Entries are encoded as follows:
First byte  	    Meaning
0x00  		    nil.
0x01  		    cons. read two entries.
0x02		    number. read 4 bytes in network order
0x03		    string. read 4 bytes size and then n bytes in utf-8
0x04		    symbol. new symbol, read 4 bytes for its id, then a string.
0x05		    symbol. read 4 bytes, look up in the hash table.

Note: symbols are stored in a hash table for the server and the client. The server starts at high
id:s while the client starts allocating symbols at low id:s. Note that the server and the client
might accidentally allocate different id:s for the same symbol. This is not a problem.

Messages
=========

Messages are sent as a list of at least one element, where the first element is a symbol describing
the type of the message. Any remaining parameters depend on the message type that was sent.

Messages sent from a client to the server:

Message	                      Description
(quit)	 	 	      Asks the Storm process to quit.
(supported type)	      See if the file type 'type' is supported.
(open id path content <pos>)  Open a new file from 'path', hereby referred to as 'id' containing 'content'.
                              This is considered edit #0. If <pos> is included, it indicates the current position
			      of the cursor, the same as indicated by 'point' below.
(close id)    		      Close a previously opened file.
(edit file id from to text)   The file 'file' has been changed. This is edit number 'id'. The text between
                              'from' and 'to' is replaced by 'text'.
(point file pos)              Tell Storm that the point is now at 'pos'.
(indent file pos)	      Query the indentation of 'file' at position 'pos'.
(error file) 		      Find and report any parse errors in 'file' (in textual form).
(test ...)		      Messages used for testing the protocol. See below.
(chunk-size n <timeout>)      Set the size of chunks (in characters) sent to the client at once. 0 disables
	    		      sending coloring information unless eplicitly queried by the 'color' message.
			      An optional 'timeout' value explicitly sets the idle timeout.
(debug id mode)		      Output the internal representation of file 'id'. Used when debugging.
(color id)    	      	      Send coloring information for 'file' once more.


Messages sent from the server to a client:
(supported type result)	      Reports that 'type' is or is not supported, depending on 'result'
(color file id start colors)  Color 'file' using information from edit #'id'. Start at character 'start'
                              and color the next '(nth 0 colors)' using '(nth 1 colors)' and so on. Note:
			      'colors' is inlined in the list.
(indent file value)	      Returns the indentation for a previous 'indent' query. 'value' is either
                              'level n, indication indentation depth 'n', or 'as n, which indicates
			      that the line should be indented in the same level as the line at position 'n'.
(test ...)		      Messages used for testing the protocol. See below.


Colors
=======

Colore are sent as symbols, nil erases any coloring present.

comment
delimiter
string
constant
keyword
fn-name
var-name
type-name


Tests
======

To test the implementation of the protocol (ie. the low-level layer), there is a class of messages
for testing. These all start with (test ...). Due to the architecture, tests are driven by the
client.

These are the messages the server understands:

Message                    Description
(test start)		   Clears any test state.
(test stop)		   Sends any pending messages.
(test sum ...)		   Stores a sum of all entries following 'recv'. This makes (test stop)
                	   send (test sum <sum>).
(test send n msg between)  Send 'n' copies of 'msg', adding the string 'between' between each instance.