// File: andresziemecki[P]MQTT/mqtt.cpp
// Function: main
int main(void){
    
    Broker* broker = Broker::getInstance();

    //ParametrosDelSimClient {Parametro, Subscriptor?, Valor, error, Retener valor, tiempo de ejec}
    usr_pass a_z("\033[1;31mandres\033[0m", "ziemecki");
    ParametrosDelSimClient p1 = {"Presion", false, 1000, 100, true, 15};
    SimPublisher andy(*broker, a_z);
    andy.start(p1);

    this_thread::sleep_for (std::chrono::seconds(2));

    usr_pass h_f("\033[1;36mHoracio\033[0m", "Fontanini");
    ParametrosDelSimClient p3 = {"Temperatura", false, 30, 10, false, 10};
    SimPublisher fonta(*broker, h_f);
    fonta.start(p3);

    usr_pass e_t("\033[1;32mEduardo\033[0m", "Tapia");
    ParametrosDelSimClient p2 = {"Presion", true};
    SimPublisher edu(*broker, e_t);
    edu.start(p2);

    this_thread::sleep_for (std::chrono::seconds(3));

    usr_pass d_b("\033[1;33mDario\033[0m", "Balmaceda");
    ParametrosDelSimClient p4 = {"Temperatura", true};
    SimPublisher dari(*broker, d_b);
    dari.start(p4);

    edu.SubscribeNewTopic("Temperatura");

    this_thread::sleep_for (std::chrono::seconds(5));

    edu.UnsuscribeTopic("Presion");
    edu.UnsuscribeTopic("Presion");
    edu.UnsuscribeTopic("Temperatura");

    this_thread::sleep_for (std::chrono::seconds(2));

    // dari.UnsuscribeTopic("Temperatura");
    edu.Disconnect();
    dari.Disconnect();

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x950, %rsp            # imm = 0x950
movl $0x0, -0x4(%rbp)
callq 0x4330
movq %rax, -0x10(%rbp)
leaq -0x71(%rbp), %rdi
movq %rdi, -0x8c8(%rbp)
callq 0x3350
movq -0x8c8(%rbp), %rdx
leaq 0xe98f(%rip), %rsi      # 0x12038
leaq -0x70(%rbp), %rdi
callq 0x3280
jmp 0x36b4
leaq -0xa9(%rbp), %rdi
movq %rdi, -0x8d0(%rbp)
callq 0x3350
movq -0x8d0(%rbp), %rdx
leaq 0xe975(%rip), %rsi      # 0x1204a
leaq -0xa8(%rbp), %rdi
callq 0x3280
jmp 0x36e3
leaq -0x50(%rbp), %rdi
leaq -0x70(%rbp), %rsi
leaq -0xa8(%rbp), %rdx
callq 0x70c0
jmp 0x36f9
leaq -0xa8(%rbp), %rdi
callq 0x3160
leaq -0xa9(%rbp), %rdi
callq 0x3230
leaq -0x70(%rbp), %rdi
callq 0x3160
leaq -0x71(%rbp), %rdi
callq 0x3230
leaq -0x109(%rbp), %rdi
movq %rdi, -0x8d8(%rbp)
callq 0x3350
movq -0x8d8(%rbp), %rdx
leaq 0xe90f(%rip), %rsi      # 0x12053
leaq -0x108(%rbp), %rdi
callq 0x3280
jmp 0x3752
movq %rsp, %rax
movl $0xf, (%rax)
leaq -0xe8(%rbp), %rdi
leaq -0x108(%rbp), %rsi
xorl %edx, %edx
movl $0x3e8, %ecx            # imm = 0x3E8
movl $0x64, %r8d
movl $0x1, %r9d
callq 0x34c0
jmp 0x3783
leaq -0x108(%rbp), %rdi
callq 0x3160
leaq -0x109(%rbp), %rdi
callq 0x3230
movq -0x10(%rbp), %rsi
leaq -0x210(%rbp), %rdi
leaq -0x50(%rbp), %rdx
callq 0x6400
jmp 0x37b1
leaq -0x210(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x43a0
jmp 0x37c6
movl $0x2, -0x21c(%rbp)
leaq -0x218(%rbp), %rdi
leaq -0x21c(%rbp), %rsi
callq 0x71d0
jmp 0x37e5
leaq -0x218(%rbp), %rdi
callq 0x7120
jmp 0x37f3
leaq -0x281(%rbp), %rdi
movq %rdi, -0x8e0(%rbp)
callq 0x3350
movq -0x8e0(%rbp), %rdx
leaq 0xe847(%rip), %rsi      # 0x1205b
leaq -0x280(%rbp), %rdi
callq 0x3280
jmp 0x3822
leaq -0x2a9(%rbp), %rdi
movq %rdi, -0x8e8(%rbp)
callq 0x3350
movq -0x8e8(%rbp), %rdx
leaq 0xe82b(%rip), %rsi      # 0x1206e
leaq -0x2a8(%rbp), %rdi
callq 0x3280
jmp 0x3851
leaq -0x260(%rbp), %rdi
leaq -0x280(%rbp), %rsi
leaq -0x2a8(%rbp), %rdx
callq 0x70c0
jmp 0x386d
leaq -0x2a8(%rbp), %rdi
callq 0x3160
leaq -0x2a9(%rbp), %rdi
callq 0x3230
leaq -0x280(%rbp), %rdi
callq 0x3160
leaq -0x281(%rbp), %rdi
callq 0x3230
leaq -0x309(%rbp), %rdi
movq %rdi, -0x8f0(%rbp)
callq 0x3350
movq -0x8f0(%rbp), %rdx
leaq 0xe7ba(%rip), %rsi      # 0x12078
leaq -0x308(%rbp), %rdi
callq 0x3280
jmp 0x38cc
movq %rsp, %rax
movl $0xa, (%rax)
leaq -0x2e8(%rbp), %rdi
leaq -0x308(%rbp), %rsi
movl $0x1e, %ecx
movl $0xa, %r8d
xorl %r9d, %r9d
movl %r9d, %edx
callq 0x34c0
jmp 0x38fb
leaq -0x308(%rbp), %rdi
callq 0x3160
leaq -0x309(%rbp), %rdi
callq 0x3230
movq -0x10(%rbp), %rsi
leaq -0x410(%rbp), %rdi
leaq -0x260(%rbp), %rdx
callq 0x6400
jmp 0x392c
leaq -0x410(%rbp), %rdi
leaq -0x2e8(%rbp), %rsi
callq 0x43a0
jmp 0x3941
leaq -0x471(%rbp), %rdi
movq %rdi, -0x8f8(%rbp)
callq 0x3350
movq -0x8f8(%rbp), %rdx
leaq 0xe722(%rip), %rsi      # 0x12084
leaq -0x470(%rbp), %rdi
callq 0x3280
jmp 0x3970
leaq -0x499(%rbp), %rdi
movq %rdi, -0x900(%rbp)
callq 0x3350
movq -0x900(%rbp), %rdx
leaq 0xe706(%rip), %rsi      # 0x12097
leaq -0x498(%rbp), %rdi
callq 0x3280
jmp 0x399f
leaq -0x450(%rbp), %rdi
leaq -0x470(%rbp), %rsi
leaq -0x498(%rbp), %rdx
callq 0x70c0
jmp 0x39bb
leaq -0x498(%rbp), %rdi
callq 0x3160
leaq -0x499(%rbp), %rdi
callq 0x3230
leaq -0x470(%rbp), %rdi
callq 0x3160
leaq -0x471(%rbp), %rdi
callq 0x3230
leaq -0x4f9(%rbp), %rdi
movq %rdi, -0x908(%rbp)
callq 0x3350
movq -0x908(%rbp), %rdx
leaq 0xe647(%rip), %rsi      # 0x12053
leaq -0x4f8(%rbp), %rdi
callq 0x3280
jmp 0x3a1a
movq %rsp, %rax
movl $0xa, (%rax)
leaq -0x4d8(%rbp), %rdi
leaq -0x4f8(%rbp), %rsi
movl $0x1, %edx
xorl %r9d, %r9d
movl %r9d, %ecx
movl %r9d, %r8d
callq 0x34c0
jmp 0x3a46
leaq -0x4f8(%rbp), %rdi
callq 0x3160
leaq -0x4f9(%rbp), %rdi
callq 0x3230
movq -0x10(%rbp), %rsi
leaq -0x600(%rbp), %rdi
leaq -0x450(%rbp), %rdx
callq 0x6400
jmp 0x3a77
leaq -0x600(%rbp), %rdi
leaq -0x4d8(%rbp), %rsi
callq 0x43a0
jmp 0x3a8c
movl $0x3, -0x60c(%rbp)
leaq -0x608(%rbp), %rdi
leaq -0x60c(%rbp), %rsi
callq 0x71d0
jmp 0x3aab
leaq -0x608(%rbp), %rdi
callq 0x7120
jmp 0x3ab9
leaq -0x671(%rbp), %rdi
movq %rdi, -0x910(%rbp)
callq 0x3350
movq -0x910(%rbp), %rdx
leaq 0xe5c3(%rip), %rsi      # 0x1209d
leaq -0x670(%rbp), %rdi
callq 0x3280
jmp 0x3ae8
leaq -0x699(%rbp), %rdi
movq %rdi, -0x918(%rbp)
callq 0x3350
movq -0x918(%rbp), %rdx
leaq 0xe5a5(%rip), %rsi      # 0x120ae
leaq -0x698(%rbp), %rdi
callq 0x3280
jmp 0x3b17
leaq -0x650(%rbp), %rdi
leaq -0x670(%rbp), %rsi
leaq -0x698(%rbp), %rdx
callq 0x70c0
jmp 0x3b33
leaq -0x698(%rbp), %rdi
callq 0x3160
leaq -0x699(%rbp), %rdi
callq 0x3230
leaq -0x670(%rbp), %rdi
callq 0x3160
leaq -0x671(%rbp), %rdi
callq 0x3230
leaq -0x6f9(%rbp), %rdi
movq %rdi, -0x920(%rbp)
callq 0x3350
movq -0x920(%rbp), %rdx
leaq 0xe4f4(%rip), %rsi      # 0x12078
leaq -0x6f8(%rbp), %rdi
callq 0x3280
jmp 0x3b92
movq %rsp, %rax
movl $0xa, (%rax)
leaq -0x6d8(%rbp), %rdi
leaq -0x6f8(%rbp), %rsi
movl $0x1, %edx
xorl %r9d, %r9d
movl %r9d, %ecx
movl %r9d, %r8d
callq 0x34c0
jmp 0x3bbe
leaq -0x6f8(%rbp), %rdi
callq 0x3160
leaq -0x6f9(%rbp), %rdi
callq 0x3230
movq -0x10(%rbp), %rsi
leaq -0x800(%rbp), %rdi
leaq -0x650(%rbp), %rdx
callq 0x6400
jmp 0x3bef
leaq -0x800(%rbp), %rdi
leaq -0x6d8(%rbp), %rsi
callq 0x43a0
jmp 0x3c04
leaq -0x821(%rbp), %rdi
movq %rdi, -0x928(%rbp)
callq 0x3350
movq -0x928(%rbp), %rdx
leaq 0xe453(%rip), %rsi      # 0x12078
leaq -0x820(%rbp), %rdi
callq 0x3280
jmp 0x3c33
leaq -0x600(%rbp), %rdi
leaq -0x820(%rbp), %rsi
callq 0x4410
jmp 0x3c48
leaq -0x820(%rbp), %rdi
callq 0x3160
leaq -0x821(%rbp), %rdi
callq 0x3230
movl $0x5, -0x834(%rbp)
leaq -0x830(%rbp), %rdi
leaq -0x834(%rbp), %rsi
callq 0x71d0
jmp 0x3c7f
leaq -0x830(%rbp), %rdi
callq 0x7120
jmp 0x3c8d
leaq -0x859(%rbp), %rdi
movq %rdi, -0x930(%rbp)
callq 0x3350
movq -0x930(%rbp), %rdx
leaq 0xe3a5(%rip), %rsi      # 0x12053
leaq -0x858(%rbp), %rdi
callq 0x3280
jmp 0x3cbc
leaq -0x600(%rbp), %rdi
leaq -0x858(%rbp), %rsi
callq 0x4520
jmp 0x3cd1
leaq -0x858(%rbp), %rdi
callq 0x3160
leaq -0x859(%rbp), %rdi
callq 0x3230
leaq -0x881(%rbp), %rdi
movq %rdi, -0x938(%rbp)
callq 0x3350
movq -0x938(%rbp), %rdx
leaq 0xe349(%rip), %rsi      # 0x12053
leaq -0x880(%rbp), %rdi
callq 0x3280
jmp 0x3d18
leaq -0x600(%rbp), %rdi
leaq -0x880(%rbp), %rsi
callq 0x4520
jmp 0x3d2d
leaq -0x880(%rbp), %rdi
callq 0x3160
leaq -0x881(%rbp), %rdi
callq 0x3230
leaq -0x8a9(%rbp), %rdi
movq %rdi, -0x940(%rbp)
callq 0x3350
movq -0x940(%rbp), %rdx
leaq 0xe312(%rip), %rsi      # 0x12078
leaq -0x8a8(%rbp), %rdi
callq 0x3280
jmp 0x3d74
leaq -0x600(%rbp), %rdi
leaq -0x8a8(%rbp), %rsi
callq 0x4520
jmp 0x3d89
leaq -0x8a8(%rbp), %rdi
callq 0x3160
leaq -0x8a9(%rbp), %rdi
callq 0x3230
movl $0x2, -0x8bc(%rbp)
leaq -0x8b8(%rbp), %rdi
leaq -0x8bc(%rbp), %rsi
callq 0x71d0
jmp 0x3dc0
leaq -0x8b8(%rbp), %rdi
callq 0x7120
jmp 0x3dce
leaq -0x600(%rbp), %rdi
callq 0x45d0
jmp 0x3ddc
leaq -0x800(%rbp), %rdi
callq 0x45d0
jmp 0x3dea
movl $0x0, -0x4(%rbp)
leaq -0x800(%rbp), %rdi
callq 0x64a0
leaq -0x6d8(%rbp), %rdi
callq 0x71f0
leaq -0x650(%rbp), %rdi
callq 0x7210
leaq -0x600(%rbp), %rdi
callq 0x64a0
leaq -0x4d8(%rbp), %rdi
callq 0x71f0
leaq -0x450(%rbp), %rdi
callq 0x7210
leaq -0x410(%rbp), %rdi
callq 0x64a0
leaq -0x2e8(%rbp), %rdi
callq 0x71f0
leaq -0x260(%rbp), %rdi
callq 0x7210
leaq -0x210(%rbp), %rdi
callq 0x64a0
leaq -0xe8(%rbp), %rdi
callq 0x71f0
leaq -0x50(%rbp), %rdi
callq 0x7210
movl -0x4(%rbp), %eax
addq $0x950, %rsp            # imm = 0x950
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x3edc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x3ec7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x3160
leaq -0xa9(%rbp), %rdi
callq 0x3230
leaq -0x70(%rbp), %rdi
callq 0x3160
leaq -0x71(%rbp), %rdi
callq 0x3230
jmp 0x4326
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x3f16
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x3160
leaq -0x109(%rbp), %rdi
callq 0x3230
jmp 0x431d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x4311
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x4305
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x3fa4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x3f8c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x2a8(%rbp), %rdi
callq 0x3160
leaq -0x2a9(%rbp), %rdi
callq 0x3230
leaq -0x280(%rbp), %rdi
callq 0x3160
leaq -0x281(%rbp), %rdi
callq 0x3230
jmp 0x4305
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x3fe1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x308(%rbp), %rdi
callq 0x3160
leaq -0x309(%rbp), %rdi
callq 0x3230
jmp 0x42f9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x42ed
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x42e1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x406f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x4057
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x498(%rbp), %rdi
callq 0x3160
leaq -0x499(%rbp), %rdi
callq 0x3230
leaq -0x470(%rbp), %rdi
callq 0x3160
leaq -0x471(%rbp), %rdi
callq 0x3230
jmp 0x42e1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x40ac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x4f8(%rbp), %rdi
callq 0x3160
leaq -0x4f9(%rbp), %rdi
callq 0x3230
jmp 0x42d5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x42c9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x42bd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x413a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x4122
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x698(%rbp), %rdi
callq 0x3160
leaq -0x699(%rbp), %rdi
callq 0x3230
leaq -0x670(%rbp), %rdi
callq 0x3160
leaq -0x671(%rbp), %rdi
callq 0x3230
jmp 0x42bd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x4177
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x6f8(%rbp), %rdi
callq 0x3160
leaq -0x6f9(%rbp), %rdi
callq 0x3230
jmp 0x42b1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x42a5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x4299
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x41dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x820(%rbp), %rdi
callq 0x3160
leaq -0x821(%rbp), %rdi
callq 0x3230
jmp 0x4299
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x4219
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x858(%rbp), %rdi
callq 0x3160
leaq -0x859(%rbp), %rdi
callq 0x3230
jmp 0x4299
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x4253
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x880(%rbp), %rdi
callq 0x3160
leaq -0x881(%rbp), %rdi
callq 0x3230
jmp 0x4299
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x428d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x8a8(%rbp), %rdi
callq 0x3160
leaq -0x8a9(%rbp), %rdi
callq 0x3230
leaq -0x800(%rbp), %rdi
callq 0x64a0
leaq -0x6d8(%rbp), %rdi
callq 0x71f0
leaq -0x650(%rbp), %rdi
callq 0x7210
leaq -0x600(%rbp), %rdi
callq 0x64a0
leaq -0x4d8(%rbp), %rdi
callq 0x71f0
leaq -0x450(%rbp), %rdi
callq 0x7210
leaq -0x410(%rbp), %rdi
callq 0x64a0
leaq -0x2e8(%rbp), %rdi
callq 0x71f0
leaq -0x260(%rbp), %rdi
callq 0x7210
leaq -0x210(%rbp), %rdi
callq 0x64a0
leaq -0xe8(%rbp), %rdi
callq 0x71f0
leaq -0x50(%rbp), %rdi
callq 0x7210
movq -0x80(%rbp), %rdi
callq 0x3340
nop