websocketServer.cpp 804 字节
Newer Older
L
libb 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35

#include <FFL_Netlib.hpp>
#include <net/websocket/FFL_WebSocketServer.hpp>

static void myExit(const char* args, void* userdata) {
	printf("cmd:myExit\n");

	FFL::ConsoleLoop* console =(FFL::ConsoleLoop*) userdata;
	FFL::WebSocketServer* webServer=(FFL::WebSocketServer*)console->getUserdata();
	webServer->stop();
	console->stop();
}

static CmdOption  myCmdOption[] = {	
	{ "exit",0,myExit,"exit process" },
	{ "quit",0,myExit,"exit process" },
	{ 0,0,0,0 }
};


int FFL_main() {	
	FFL_socketInit();
	
	FFL::WebSocketServer webServer("127.0.0.1",8800,NULL);	
	webServer.start(new FFL::ModuleThread("websocket"));

	FFL::ConsoleLoop console;
	console.setUserdata(&webServer);
	console.registeCommand(myCmdOption, 2);
	console.start(NULL);
	console.dumpUsage();
	console.eventLoop(NULL);	

	return 0;
}