Skip to content

Commit ec3ecdb

Browse files
authored
Add logout function (#7)
1 parent 325c253 commit ec3ecdb

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// See https://aka.ms/vscode-remote/devcontainer.json for format details.
22
{
3-
"name": "PyDroid IPCam dev",
3+
"name": "Connect-Box dev",
44
"context": "..",
55
"dockerFile": "Dockerfile",
66
"postCreateCommand": "pip3 install -e .",

connect_box/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
HTTP_HEADER_X_REQUESTED_WITH = "X-Requested-With"
1717

1818
CMD_LOGIN = 15
19+
CMD_LOGOUT = 16
1920
CMD_DEVICES = 123
2021

2122

@@ -76,6 +77,13 @@ async def async_get_devices(self) -> List[Device]:
7677

7778
return self.devices
7879

80+
async def async_logout(self) -> None:
81+
"""Logout and close session."""
82+
if not self.token:
83+
return
84+
85+
await self._async_ws_function(CMD_LOGOUT)
86+
7987
async def async_initialize_token(self) -> None:
8088
"""Get the token first."""
8189
try:

example.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ async def main():
1515
await client.async_get_devices()
1616
print(client.devices)
1717

18+
await client.async_logout()
19+
1820

1921
loop = asyncio.get_event_loop()
2022
loop.run_until_complete(main())

0 commit comments

Comments
 (0)