import uuid

import asyncio
import socketio

# Create an asynchronous Socket.IO client with reconnection options
sio = socketio.AsyncClient(reconnection=True, reconnection_attempts=5)

# Event handler for connection
@sio.event
async def connect():
    print('Connection established')

# Event handler for disconnection
@sio.event
async def disconnect():
    print('Disconnected from server')

# Event handler for custom event response
@sio.event
async def response(data):
    print('Response from server:', data)

# Asynchronous function to emit 'updateCartWeight' event
async def cart_weight_update(data):
    while True:
        print('Emitting updateCartWeight')
        if sio.connected:
            await sio.emit('updateCartWeight', data)
        else:
            print("Socket is not connected")
        await asyncio.sleep(10)

# Main function to run the async client
async def main():
    await sio.connect('http://localhost:3009/wsio?auth_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqd3RpZCI6IlVtX0pWMVh2ZSIsImlhdCI6MTcxOTMyMTE4MzA0NywiZXhwIjoxNzE5MzM1NTgzLCJzdWIiOiJhdXRoX3Rva2VuIiwiZGF0YSI6eyJtb2JpbGUiOiI5NjMyNTY4OTYzIiwidXNlcl9pZCI6IjY2NjkzYWFhMzVmM2U1NmM0ZDVhMTBmMiJ9fQ.G-uxUzZFu1YoK711BcguC6Z9Zhis9k9S1lq6JbToAP4&=')
    
    # Start cart weight update in the background
    asyncio.create_task(cart_weight_update({'weight': 1000}))
    
    # Wait indefinitely for events
    await sio.wait()

# Run the main function
if __name__ == '__main__':
    asyncio.run(main())


def get_mac_address():
    mac = uuid.getnode()
    mac_address = ':'.join(('%012X' % mac)[i:i+2] for i in range(0, 12, 2))
    return mac_address

mac_address = get_mac_address().lower()


print('MAC Address:', mac_address)