00001
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include "stdnet.h"
00029
00030 #include "nel/misc/system_info.h"
00031
00032 #include "nel/net/callback_client.h"
00033
00034 #include "nel/net/login_cookie.h"
00035 #include "nel/net/login_client.h"
00036
00037 #include "nel/net/udp_sock.h"
00038
00039 using namespace std;
00040 using namespace NLMISC;
00041
00042 namespace NLNET {
00043
00044
00045
00046 bool ShardValidate;
00047 string ShardValidateReason;
00048 void cbShardValidate (CMessage &msgin, TSockId from, CCallbackNetBase &netbase)
00049 {
00050
00051
00052
00053
00054 msgin.serial (ShardValidateReason);
00055 ShardValidate = true;
00056 }
00057
00058 static TCallbackItem FESCallbackArray[] =
00059 {
00060 { "SV", cbShardValidate },
00061 };
00062
00063 string CLoginClient::connectToShard (CLoginCookie &lc, const std::string &addr, CCallbackClient &cnx)
00064 {
00065 nlassert (!cnx.connected());
00066
00067 try
00068 {
00069
00070
00071
00072 cnx.connect (CInetAddress(addr));
00073 cnx.addCallbackArray (FESCallbackArray, sizeof(FESCallbackArray)/sizeof(FESCallbackArray[0]));
00074
00075 cnx.displayAllMyAssociations ();
00076
00077
00078 CMessage msgout2 (cnx.getSIDA (), "SV");
00079 msgout2.serial (lc);
00080 cnx.send (msgout2);
00081
00082
00083 ShardValidate = false;
00084 while (cnx.connected() && !ShardValidate)
00085 {
00086 cnx.update ();
00087 nlSleep(10);
00088 }
00089
00090
00091 if (!ShardValidate) return "FES disconnect me";
00092 }
00093 catch (ESocket &e)
00094 {
00095 return string("FES refused the connection (") + e.what () + ")";
00096 }
00097
00098 return ShardValidateReason;
00099 }
00100
00101 string CLoginClient::connectToShard (const std::string &addr, CUdpSock &cnx)
00102 {
00103 nlassert (!cnx.connected());
00104
00105 try
00106 {
00107
00108
00109
00110 cnx.connect (CInetAddress(addr));
00111 }
00112 catch (ESocket &e)
00113 {
00114 return string("FES refused the connection (") + e.what () + ")";
00115 }
00116
00117 return ShardValidateReason;
00118 }
00119
00120 string CLoginClient::connectToShard (const std::string &addr, CUdpSimSock &cnx)
00121 {
00122 nlassert (!cnx.connected());
00123
00124 try
00125 {
00126
00127
00128
00129 cnx.connect (CInetAddress(addr));
00130 }
00131 catch (ESocket &e)
00132 {
00133 return string("FES refused the connection (") + e.what () + ")";
00134 }
00135
00136 return ShardValidateReason;
00137 }
00138
00139 }