// File: /workspace/github_cpp_makefile_star2_O3/Unreality3D[P]Unreality3D/indie-studio/source/Network/Broker.cpp
// Function: network::Broker::onPacketMessage(int, IndieProtocol::Message)
void	Broker::onPacketMessage(int fd, IndieProtocol::Message msg)
  {
    std::cout << "FD : " << fd << " : MESSAGE" << std::endl;
    std::cout << msg.target << std::endl;
    std::cout << msg.topic << std::endl;
    std::cout << msg.event << std::endl;

    auto from = _clients.find(fd);
    if (from == _clients.end() || !(*from).second.connected)
      {
	std::cout << "FROM client not connected. Not forwarding the message" << std::endl;
	return ;
      }

    IndieProtocol::Serialized serialed = _serializer(msg);

    // broadcast
    if (msg.target == "")
      {
	IndieProtocol::Serialized tmpSerialed;
	for (auto c = _clients.begin(); c != _clients.end(); ++c)
	  {
	    if ((*c).second.connected && (*c).second.fd != fd)
	      {
		std::cout << "Forwarding to " << (*c).second.name << std::endl;
		tmpSerialed = serialed;
		(*c).second.writeBuffer.push_back(tmpSerialed);
	      }
	  }
      }
    else
      {
	auto c = std::find_if(_clients.begin(), _clients.end(),
			      [&msg](std::pair<SOCKET, Client> const &elem)
			      {
				return (elem.second.name == msg.target && elem.second.connected);
			      });
	if (c != _clients.end())
	  {
	    std::cout << "Forwarding to " << (*c).second.name << std::endl;
	    (*c).second.writeBuffer.push_back(serialed);
	  }
      }
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rdx, %r14
movl %esi, %ebx
movq %rdi, %r15
movq 0xb652(%rip), %r12      # 0x1afb8
leaq 0x5948(%rip), %rsi      # 0x152b5
movl $0x5, %edx
movq %r12, %rdi
callq 0xb870
movq %r12, %rdi
movl %ebx, %esi
callq 0xbc80
movq %rax, %r13
leaq 0x5940(%rip), %rsi      # 0x152ce
movl $0xa, %edx
movq %rax, %rdi
callq 0xb870
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0xb750
movsbl %al, %esi
movq %r13, %rdi
callq 0xb040
movq %rax, %rdi
callq 0xb540
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq %r12, %rdi
callq 0xb870
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0xb750
movsbl %al, %esi
movq %r13, %rdi
callq 0xb040
movq %rax, %rdi
callq 0xb540
movq 0x20(%r14), %rsi
movq 0x28(%r14), %rdx
movq %r12, %rdi
callq 0xb870
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0xb750
movsbl %al, %esi
movq %r13, %rdi
callq 0xb040
movq %rax, %rdi
callq 0xb540
movq 0x40(%r14), %rsi
movq 0x48(%r14), %rdx
movq %r12, %rdi
callq 0xb870
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0xb750
movsbl %al, %esi
movq %r13, %rdi
callq 0xb040
movq %rax, %rdi
callq 0xb540
movq 0x190(%r15), %rcx
testq %rcx, %rcx
je 0xfbd2
leaq 0x188(%r15), %r13
movq %r13, %rax
xorl %edx, %edx
cmpl %ebx, 0x20(%rcx)
setl %dl
cmovgeq %rcx, %rax
movq 0x10(%rcx,%rdx,8), %rcx
testq %rcx, %rcx
jne 0xfa8a
cmpq %r13, %rax
je 0xfbd2
cmpl %ebx, 0x20(%rax)
jg 0xfbd2
cmpb $0x0, 0x28(%rax)
je 0xfbd2
movq %rsp, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0xbda0
leaq 0x57e9(%rip), %rsi      # 0x152ba
movq %r14, %rdi
callq 0xb170
testl %eax, %eax
je 0xfc1f
movq 0x198(%r15), %rbx
cmpq %r13, %rbx
je 0xfb5c
leaq 0x10(%rsp), %r12
leaq 0x20(%rbx), %rsi
movq %r12, %rdi
callq 0xb260
movq 0x28(%rsp), %rdx
cmpq 0x8(%r14), %rdx
jne 0xfb23
testq %rdx, %rdx
je 0xfb2f
movq (%r14), %rsi
movq 0x20(%rsp), %rdi
callq 0xb800
testl %eax, %eax
sete %bpl
jmp 0xfb32
leaq 0x18(%rsp), %rdi
callq 0xb8c0
jmp 0xfb4c
movb $0x1, %bpl
movb 0x18(%rsp), %r15b
leaq 0x18(%rsp), %rdi
callq 0xb8c0
testb %bpl, %bpl
je 0xfb4c
testb $0x1, %r15b
jne 0xfb5c
movq %rbx, %rdi
callq 0xb570
movq %rax, %rbx
cmpq %r13, %rax
jne 0xfaf2
cmpq %r13, %rbx
je 0xfd23
movq 0xb44c(%rip), %rdi      # 0x1afb8
leaq 0x579c(%rip), %rsi      # 0x1530f
movl $0xe, %edx
callq 0xb870
movq 0x30(%rbx), %rsi
movq 0x38(%rbx), %rdx
movq 0xb42c(%rip), %rdi      # 0x1afb8
callq 0xb870
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0xb750
movsbl %al, %esi
movq %r14, %rdi
callq 0xb040
movq %rax, %rdi
callq 0xb540
addq $0xe0, %rbx
movq %rsp, %rsi
movq %rbx, %rdi
callq 0xb3c0
jmp 0xfd23
leaq 0x5700(%rip), %rsi      # 0x152d9
movl $0x35, %edx
movq %r12, %rdi
callq 0xb870
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0xb750
movsbl %al, %esi
movq %r12, %rdi
callq 0xb040
movq %rax, %rdi
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xb540
movl $0x0, 0x10(%rsp)
movl $0x1, %edi
callq 0xb030
movq %rax, 0x18(%rsp)
movq 0x198(%r15), %r14
cmpq %r13, %r14
je 0xfd1b
movq 0xb36b(%rip), %r15      # 0x1afb8
leaq 0x10(%rsp), %r12
cmpb $0x1, 0x28(%r14)
jne 0xfcfd
cmpl %ebx, 0x2c(%r14)
je 0xfcfd
movl $0xe, %edx
movq %r15, %rdi
leaq 0x5699(%rip), %rsi      # 0x1530f
callq 0xb870
movq 0x30(%r14), %rsi
movq 0x38(%r14), %rdx
movq %r15, %rdi
callq 0xb870
movq %rax, %rbp
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0xb750
movsbl %al, %esi
movq %rbp, %rdi
callq 0xb040
movq %rax, %rdi
callq 0xb540
movl (%rsp), %eax
movl %eax, 0x10(%rsp)
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0xfccf
callq 0xb990
movl 0x10(%rsp), %eax
movl %eax, %ebp
movq %rbp, %rdi
callq 0xb030
movq %rax, 0x18(%rsp)
movq 0x8(%rsp), %rsi
movq %rax, %rdi
movq %rbp, %rdx
callq 0xb670
leaq 0xe0(%r14), %rdi
movq %r12, %rsi
callq 0xb3c0
movq %r14, %rdi
callq 0xb570
movq %rax, %r14
cmpq %r13, %rax
jne 0xfc52
movq 0x18(%rsp), %rax
testq %rax, %rax
je 0xfd23
movq %rax, %rdi
callq 0xb990
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0xfd32
callq 0xb990
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xfd48
jmp 0xfd48
movq %rax, %rbx
jmp 0xfd5f
movq %rax, %rbx
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0xfd5f
callq 0xb990
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0xfd6e
callq 0xb990
movq %rbx, %rdi
callq 0xbce0