Browse Source

代码统一更新库文件

game 1 month ago
parent
commit
7a27e2d4a3

BIN
webapi/dll/httplib.dll


BIN
webapi/dll/httplibd.dll


+ 2 - 0
webapi/dll/webcnf.ini

@@ -0,0 +1,2 @@
+[web]
+port=8002

BIN
webapi/dll/weblib.dll


BIN
webapi/dll/weblibd.dll


BIN
webapi/mgdb/lib/httplib.lib


BIN
webapi/mgdb/lib/httplibd.lib


+ 138 - 90
webapi/webapi/HttpSocket.cpp

@@ -123,17 +123,17 @@ bool HttpSocket::postmsg(std::function<void(std::string&)> funhttpmsg, std::map<
 			//玩家账号注册
 			if (itype == HTTPREGUSER)
 			{
-				strtojson = strtojson = regaccount(getdata);
+				strtojson = regaccount(getdata);
 			}
 			//更新玩家分数
 			else if (itype == HTTPUPDATEUSERSCORE)
 			{
-				strtojson = updateuserscore(getdata);
+				strtojson = updateuserscore(getdata, funhttpmsg);
 			}
 			//把玩家踢出游戏
 			else if (itype == HTTPADMINKICKUSER)
 			{
-				strtojson = adminhituser(getdata);
+				strtojson = adminhituser(getdata, funhttpmsg);
 			}
 			//管理员禁止管理员所属玩家
 			else if (itype == HTTPADMINPROHIBITUSER)
@@ -191,6 +191,7 @@ bool HttpSocket::postmsg(std::function<void(std::string&)> funhttpmsg, std::map<
 			}
 
 			funhttpmsg(strtojson);
+			return true;
 		}
 		else
 		{
@@ -212,12 +213,15 @@ bool HttpSocket::postmsg(std::function<void(std::string&)> funhttpmsg, std::map<
 				}
 			}
 			funhttpmsg(strtojson);
+			return true;
 		}
 	}
 	catch (std::exception& e)
 	{
 	}
 
+	std::string strerror{ "{\"error\":1}" };
+	funhttpmsg(strerror);
 	return true;
 }
 
@@ -916,7 +920,7 @@ std::string HttpSocket::regaccount(std::map<std::string, std::string> getdata)
 }
 
 //玩家更新分数
-std::string HttpSocket::updateuserscore(std::map<std::string, std::string> getdata)
+std::string HttpSocket::updateuserscore(std::map<std::string, std::string> getdata, std::function<void(std::string&)>& dofun)
 {
 	userscore tuserscore;
 	getvaluedata(getdata, tuserscore);
@@ -1011,14 +1015,15 @@ std::string HttpSocket::updateuserscore(std::map<std::string, std::string> getda
 	std::string strspreadername;
 	std::string strspreaderaccount;
 	std::string strspreaderip;
+	std::string strwebonlyuser{};
 
 	//商家送分
 	if (tuserscore.score < 0)
 	{
 		//可以赠送
 		if (vipscore + tuserscore.score >= 0)
-		{			
-
+		{
+			//用户不存在不减商家的分数
 			if (!firstuser->view()["score"] || !firstuser->view()["name"] || !firstuser->view()["account"] || !firstuser->view()["lastlogonip"] || !firstuser->view()["userid"])
 			{
 				strret = funclib::rettojson(11, "user is not exist");
@@ -1029,6 +1034,7 @@ std::string HttpSocket::updateuserscore(std::map<std::string, std::string> getda
 			strusername = firstuser->view()["name"].get_utf8().value.data();
 			struseraccount = firstuser->view()["account"].get_utf8().value.data();
 			struserip = firstuser->view()["lastlogonip"].get_utf8().value.data();
+			strwebonlyuser = firstuser->view()["webuser"].get_utf8().value.data();
 			iuserid = firstuser->view()["userid"].get_int64();
 
 			//减商家分数
@@ -1041,7 +1047,7 @@ std::string HttpSocket::updateuserscore(std::map<std::string, std::string> getda
 				return strret;
 			}
 
-			if (!retscore->view()["score"] || !retscore->view()["name"] || !retscore->view()["account"] || !retscore->view()["loginip"])
+			if (!retscore->view()["score"] || !retscore->view()["name"] || !retscore->view()["account"])
 			{
 				strret = funclib::rettojson(Err_AgentUpdateScoreFailed, "modify score erro1");
 				return strret;
@@ -1050,7 +1056,8 @@ std::string HttpSocket::updateuserscore(std::map<std::string, std::string> getda
 			beforespreaderscore = retscore->view()["score"].get_int64();
 			strspreadername = retscore->view()["name"].get_utf8().value.data();
 			strspreaderaccount = retscore->view()["account"].get_utf8().value.data();
-			strspreaderip = retscore->view()["loginip"].get_utf8().value.data();
+			if(retscore->view()["loginip"])
+				strspreaderip = retscore->view()["loginip"].get_utf8().value.data();
 
 			afterspreaderscore = beforespreaderscore + tuserscore.score;
 
@@ -1165,37 +1172,35 @@ std::string HttpSocket::updateuserscore(std::map<std::string, std::string> getda
 			return strret;
 		}
 
+		//如果玩家在线,从游戏中扣除
 		auto useroline = m_pplayuseronline->find_one(bsoncxx::builder::stream::document{} << "userid" << iuserid << bsoncxx::builder::stream::finalize);
-
-		auto loginoline = m_userloginonline->find_one(bsoncxx::builder::stream::document{} << "userid" << iuserid << bsoncxx::builder::stream::finalize);
-
-		if (loginoline && loginoline->view()["contextid"] && loginoline->view()["userip"])
 		{
 			//通知游戏更新分数
-			CMD_CS_C_UpdateScoreEx  tempUpdateScore;
-			ZeroMemory(&tempUpdateScore, sizeof(tempUpdateScore));
-			tempUpdateScore.dwUserID = iuserid;
-			tempUpdateScore.addscore = tuserscore.score;
-			std::string strloginip{};
-
-			tempUpdateScore.dwLoginContextID = loginoline->view()["contextid"].get_int64();
-			strloginip = loginoline->view()["userip"].get_utf8().value.data();
-			m_gamemsg(strloginip, &tempUpdateScore, sizeof(tempUpdateScore));
-		}
+			bool bfind = false;
+			std::string struserip{};
+			if (useroline && useroline->view()["serverid"] && useroline->view()["contextid"] && useroline->view()["userip"])
+			{
+				struserip = useroline->view()["userip"].get_utf8().value.data();
+				bfind = true;
+			}
 
-		if (useroline && useroline->view()["serverid"] && useroline->view()["contextid"] && useroline->view()["userip"])
-		{
-			//通知游戏更新分数
-			CMD_CS_C_UpdateScoreEx  tempUpdateScore;
-			ZeroMemory(&tempUpdateScore, sizeof(tempUpdateScore));
-			tempUpdateScore.dwUserID = iuserid;
-			tempUpdateScore.addscore = tuserscore.score;
-			std::string strloginip{};
-
-			tempUpdateScore.wgameserverid = useroline->view()["serverid"].get_int32();
-			tempUpdateScore.dwGameContextID = useroline->view()["contextid"].get_int64();
-			strloginip = useroline->view()["userip"].get_utf8().value.data();
-			m_gamemsg(strloginip, &tempUpdateScore, sizeof(tempUpdateScore));
+			if (bfind && m_gamemsg && !struserip.empty())
+			{
+				rapidjson::Document docgame;
+				docgame.SetObject();
+				rapidjson::Document::AllocatorType& allocatorgame = docgame.GetAllocator();
+				docgame.AddMember("agent", rapidjson::Value(strspreaderaccount.c_str(), allocatorgame), allocatorgame);
+				docgame.AddMember("user", rapidjson::Value(strwebonlyuser.c_str(), allocatorgame), allocatorgame);
+				docgame.AddMember("score", tuserscore.score * -1, allocatorgame);
+
+				weblib::httpinfo thttpinfo{};
+				thttpinfo.strurl = std::move(struserip);
+				thttpinfo.strtarget = "webapi/updatescore";
+				thttpinfo.strjson = funclib::doctojson(docgame);
+				m_gamemsg(thttpinfo, std::move(dofun));
+
+				return {};
+			}
 		}
 
 		strret = funclib::rettojson(-1, "ok");
@@ -1236,7 +1241,7 @@ std::string HttpSocket::updateuserscore(std::map<std::string, std::string> getda
 			return strret;
 		}
 
-		if (!userretscore->view()["score"] || !userretscore->view()["account"] || !userretscore->view()["lastlogonip"])
+		if (!userretscore->view()["score"] || !userretscore->view()["account"] || !userretscore->view()["lastlogonip"] || !userretscore->view()["webuser"])
 		{
 			strret = funclib::rettojson(Err_Player_LackInfo, "user is playing1");
 			return strret;
@@ -1262,6 +1267,7 @@ std::string HttpSocket::updateuserscore(std::map<std::string, std::string> getda
 		strusername = userretscore->view()["name"].get_utf8().value.data();
 		struseraccount = userretscore->view()["account"].get_utf8().value.data();
 		struserip = userretscore->view()["lastlogonip"].get_utf8().value.data();
+		strwebonlyuser = userretscore->view()["webuser"].get_utf8().value.data();
 
 		//商家不存在不能减用户的分
 		auto firstadmin = m_pvipuser->find_one(bsoncxx::builder::stream::document{} << "userid" << adminuserid << bsoncxx::builder::stream::finalize);
@@ -1370,39 +1376,35 @@ std::string HttpSocket::updateuserscore(std::map<std::string, std::string> getda
 		auto result = m_pusertradeinfo->insert_one(builder.view());
 
 
+		//如果玩家在线,从游戏中扣除
 		auto useroline = m_pplayuseronline->find_one(bsoncxx::builder::stream::document{} << "userid" << iuserid << bsoncxx::builder::stream::finalize);
-
-		auto loginoline = m_userloginonline->find_one(bsoncxx::builder::stream::document{} << "userid" << iuserid << bsoncxx::builder::stream::finalize);
-
-		if (loginoline && loginoline->view()["contextid"] && loginoline->view()["userip"])
 		{
 			//通知游戏更新分数
 			bool bfind = false;
-			CMD_CS_C_UpdateScoreEx  tempUpdateScore;
-			ZeroMemory(&tempUpdateScore, sizeof(tempUpdateScore));
-			tempUpdateScore.dwUserID = iuserid;
-			tempUpdateScore.addscore = tradescore * -1;
-			std::string strloginip{};
-
-			tempUpdateScore.dwLoginContextID = loginoline->view()["contextid"].get_int64();
-			strloginip = loginoline->view()["userip"].get_utf8().value.data();
-			m_gamemsg(strloginip, &tempUpdateScore, sizeof(tempUpdateScore));
-		}
+			std::string struserip{};
+			if (useroline && useroline->view()["serverid"] && useroline->view()["contextid"] && useroline->view()["userip"])
+			{
+				struserip = useroline->view()["userip"].get_utf8().value.data();
+				bfind = true;
+			}
 
-		if (useroline && useroline->view()["serverid"] && useroline->view()["contextid"] && useroline->view()["userip"])
-		{
-			//通知游戏更新分数
-			bool bfind = false;
-			CMD_CS_C_UpdateScoreEx  tempUpdateScore;
-			ZeroMemory(&tempUpdateScore, sizeof(tempUpdateScore));
-			tempUpdateScore.dwUserID = iuserid;
-			tempUpdateScore.addscore = tradescore * -1;
-			std::string strloginip{};
-
-			tempUpdateScore.wgameserverid = useroline->view()["serverid"].get_int32();
-			tempUpdateScore.dwGameContextID = useroline->view()["contextid"].get_int64();
-			strloginip = useroline->view()["userip"].get_utf8().value.data();
-			m_gamemsg(strloginip, &tempUpdateScore, sizeof(tempUpdateScore));
+			if (bfind && m_gamemsg && !struserip.empty())
+			{
+				rapidjson::Document docgame;
+				docgame.SetObject();
+				rapidjson::Document::AllocatorType& allocatorgame = docgame.GetAllocator();
+				docgame.AddMember("agent", rapidjson::Value(strspreaderaccount.c_str(), allocatorgame), allocatorgame);
+				docgame.AddMember("user", rapidjson::Value(strwebonlyuser.c_str(), allocatorgame), allocatorgame);
+				docgame.AddMember("score", tuserscore.score * -1, allocatorgame);
+
+				weblib::httpinfo thttpinfo{};
+				thttpinfo.strurl = std::move(struserip);
+				thttpinfo.strtarget = "webapi/updatescore";
+				thttpinfo.strjson = funclib::doctojson(docgame);
+				m_gamemsg(thttpinfo, std::move(dofun));
+
+				return {};
+			}
 		}
 	}
 
@@ -1412,7 +1414,7 @@ std::string HttpSocket::updateuserscore(std::map<std::string, std::string> getda
 }
 
 //把玩家踢出游戏
-std::string HttpSocket::adminhituser(std::map<std::string, std::string> getdata)
+std::string HttpSocket::adminhituser(std::map<std::string, std::string> getdata, std::function<void(std::string&)>& dofun)
 {
 	kickuser tkickuser;
 	getvaluedata(getdata, tkickuser);
@@ -1441,7 +1443,7 @@ std::string HttpSocket::adminhituser(std::map<std::string, std::string> getdata)
 		return strret;
 	}
 
-	if (!finduser->view()["userid"])
+	if (!finduser->view()["userid"] || !finduser->view()["webuser"])
 	{
 		strret = funclib::rettojson(Err_Player_LackInfo, "the user is not exist");
 		return strret;
@@ -1450,6 +1452,10 @@ std::string HttpSocket::adminhituser(std::map<std::string, std::string> getdata)
 	userspreadid = finduser->view()["spreaderid"].get_int64();
 	userid = finduser->view()["userid"].get_int64();
 
+	std::string strextension1{};
+	std::string strwebonlyuser{};
+	strwebonlyuser = finduser->view()["webuser"].get_utf8().value.data();
+
 	//判断三方平台是否存在
 	auto threeadmin = m_pthreeadmin->find_one(bsoncxx::builder::stream::document{} << "authcode" << tkickuser.authcode.c_str() \
 		<< "authkey" << tkickuser.authkey.c_str() << bsoncxx::builder::stream::finalize);
@@ -1474,39 +1480,74 @@ std::string HttpSocket::adminhituser(std::map<std::string, std::string> getdata)
 		return strret;
 	}
 
-	if (adminuserid != userspreadid || userspreadid == 0)
+	if (adminuserid != userspreadid || userspreadid == 0 || !vipuser->view()["account"])
 	{
 		strret = funclib::rettojson(Err_No_Agent, "the business is not exist");
 		return strret;
 	}
 
-	auto finduserview = make_document(kvp("userid", userid));
+	if (vipuser->view()["account"])
+	{
+		strextension1 = vipuser->view()["account"].get_utf8().value.data();
+	}
+
+	auto finduserview = make_document(kvp("userid", finduser->view()["userid"].get_int64()));
 	auto useroline = m_pplayuseronline->find_one(finduserview.view());
 	bool bfind = false;
-	
+	std::string struserip{};
+	std::int64_t iuserid{ 0 };
+	std::int32_t iserverid{ 0 };
+	std::int64_t icontextid{ 0 };
+
 	if (useroline && useroline->view()["userid"] && useroline->view()["serverid"] && useroline->view()["contextid"] && useroline->view()["userip"])
 	{
-		std::string strloginip{};
-		CMD_CS_C_DelOnlineUser  tDelOnlineUser;
-		ZeroMemory(&tDelOnlineUser, sizeof(tDelOnlineUser));
+		iuserid = useroline->view()["userid"].get_int64();
+		icontextid = useroline->view()["contextid"].get_int64();
+		iserverid = useroline->view()["serverid"].get_int32();
+		struserip = useroline->view()["userip"].get_utf8().value.data();
+		bfind = true;
+	}
 
-		tDelOnlineUser.dwUserID = useroline->view()["userid"].get_int64();
-		tDelOnlineUser.wserverid = useroline->view()["serverid"].get_int32();
-		tDelOnlineUser.dwGameContextID = useroline->view()["contextid"].get_int64();
-		strloginip = useroline->view()["userip"].get_utf8().value.data();
-		m_gamemsg(strloginip, &tDelOnlineUser, sizeof(tDelOnlineUser));
+	if (bfind && m_gamemsg && !struserip.empty())
+	{
+		rapidjson::Document docgame;
+		docgame.SetObject();
+		rapidjson::Document::AllocatorType& allocatorgame = docgame.GetAllocator();
+		docgame.AddMember("agent", rapidjson::Value(strextension1.c_str(), allocatorgame), allocatorgame);
+		docgame.AddMember("user", rapidjson::Value(strwebonlyuser.c_str(), allocatorgame), allocatorgame);
+
+		weblib::httpinfo thttpinfo{};
+		thttpinfo.strurl = std::move(struserip);
+		thttpinfo.strtarget = "webapi/deluser";
+		thttpinfo.strjson = funclib::doctojson(docgame);
+
+		m_gamemsg(thttpinfo, std::move([this, iuserid, iserverid, icontextid, dofun = std::move(dofun)](std::string strdata)mutable
+		{
+			//踢出成功
+			std::string strtojson = funclib::rettojson(-1, "ok");
+
+			if (strdata == "del")
+			{
+				std::function<void()> tfun = [this, iuserid, iserverid, icontextid, dofun = std::move(dofun), strtojson]() mutable{
+					auto finduserview = make_document(kvp("userid", iuserid), kvp("serverid", iserverid), kvp("contextid", icontextid));
+					m_pplayuseronline->delete_one(finduserview.view());
+					dofun(strtojson);
+				};
+				m_postmsg(std::move(tfun));
+				return;
+			}
+
+			dofun(strtojson);
+		}));
+
+		return {};
 	}
 	else
 	{
-		strret = funclib::rettojson(Err_InnerError, "server param erro");
-		return strret;
+		std::string strtojson = funclib::errotojson(Err_Player_NotOnline);
+		return strtojson;
 	}
 
-	//m_pplayuseronline->delete_many(bsoncxx::builder::stream::document{} << "userid" << pkickuser->userid << bsoncxx::builder::stream::finalize);
-
-	//删除成功
-	strret = funclib::rettojson(-1, "ok");
-	return strret;
 }
 
 //管理员禁止管理员所属玩家
@@ -2094,13 +2135,13 @@ std::string HttpSocket::playgameinfo(std::map<std::string, std::string> getdata)
 	//判断三方平台是否存在
 	auto threeadmin = m_pthreeadmin->find_one(bsoncxx::builder::stream::document{} << "authcode" << tplayinfo.authcode.c_str() \
 		<< "authkey" << tplayinfo.authkey.c_str() << bsoncxx::builder::stream::finalize);
-	if (!threeadmin)
+	if (!threeadmin || !threeadmin->view()["adminuserid"])
 	{
 		strret = funclib::rettojson(Err_KeyNotExist, "code or key isnot exist");
 		return strret;
 	}
 
-
+	iadminuserid = threeadmin->view()["adminuserid"].get_int64();
 	auto finduser = m_pcoll->find_one(bsoncxx::builder::stream::document{} << "userid" << tplayinfo.iuserid << bsoncxx::builder::stream::finalize);
 	if (!finduser)
 	{
@@ -2114,7 +2155,14 @@ std::string HttpSocket::playgameinfo(std::map<std::string, std::string> getdata)
 		return strret;
 	}
 
-	iadminuserid = finduser->view()["spreaderid"].get_int64();
+	userspreadid = finduser->view()["spreaderid"].get_int64();
+
+	if (iadminuserid != userspreadid)
+	{
+		strret = funclib::rettojson(Err_Player_LackInfo, "the account does not belong to you");
+		return strret;
+	}
+
 	auto vipuser = m_pvipuser->find_one(bsoncxx::builder::stream::document{} << "userid" << iadminuserid << bsoncxx::builder::stream::finalize);
 	if (!vipuser)
 	{
@@ -2689,7 +2737,7 @@ std::string HttpSocket::updateuseringot(std::map<std::string, std::string> getda
 
 		tempUpdateScore.dwLoginContextID = loginoline->view()["contextid"].get_int64();
 		strloginip = loginoline->view()["userip"].get_utf8().value.data();
-		m_gamemsg(strloginip, &tempUpdateScore, sizeof(tempUpdateScore));
+		//m_gamemsg(strloginip, &tempUpdateScore, sizeof(tempUpdateScore));
 	}
 
 	if (useroline && useroline->view()["serverid"] && useroline->view()["contextid"] && useroline->view()["userip"])
@@ -2704,7 +2752,7 @@ std::string HttpSocket::updateuseringot(std::map<std::string, std::string> getda
 		tempUpdateScore.wgameserverid = useroline->view()["serverid"].get_int32();
 		tempUpdateScore.dwGameContextID = useroline->view()["contextid"].get_int64();
 		strloginip = useroline->view()["userip"].get_utf8().value.data();
-		m_gamemsg(strloginip, &tempUpdateScore, sizeof(tempUpdateScore));
+		//m_gamemsg(strloginip, &tempUpdateScore, sizeof(tempUpdateScore));
 	}
 
 	strret = funclib::rettojson(-1, "ok");
@@ -2969,7 +3017,7 @@ std::string HttpSocket::backuseringot(std::map<std::string, std::string> getdata
 
 		tempUpdateScore.dwLoginContextID = loginoline->view()["contextid"].get_int64();
 		strloginip = loginoline->view()["userip"].get_utf8().value.data();
-		m_gamemsg(strloginip, &tempUpdateScore, sizeof(tempUpdateScore));
+		//m_gamemsg(strloginip, &tempUpdateScore, sizeof(tempUpdateScore));
 	}
 
 	strret = funclib::rettojson(-1, "ok");

+ 7 - 4
webapi/webapi/HttpSocket.h

@@ -6,8 +6,11 @@
 class IIhttpsocket
 {
 public:
-	std::function<void(std::string&, void*, std::size_t)> m_gamemsg;
-	std::function<void(std::string, boost::any)> m_updatestatic;
+	std::function<void(weblib::httpinfo, std::function<void(std::string)>&&)> m_gamemsg{ nullptr };
+	std::function<void(std::string, boost::any)> m_updatestatic{ nullptr };
+	std::function<void(std::function<void()>&&)> m_postmsg{ nullptr };
+	std::function<void(std::string)> m_writelog{ nullptr };
+
 public:
 	virtual void init() = 0;
 	virtual bool postmsg(std::function<void(std::string&)> funhttpmsg, std::map<std::string, std::string> getdata) = 0;
@@ -92,9 +95,9 @@ protected:
 	//玩家账号注册
 	std::string regaccount(std::map<std::string, std::string> getdata);
 	//玩家更新分数
-	std::string updateuserscore(std::map<std::string, std::string> getdata);
+	std::string updateuserscore(std::map<std::string, std::string> getdata, std::function<void(std::string&)>& dofun);
 	//把玩家踢出游戏
-	std::string adminhituser(std::map<std::string, std::string> getdata);
+	std::string adminhituser(std::map<std::string, std::string> getdata, std::function<void(std::string&)>& dofun);
 	//管理员禁止管理员所属玩家
 	std::string adminforbiduser(std::map<std::string, std::string> getdata);
 	//获取账号

+ 2 - 2
webapi/webapi/webapi.vcxproj

@@ -101,7 +101,7 @@
     </ClCompile>
     <Link>
       <SubSystem>Windows</SubSystem>
-      <AdditionalLibraryDirectories>$(SolutionDir)inc\lib\d;$(SolutionDir)mgdb\lib;$(SolutionDir)g3log\debuglib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <AdditionalLibraryDirectories>$(SolutionDir)mgdb\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <AdditionalDependencies>bsoncxx.lib;mongocxx.lib;Synchronization.lib</AdditionalDependencies>
     </Link>
     <Midl>
@@ -159,7 +159,7 @@
       <SubSystem>Windows</SubSystem>
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <OptimizeReferences>true</OptimizeReferences>
-      <AdditionalLibraryDirectories>$(SolutionDir)g3log\releaselib;$(SolutionDir)\mgdb\lib;$(SolutionDir)\inc\lib\r;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <AdditionalLibraryDirectories>$(SolutionDir)g3log\releaselib;$(SolutionDir)\mgdb\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <AdditionalDependencies>bsoncxx.lib;mongocxx.lib;Synchronization.lib</AdditionalDependencies>
     </Link>
     <Midl>

+ 1 - 1
webapi/webapi/webapiDlg.cpp

@@ -63,7 +63,7 @@ BOOL CwebapiDlg::OnInitDialog()
 		boost::shared_ptr<IIhttpsocket> phttp = m_phttpmsg[i];
 		weblib::addmsg(m_pwebsocket, phttp);
 	}
-	weblib::webrun((void*)m_pwebsocket, (void*)m_wnd);
+	weblib::webrun((void*)m_pwebsocket);
 
 	return TRUE;  // return TRUE  unless you set the focus to a control
 }

+ 22 - 5
webapi/webapi/webfun.h

@@ -2,31 +2,48 @@
 #define WEBFUN_H
 
 #ifdef _WIN32
-#ifdef WEBLIBEXPORTS
+#ifdef HTTPLIBEXPORTS
 #define WEBFUN_API __declspec(dllexport)
 #else
 #define WEBFUN_API __declspec(dllimport)
 #ifdef _DEBUG
-#pragma comment (lib, "weblibd.lib")
+#pragma comment (lib, "httplibd.lib")
 #else
-#pragma comment (lib, "weblib.lib")
+#pragma comment (lib, "httplib.lib")
 #endif
 #endif
 #else
 #define WEBFUN_API
 #endif
 
+#include <string>
+#include <functional>
 #include <boost/any.hpp>
 
 namespace weblib
 {
-	WEBFUN_API inline void* webini();
+	struct httpinfo
+	{
+		std::string strurl{};
+		std::string strtarget{};
+		std::string strjson{};
+	};
 
-	WEBFUN_API inline void webrun(void* pweb, void* wnd);
+	WEBFUN_API inline void* webini(int iport = 0, bool blog = true);
+
+	WEBFUN_API inline void webrun(void* pweb);
 
 	WEBFUN_API inline void delweb(void* pweb);
 
 	WEBFUN_API inline void addmsg(void* pweb, boost::any thttp);
+
+	WEBFUN_API inline void* httpini();
+
+	WEBFUN_API inline void delhttp(void* phttp);
+
+	WEBFUN_API inline void addhttpmsg(void* phttp, boost::any thttp);
+
+	WEBFUN_API inline void sendhttp(void* phttp, httpinfo&& thttpinfo, std::function<void(std::string)> &&dofun = nullptr);
 }
 
 #endif // WEBSOCKET_HPP