// File: /workspace/github_cpp_makefile_star2_O2/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, %r14
movl %edi, %ebp
movq 0x4528(%rip), %rbx      # 0x6fd0
leaq 0x16bc(%rip), %rsi      # 0x416b
movq %rbx, %rdi
callq 0x21c0
movq %rax, %rdi
movq %r14, %rsi
callq 0x21c0
leaq 0x16ba(%rip), %rsi      # 0x4183
movq %rax, %rdi
callq 0x21c0
movq %rax, %rdi
movl %ebp, %esi
callq 0x22c0
movq %rax, %rdi
callq 0x2100
leaq 0x46d6(%rip), %rdi      # 0x71c0
movq %r14, %rsi
callq 0x3310
movq 0x46c7(%rip), %r14      # 0x71c0
movq 0x46c8(%rip), %rbp      # 0x71c8
leaq 0x18(%rsp), %r15
leaq 0x167e(%rip), %r12      # 0x418a
leaq 0x16a6(%rip), %r13      # 0x41b9
cmpq %rbp, %r14
je 0x2b52
movq %r15, %rdi
movq %r14, %rsi
callq 0x2240
movq %rbx, %rdi
movq %r12, %rsi
callq 0x21c0
movq %rax, %rdi
movq %r15, %rsi
callq 0x21a0
movq %rax, %rdi
movq %r13, %rsi
callq 0x21c0
movq %r15, %rdi
callq 0x20e0
addq $0x20, %r14
jmp 0x2b13
leaq 0x28(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x4656(%rip), %rdi      # 0x71c0
xorl %esi, %esi
callq 0x2d4a
leaq 0x18(%rsp), %rdi
movq %rax, %rsi
callq 0x2130
andq $0x0, 0x8(%rsp)
leaq 0x38(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x2240
leaq 0x463e(%rip), %rdi      # 0x71d8
leaq 0x38(%rsp), %rsi
leaq 0x8(%rsp), %rdx
callq 0x2d85
movl %eax, %ebx
leaq 0x38(%rsp), %rdi
callq 0x20e0
testb %bl, %bl
je 0x2bd9
movq 0x8(%rsp), %rsi
leaq 0x1602(%rip), %rdi      # 0x41c7
xorl %eax, %eax
callq 0x2040
leaq 0x45ed(%rip), %rdi      # 0x71c0
callq *0x8(%rsp)
jmp 0x2c08
movq 0x4410(%rip), %rdi      # 0x6ff0
leaq 0x1604(%rip), %rsi      # 0x41eb
callq 0x21c0
leaq 0x18(%rsp), %rsi
movq %rax, %rdi
callq 0x21a0
leaq 0x1610(%rip), %rsi      # 0x4210
movq %rax, %rdi
callq 0x21c0
leaq 0x45b1(%rip), %rdi      # 0x71c0
callq 0x2dd8
leaq 0x18(%rsp), %rdi
callq 0x20e0
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x20e0
jmp 0x2cb3
movq %rax, %rbx
cmpl $0x1, %edx
jne 0x2cb3
movq %rbx, %rdi
callq 0x2210
leaq 0x8(%rsp), %rdi
movq %rax, %rsi
callq 0x2d6c
movq %rbx, %rdi
callq 0x20c0
movq 0x4388(%rip), %rdi      # 0x6ff0
leaq 0x154e(%rip), %rsi      # 0x41bd
callq 0x21c0
movq %rax, %rdi
callq 0x2100
leaq 0x8(%rsp), %rdi
callq 0x2250
callq 0x22a0
jmp 0x2b7e
jmp 0x2cb0
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x2250
callq 0x22a0
jmp 0x2cb3
movq %rax, %rdi
callq 0x299b
jmp 0x2cb0
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x20e0
movq %rbx, %rdi
callq 0x22e0