FreeRDP
Loading...
Searching...
No Matches
xdg-aad-helper.JsonRpcChannel Class Reference

Public Member Functions

 __init__ (self, int fd_in, int fd_out)
 
 read_message (self)
 
None send (self, dict message)
 

Protected Attributes

 _in
 
 _out
 
 _out_lock
 
 _buf
 

Detailed Description

Newline-delimited JSON over the raw cmdIn/cmdOut pipe fds.

Definition at line 105 of file xdg-aad-helper.py.

Constructor & Destructor Documentation

◆ __init__()

xdg-aad-helper.JsonRpcChannel.__init__ (   self,
int  fd_in,
int  fd_out 
)

Definition at line 108 of file xdg-aad-helper.py.

108 def __init__(self, fd_in: int, fd_out: int):
109 self._in = os.fdopen(fd_in, "rb", buffering=0)
110 self._out = os.fdopen(fd_out, "wb", buffering=0)
111 self._out_lock = threading.Lock()
112 self._buf = b""
113

Member Function Documentation

◆ read_message()

xdg-aad-helper.JsonRpcChannel.read_message (   self)
Returns the next parsed JSON object, {} for an unparsable line
(silently ignored per the protocol notes), or None on EOF.

Definition at line 114 of file xdg-aad-helper.py.

114 def read_message(self):
115 """Returns the next parsed JSON object, {} for an unparsable line
116 (silently ignored per the protocol notes), or None on EOF."""
117 while b"\n" not in self._buf:
118 chunk = self._in.read(4096)
119 if not chunk:
120 return None
121 self._buf += chunk
122 line, _, self._buf = self._buf.partition(b"\n")
123 if not line.strip():
124 return {}
125 try:
126 return json.loads(line)
127 except ValueError:
128 return {}
129

References xdg-aad-helper.JsonRpcChannel._buf, test_qt_aad_auth_helper.HelperProcess._in, xdg-aad-helper.JsonRpcChannel._in, test_qt_aad_auth_helper.HelperProcess._out, xdg-aad-helper.JsonRpcChannel._out, and xdg-aad-helper.JsonRpcChannel._out_lock.

◆ send()

None xdg-aad-helper.JsonRpcChannel.send (   self,
dict  message 
)

Definition at line 130 of file xdg-aad-helper.py.

130 def send(self, message: dict) -> None:
131 data = (json.dumps(message) + "\n").encode()
132 with self._out_lock:
133 self._out.write(data)
134
135

Field Documentation

◆ _buf

xdg-aad-helper.JsonRpcChannel._buf
protected

Definition at line 112 of file xdg-aad-helper.py.

Referenced by xdg-aad-helper.JsonRpcChannel.read_message().

◆ _in

xdg-aad-helper.JsonRpcChannel._in
protected

Definition at line 109 of file xdg-aad-helper.py.

Referenced by xdg-aad-helper.JsonRpcChannel.read_message().

◆ _out

xdg-aad-helper.JsonRpcChannel._out
protected

Definition at line 110 of file xdg-aad-helper.py.

Referenced by xdg-aad-helper.JsonRpcChannel.read_message().

◆ _out_lock

xdg-aad-helper.JsonRpcChannel._out_lock
protected

Definition at line 111 of file xdg-aad-helper.py.

Referenced by xdg-aad-helper.JsonRpcChannel.read_message().


The documentation for this class was generated from the following file: