aboutsummaryrefslogtreecommitdiff
path: root/test/send.py
blob: 78b89aa3e8dac3d4f29e24805bcda20ae43ec946 (plain)
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
#!/usr/bin/env python3
import json
import sys


def send(message: dict):
    raw = json.dumps(message)
    message = "Content-Length: " + str(len(raw)) + "\r\n\r\n" + raw
    sys.stdout.write(message)


initialize = {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "initialize",
    "params": {"processId": None, "rootUri": None, "capabilities": {}},
}
send(initialize)

initialized = {
    "jsonrpc": "2.0",
    "id": 2,
    "method": "initialized",
    "params": {},
}
send(initialized)

shutdown = {
    "jsonrpc": "2.0",
    "id": 3,
    "method": "shutdown",
    "params": {},
}
send(shutdown)

_exit = {
    "jsonrpc": "2.0",
    "id": 4,
    "method": "exit",
    "params": {},
}
send(_exit)