Is there any streaming bot example available in Python?
Closed this issue · 4 comments
🚨 The issue tracker is not for questions 🚨
If you have a question, please ask it on https://stackoverflow.com/questions/tagged/botframework
I have been searching for a bot example in Python which uses streaming response but haven't seen any solid sample code. Can someone point out a code example for that? Thank you.
Hi hakankaraoguz,
hope you are doing good! Since you haven't mentioned the type of streaming,let it be a video streaming. I have found a repository:https://github.com/ITZ-ZAID/Video-Player.git . I hope it will be helpful for you.
Here is what you were looking i hope , import asyncio
`class StreamingBot:
async def handle_client(self, reader, writer):
print("Client connected.")
try:
while True:
response = str(self.generate_random_number())
writer.write(response.encode())
await writer.drain()
await asyncio.sleep(1)
finally:
writer.close()
def generate_random_number():
return random.randint(1, 100)
async def main():
server = await asyncio.start_server(StreamingBot().handle_client, "localhost", 8888)
print("Serving on localhost:8888")
await server.serve_forever()
asyncio.run(main())`
@hakankaraoguz - Are you still needing help with this? Was the solution provided by @DarkTechPirate sufficient?
Hello @DarkTechPirate and @stevkan
Sorry for my late reply. I have solved it in a different way. We can close the issue. Thank you so much for your help.