(20241224) Live Feed From Kafka (to test).

This commit is contained in:
2024-12-24 14:06:05 +05:30
parent 7c7b10f27c
commit ae6a959a21
18 changed files with 1018 additions and 538 deletions
+44 -26
View File
@@ -134,7 +134,7 @@ SYMBOL_TO_PRICE_MAP = {
# *****************************************************************************************************************
# --- Nothing Yet
tg_update = False
# *****************************************************************************************************************
@@ -144,21 +144,39 @@ SYMBOL_TO_PRICE_MAP = {
# *****************************************************************************************************************
@sio.event
async def before_connect(sid, environ):
print(f"Checking connection attempt from {sid}.")
# # Simulate a failed connection based on some conditions (for example, invalid IP or header)
# user_agent = environ.get('HTTP_USER_AGENT', '')
# if 'BadUserAgent' in user_agent:
# print(f"Rejected connection from {sid} due to invalid User-Agent.")
# return False # This will reject the connection attempt
return True # Allow connection
# ---------------------------------------------------------------------------------------------------------------------
@sio.event
async def connect(sid, environ):
print(f"Client {sid} connected")
async with httpx.AsyncClient() as client:
try: await client.post(
url = r"https://api.thecaoffice.com/converse/tech/alert/chat/backend",
json = {
"type": "info",
"chatClient": "telegram",
"chatId": "-4206946032",
# "chatId": "1275560043",
"message": f"*SocketIO Connected!*\n👍 SID: {sid}"
}
)
except: pass
if tg_update:
async with httpx.AsyncClient() as client:
try: await client.post(
url = r"https://api.thecaoffice.com/converse/tech/alert/chat/backend",
json = {
"type": "info",
"chatClient": "telegram",
"chatId": "-4206946032",
# "chatId": "1275560043",
"message": f"*SocketIO Connected!*\n👍 SID: {sid}"
}
)
except: pass
# ---------------------------------------------------------------------------------------------------------------------
@@ -167,18 +185,19 @@ async def connect(sid, environ):
@sio.event
async def disconnect(sid):
print(f"Client {sid} disconnected")
async with httpx.AsyncClient() as client:
try: await client.post(
url = r"https://api.thecaoffice.com/converse/tech/alert/chat/backend",
json = {
"type": "info",
"chatClient": "telegram",
"chatId": "-4206946032",
# "chatId": "1275560043",
"message": f"*SocketIO Disconnected!*\n❌ SID: {sid}"
}
)
except: pass
if tg_update:
async with httpx.AsyncClient() as client:
try: await client.post(
url = r"https://api.thecaoffice.com/converse/tech/alert/chat/backend",
json = {
"type": "info",
"chatClient": "telegram",
"chatId": "-4206946032",
# "chatId": "1275560043",
"message": f"*SocketIO Disconnected!*\n❌ SID: {sid}"
}
)
except: pass
def round_tick(price):
@@ -339,7 +358,6 @@ if __name__ == "__main__":
runner = web.AppRunner(app)
await runner.setup()
site = web.TCPSite(runner, "0.0.0.0", 5214)
print("Server running on http://0.0.0.0:5000")
await site.start()
# Keep the server running