data.py
Go to the documentation of this file.
1 import json
2 
3 
5  peer_id,
6  token,
7  target_id,
8  plugin_info,
9  metadata,
10  data_id,
11  redirect_ip,
12  redirect_port,
13 ):
14  message = json.loads(
15  "{"
16  ' "request_type":"DATA",'
17  ' "command":"CONNECT",'
18  ' "params": {'
19  f' "peer_id": "{peer_id}", '
20  f' "token": "{token}", '
21  f' "target_id": "{target_id}", '
22  f' "plugin_info": {json.dumps(plugin_info)}, '
23  ' "options": {'
24  ' "serialization": "NONE", '
25  ' "dcInit": {'
26  ' "ordered": false, ' # パケットの順番をソートさせない場合
27  ' "maxRetransmits": 0 ' # リアルタイム通信を阻害しないよう再送させない場合
28  " }"
29  " },"
30  ' "params": { '
31  f' "data_id": "{data_id}" '
32  " }, "
33  ' "redirect_params": { '
34  f' "ip_v4": "{redirect_ip}", '
35  f' "port": {redirect_port}'
36  " }"
37  " }"
38  "}"
39  )
40 
41  message["params"]["options"]["metadata"] = json.dumps(metadata)
42  return json.dumps(message)
43 
44 
45 def redirect_request(data_connection_id, plugin_info):
46  return (
47  "{"
48  ' "request_type":"DATA",'
49  ' "command":"REDIRECT",'
50  ' "params":{'
51  f' "data_connection_id":"{data_connection_id}",'
52  f' "plugin_info":{json.dumps(plugin_info)}'
53  " }"
54  "}"
55  )
56 
57 
58 def create_data_status_request(data_connection_id):
59  return (
60  "{"
61  ' "request_type":"DATA",'
62  ' "command":"STATUS",'
63  ' "params":{'
64  f' "data_connection_id":"{data_connection_id}"'
65  " }"
66  "}"
67  )
def create_connect_request(peer_id, token, target_id, plugin_info, metadata, data_id, redirect_ip, redirect_port)
Definition: data.py:13
def redirect_request(data_connection_id, plugin_info)
Definition: data.py:45
def create_data_status_request(data_connection_id)
Definition: data.py:58


skyway
Author(s): Toshiya Nakakura
autogenerated on Sat Apr 15 2023 02:08:21