mirror of
https://github.com/Telecominfraproject/wlan-cloud-ucentralgw.git
synced 2025-11-02 11:47:47 +00:00
Improving RTTYS
This commit is contained in:
@@ -177,14 +177,13 @@ namespace OpenWifi {
|
||||
token_ = ReadString();
|
||||
std::cout << conn_id_ << ": Device Registration ID:" << id_ << " DESC:" << desc_ << " TOK:" << token_ << std::endl;
|
||||
if (RTTYS_server()->ValidEndPoint(id_, token_)) {
|
||||
if (!RTTYS_server()->IsDeviceRegistered(id_, token_, this)) {
|
||||
RTTYS_server()->Register(id_, this);
|
||||
if (RTTYS_server()->Register(id_, token_, this)) {
|
||||
serial_ = RTTYS_server()->SerialNumber(id_);
|
||||
Logger().debug(fmt::format("{}: Registration for SerialNumber: {}, Description: {}",
|
||||
conn_id_, serial_, desc_));
|
||||
} else {
|
||||
Logout();
|
||||
return;
|
||||
return delete this;
|
||||
}
|
||||
u_char OutBuf[12];
|
||||
OutBuf[0] = msgTypeRegister;
|
||||
|
||||
@@ -66,11 +66,11 @@ namespace OpenWifi {
|
||||
return It->second.Client;
|
||||
}
|
||||
|
||||
inline void Register(const std::string &Id, RTTY_Device_ConnectionHandler *Conn) {
|
||||
inline bool Register(const std::string &Id, const std::string &Token, RTTY_Device_ConnectionHandler *Conn) {
|
||||
std::lock_guard G(Mutex_);
|
||||
auto It = EndPoints_.find(Id);
|
||||
if(It==EndPoints_.end()) {
|
||||
EndPoints_[Id] = EndPoint{ .Token = "" ,
|
||||
EndPoints_[Id] = EndPoint{ .Token = Token ,
|
||||
.Client = nullptr,
|
||||
.Device = Conn,
|
||||
.TimeStamp = OpenWifi::Now(),
|
||||
@@ -80,9 +80,11 @@ namespace OpenWifi {
|
||||
.SerialNumber = "" ,
|
||||
.Done = false };
|
||||
Logger().information(fmt::format("Registering session: {}, device:'{}'",Id,It->second.SerialNumber));
|
||||
return true;
|
||||
} else {
|
||||
It->second.Device = Conn;
|
||||
// It->second.Device = Conn;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
inline void DeRegister(const std::string &Id, RTTY_Device_ConnectionHandler *Conn) {
|
||||
@@ -147,17 +149,6 @@ namespace OpenWifi {
|
||||
return ((It->second.Token == Token) && ((Now-It->second.TimeStamp)<30));
|
||||
}
|
||||
|
||||
inline bool CanConnect( const std::string &Id, RTTY_Device_ConnectionHandler *Conn) {
|
||||
std::lock_guard G(Mutex_);
|
||||
|
||||
auto It = EndPoints_.find(Id);
|
||||
if(It!=EndPoints_.end() && It->second.Device==Conn && It->second.DeviceConnected==0) {
|
||||
It->second.DeviceConnected = std::time(nullptr);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool CanConnect( const std::string &Id, RTTYS_ClientConnection *Conn) {
|
||||
std::lock_guard G(Mutex_);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user