Skip to content

Commit

Permalink
README: Reduced asynchronous client example
Browse files Browse the repository at this point in the history
  • Loading branch information
francis-clairicia committed Feb 29, 2024
1 parent 3b17978 commit cc186da
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,22 +148,6 @@ if __name__ == "__main__":
<summary>Asynchronous version ( with <code>async def</code> )</summary>

```py
import asyncio
from typing import Any, TypeAlias

from easynetwork.clients import AsyncTCPNetworkClient
from easynetwork.protocol import StreamProtocol
from easynetwork.serializers import JSONSerializer

RequestType: TypeAlias = Any
ResponseType: TypeAlias = Any


class JSONProtocol(StreamProtocol[RequestType, ResponseType]):
def __init__(self) -> None:
super().__init__(JSONSerializer())


async def main() -> None:
async with AsyncTCPNetworkClient(("localhost", 9000), JSONProtocol()) as client:
await client.send_packet({"data": {"my_body": ["as json"]}})
Expand All @@ -172,6 +156,8 @@ async def main() -> None:


if __name__ == "__main__":
import asyncio

asyncio.run(main())
```

Expand Down

0 comments on commit cc186da

Please sign in to comment.