[DEV] add the remote name connected to the TCP element IP:port

This commit is contained in:
Edouard DUPIN 2017-10-14 10:46:32 +02:00
parent 19ab3637cf
commit 34bd74c67f
2 changed files with 17 additions and 5 deletions

View File

@ -53,12 +53,13 @@ enet::Tcp::Tcp() :
}
#ifdef __TARGET_OS__Windows
enet::Tcp::Tcp(SOCKET _idSocket, const etk::String& _name) :
enet::Tcp::Tcp(SOCKET _idSocket, const etk::String& _name, const etk::String& _remoteName) :
#else
enet::Tcp::Tcp(int32_t _idSocket, const etk::String& _name) :
enet::Tcp::Tcp(int32_t _idSocket, const etk::String& _name, const etk::String& _remoteName) :
#endif
m_socketId(_idSocket),
m_name(_name),
m_remoteName(_remoteName),
m_status(status::link) {
#ifdef ENET_STORE_INPUT
m_nodeStoreInput = etk::FSNode("CACHE:StoreTCPdata_" + etk::toString(baseID++) + ".tcp");
@ -69,6 +70,7 @@ enet::Tcp::Tcp() :
enet::Tcp::Tcp(Tcp&& _obj) :
m_socketId(_obj.m_socketId),
m_name(_obj.m_name),
m_remoteName(_obj.m_remoteName),
m_status(_obj.m_status) {
#ifdef ENET_STORE_INPUT
m_nodeStoreInput = etk::FSNode("CACHE:StoreTCPdata_" + etk::toString(baseID++) + ".tcp");

View File

@ -34,9 +34,9 @@ namespace enet {
public:
Tcp();
#ifdef __TARGET_OS__Windows
Tcp(SOCKET _idSocket, const etk::String& _name);
Tcp(SOCKET _idSocket, const etk::String& _name, const etk::String& _remoteName="");
#else
Tcp(int32_t _idSocket, const etk::String& _name);
Tcp(int32_t _idSocket, const etk::String& _name, const etk::String& _remoteName="");
#endif
// move constructor
Tcp(Tcp&& _obj);
@ -52,9 +52,19 @@ namespace enet {
* @brief Get the decriptive name hot the host:port
* @return the string requested
*/
const etk::String& getName() {
const etk::String& getName() const {
return m_name;
}
private:
etk::String m_remoteName; //!< remote IP:port.
public:
/**
* @brief Get the decriptive name hot the host:port
* @return the string requested
*/
const etk::String& getRemoteName() const {
return m_remoteName;
}
public:
enum class status {
unlink,