// File: /workspace/github_cpp_makefile_star2_O2/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 $0xf8, %rsp
movq %rdx, %rbx
movl %esi, %ebp
movq %rdi, %r14
leaq 0xc(%rsp), %r15
movl %esi, (%r15)
movq 0xbafe(%rip), %r12      # 0x1efb8
leaq 0x4db3(%rip), %rsi      # 0x18274
movq %r12, %rdi
callq 0xfb10
movq %rax, %rdi
movl %ebp, %esi
callq 0x10280
leaq 0x4db3(%rip), %rsi      # 0x1828d
movq %rax, %rdi
callq 0xfb10
movq %rax, %rdi
callq 0xf4c0
movq %r12, %rdi
movq %rbx, %rsi
callq 0xf9e0
movq %rax, %rdi
callq 0xf4c0
leaq 0x20(%rbx), %rsi
movq %r12, %rdi
callq 0xf9e0
movq %rax, %rdi
callq 0xf4c0
leaq 0x40(%rbx), %rsi
movq %r12, %rdi
callq 0xf9e0
movq %rax, %rdi
callq 0xf4c0
leaq 0x180(%r14), %rdi
movq %r15, %rsi
callq 0xf7f0
leaq 0x188(%r14), %r15
cmpq %r15, %rax
je 0x13609
cmpb $0x0, 0x28(%rax)
je 0x13609
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x103d0
leaq 0x4d14(%rip), %rsi      # 0x18279
movq %rbx, %rdi
callq 0x10500
testb %al, %al
je 0x13629
andl $0x0, 0x20(%rsp)
pushq $0x1
popq %rdi
callq 0xf030
leaq 0x20(%rsp), %rbx
movq %rax, 0x8(%rbx)
movq 0x198(%r14), %r12
movq 0xba1f(%rip), %r14      # 0x1efb8
leaq 0x4d2e(%rip), %rbp      # 0x182ce
leaq 0x10(%rsp), %r13
cmpq %r15, %r12
je 0x13680
cmpb $0x1, 0x28(%r12)
jne 0x135fc
movl 0x2c(%r12), %eax
cmpl 0xc(%rsp), %eax
je 0x135fc
movq %r14, %rdi
movq %rbp, %rsi
callq 0xfb10
leaq 0x30(%r12), %rsi
movq %rax, %rdi
callq 0xf9e0
movq %rax, %rdi
callq 0xf4c0
movq %rbx, %rdi
movq %r13, %rsi
callq 0xf350
leaq 0xe0(%r12), %rdi
movq %rbx, %rsi
callq 0xf560
movq %r12, %rdi
callq 0xf7c0
movq %rax, %r12
jmp 0x135a5
movq 0xb9a8(%rip), %rdi      # 0x1efb8
leaq 0x4c81(%rip), %rsi      # 0x18298
callq 0xfb10
movq %rax, %rdi
callq 0xf4c0
jmp 0x136d1
movq 0x198(%r14), %r14
leaq 0x20(%rsp), %r13
cmpq %r15, %r14
je 0x136c7
leaq 0x20(%r14), %rsi
movq %r13, %rdi
callq 0xf3c0
leaq 0x30(%rsp), %rdi
movq %rbx, %rsi
callq 0xf610
movl %eax, %ebp
movb 0x28(%rsp), %r12b
leaq 0x28(%rsp), %rdi
callq 0xfcc0
testb %bpl, %bpl
je 0x13673
testb $0x1, %r12b
jne 0x1368c
movq %r14, %rdi
callq 0xf7c0
movq %rax, %r14
jmp 0x13635
leaq 0x20(%rsp), %rdi
callq 0xf7b0
jmp 0x136c7
movq 0xb925(%rip), %rdi      # 0x1efb8
leaq 0x4c34(%rip), %rsi      # 0x182ce
callq 0xfb10
leaq 0x30(%r14), %rsi
movq %rax, %rdi
callq 0xf9e0
movq %rax, %rdi
callq 0xf4c0
addq $0xe0, %r14
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0xf560
leaq 0x10(%rsp), %rdi
callq 0xf7b0
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x136e7
jmp 0x136e7
movq %rax, %rbx
jmp 0x136f9
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0xf7b0
leaq 0x10(%rsp), %rdi
callq 0xf7b0
movq %rbx, %rdi
callq 0x102f0
nop