diff --git a/server/wsproxy/GCListener.cc b/server/wsproxy/GCListener.cc index 5261ab6..454d5ce 100644 --- a/server/wsproxy/GCListener.cc +++ b/server/wsproxy/GCListener.cc @@ -72,28 +72,21 @@ public: virtual bool HandleRedirect(const std::string& url, const std::string& querystr, std::string& location) override { - a8::HTTPRequest request; - a8::ParserUrlQueryString(querystr.c_str(), request); - if (a8::Get(request, "c").GetString() == "Ops" && - a8::Get(request, "a").GetString() == "join") { - std::string team_uuid = a8::Get(request, "team_uuid").GetString(); - std::vector strings; - a8::Split(team_uuid, strings, '_'); - if (strings.size() >= 2) { - int node_id = a8::XValue(strings[0]); - if (node_id != App::Instance()->node_id) { - std::string host; - if (JsonDataMgr::Instance()->GetNodeHost(node_id, host)) { - location = a8::Format("wss://%s/webapp/index.php?c=Ops&a=join&team_uuid=%s", - { - host, - team_uuid - }); - return true; - } - } - } - } +#ifdef DEBUG + f8::MsgQueue::Instance()->PostMsg + ( + IM_HandleRedirect, + a8::Args + ( + { + (int)socket_handle, + (std::string)(url + ""), + (std::string)(querystr + ""), + (unsigned long)saddr + } + ) + ); +#endif return false; } @@ -132,6 +125,24 @@ void GCListener::Init() tcp_listener_->bind_address = "0.0.0.0"; tcp_listener_->bind_port = JsonDataMgr::Instance()->GetConf()->At("listen_port")->AsXValue(); tcp_listener_->Open(); + f8::MsgQueue::Instance()->RegisterCallBack + ( + IM_HandleRedirect, + [this] (const a8::Args& args) + { + int socket_handle = args.Get(0); + std::string url = args.Get(1); + std::string query_str = args.Get(2); + websocket_url_hash_[socket_handle] = std::make_tuple(url, query_str); + }); + f8::MsgQueue::Instance()->RegisterCallBack + ( + IM_ClientSocketDisconnect, + [this] (const a8::Args& args) + { + int socket_handle = args.Get(0); + websocket_url_hash_.erase(socket_handle); + }); } void GCListener::UnInit() diff --git a/server/wsproxy/constant.h b/server/wsproxy/constant.h index 256c84c..92a0b17 100644 --- a/server/wsproxy/constant.h +++ b/server/wsproxy/constant.h @@ -14,6 +14,7 @@ enum InnerMesssage_e IM_ExecGM, IM_UpStreamDisconnect, IM_UpStreamConnect, + IM_HandleRedirect }; //网络处理对象