// File: /workspace/github_cpp_makefile_star2_O1/Gydo194[P]server/controller/controller.cpp
// Function: Controller::handleServerInput(unsigned short, char*)
void Controller::handleServerInput(uint16_t fd, char *buffer)
{
	cout << "Controller: got input '" << buffer << "'from " << fd << endl;
	prs.parse(buffer);
	for(string i : prs.values)
	{
		cout << "Controller::handleServerInput -> for: input: '" << i << "'.\n";
	}


	//get the first argument name
	string key;
	try
	{
		key = prs.values.at(0);
	}
	catch(out_of_range oor)
	{
		cerr << "no action" << endl;
	}

	//look it up in the handlers map
	Controller::handler h = NULL;
	if(map_get<string,Controller::handler>(&handlers, key, &h))
	{
		printf("Controller: handler address = '%x'\n",h);
		//call the callback function
		h(&prs.values);
	}
	else
	{
		cerr << "[ERROR] Controller: No such action (" << key << ")\n";
	}

	prs.values.clear();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rsi, %rbx
movl %edi, %ebp
movq 0x42c2(%rip), %r14      # 0x6fd0
leaq 0x1480(%rip), %rsi      # 0x4195
movl $0x17, %edx
movq %r14, %rdi
callq 0x2210
testq %rbx, %rbx
je 0x2d43
movq %rbx, %rdi
callq 0x20f0
movq 0x429a(%rip), %rdi      # 0x6fd0
movq %rbx, %rsi
movq %rax, %rdx
callq 0x2210
jmp 0x2d5b
movq (%r14), %rax
movq -0x18(%rax), %rax
leaq (%r14,%rax), %rdi
movl 0x20(%r14,%rax), %esi
orl $0x1, %esi
callq 0x22d0
movq 0x426e(%rip), %r14      # 0x6fd0
leaq 0x1444(%rip), %rsi      # 0x41ad
movl $0x6, %edx
movq %r14, %rdi
callq 0x2210
movzwl %bp, %esi
movq %r14, %rdi
callq 0x2140
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2150
leaq 0x440e(%rip), %rdi      # 0x71c0
movq %rbx, %rsi
callq 0x366c
movq 0x43ff(%rip), %r13      # 0x71c0
movq 0x4400(%rip), %rbp      # 0x71c8
cmpq %rbp, %r13
je 0x2e57
leaq 0x18(%rsp), %rbx
movq 0x41f3(%rip), %r14      # 0x6fd0
leaq 0x13d0(%rip), %r15      # 0x41b4
leaq 0x13f8(%rip), %r12      # 0x41e3
movq %rbx, 0x8(%rsp)
movq (%r13), %rsi
movq 0x8(%r13), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %rdi
callq 0x2bac
movl $0x2e, %edx
movq %r14, %rdi
movq %r15, %rsi
callq 0x2210
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %r14, %rdi
callq 0x2210
movl $0x3, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2210
movq 0x8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x2e4e
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21e0
addq $0x20, %r13
cmpq %rbp, %r13
jne 0x2deb
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
movq $0x0, -0x8(%r15)
movb $0x0, (%r15)
movq 0x434d(%rip), %rsi      # 0x71c0
cmpq %rsi, 0x434e(%rip)      # 0x71c8
je 0x2f81
leaq 0x8(%rsp), %rdi
callq 0x2130
movq $0x0, 0x28(%rsp)
leaq 0x48(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
leaq 0x38(%rsp), %rdi
callq 0x2bac
leaq 0x431e(%rip), %rdi      # 0x71d8
leaq 0x38(%rsp), %rsi
leaq 0x28(%rsp), %rdx
callq 0x3167
movl %eax, %ebx
movq 0x38(%rsp), %rdi
cmpq %r14, %rdi
je 0x2ee2
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x21e0
testb %bl, %bl
je 0x2f06
movq 0x28(%rsp), %rsi
leaq 0x12ff(%rip), %rdi      # 0x41f1
xorl %eax, %eax
callq 0x2050
leaq 0x42c0(%rip), %rdi      # 0x71c0
callq *0x28(%rsp)
jmp 0x2f48
movq 0x40e3(%rip), %rdi      # 0x6ff0
leaq 0x1301(%rip), %rsi      # 0x4215
movl $0x24, %edx
callq 0x2210
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x40c1(%rip), %rdi      # 0x6ff0
callq 0x2210
leaq 0x12ff(%rip), %rsi      # 0x423a
movl $0x2, %edx
movq %rax, %rdi
callq 0x2210
movq 0x4271(%rip), %rsi      # 0x71c0
leaq 0x426a(%rip), %rdi      # 0x71c0
callq 0x32f4
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x2f72
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21e0
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x12d5(%rip), %rdi      # 0x425d
xorl %esi, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x2280
movq %rax, %r12
movq 0x38(%rsp), %rdi
cmpq %r14, %rdi
je 0x3049
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x21e0
jmp 0x3049
movq %rax, %r12
cmpl $0x1, %edx
jne 0x3049
movq %r12, %rdi
callq 0x2220
leaq 0x28(%rsp), %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x22b0
movq 0x3fdf(%rip), %rax      # 0x6fc0
addq $0x10, %rax
movq %rax, (%r14)
movq %r12, %rdi
callq 0x20e0
movq 0x3ff9(%rip), %rdi      # 0x6ff0
leaq 0x11e9(%rip), %rsi      # 0x41e7
movl $0x9, %edx
callq 0x2210
movq 0x3fe1(%rip), %rdi      # 0x6ff0
callq 0x2100
leaq 0x28(%rsp), %rdi
callq 0x2240
callq 0x22a0
jmp 0x2e8a
jmp 0x3046
movq %rax, %r12
leaq 0x28(%rsp), %rdi
callq 0x2240
callq 0x22a0
jmp 0x3049
movq %rax, %rdi
callq 0x2abb
movq %rax, %r12
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
jne 0x3062
jmp 0x306f
movq %rax, %r12
movq 0x8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x306f
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21e0
movq %r12, %rdi
callq 0x22e0