About Store Forum Documentation Contact



Post Reply 
Storing client addresses
Author Message
kulesz Offline
Member

Post: #1
Storing client addresses
If I store clients similar to ConnectionServer - in a map (or vector), with their socket addresses (SockAddr) as a key, how can I validate, if the client is still connected?

For example, addresses of clients that are standing in a specific area are pushed into a vector. After some time, I'd like to iterate through this vector and do some action on clients. However, some of the clients may have already disconnected - how can I verify this?

Eventually, what is the best way to store clients information with ability to verify it's correctness?
09-19-2011 08:41 PM
Find all posts by this user Quote this message in a reply
Dandruff Offline
Member

Post: #2
RE: Storing client addresses
You can try to send a ping to each client, and if they don't reply in x time you could assume that they are disconnected.
09-19-2011 11:40 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #3
RE: Storing client addresses
ConnectionServer class will automatically remove the elements (clients) upon disconnection
09-20-2011 11:30 AM
Find all posts by this user Quote this message in a reply
kulesz Offline
Member

Post: #4
RE: Storing client addresses
OK, so I'm storing part of my clients (that did specific action in game) in Memc<SockAddr> container. After some time, I want to iterate through this container and send some messages to all those clients. But some of them may have already disconnected and I still have their socket addresses in memory. How can I check, during iteration, if the client still exists (and it's still the same client)?
And one more problem - why doing:
Code:
void RemoveChunk(const SockAddr address, UInt x, UInt z)
{
   chunks[x][z]->clients.exclude(address);
}
gives me:
Code:
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\memory\mem continuous.h(43): error C2679: binary '==' : no operator found which takes a right-hand operand of type 'const EE::SockAddr' (or there is no acceptable conversion)
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\net\socket.h(38): could be 'Bool EE::operator ==(EE::SockAddr &,EE::SockAddr &)' [found using argument-dependent lookup]
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\misc\string functions.h(116): or       'Bool EE::operator ==(const EE::Str &,const EE::Str &)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\misc\string functions.h(117): or       'Bool EE::operator ==(const EE::Str &,CChar *)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\misc\string functions.h(118): or       'Bool EE::operator ==(const EE::Str &,CChar8 *)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\misc\string functions.h(119): or       'Bool EE::operator ==(CChar *,const EE::Str &)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\misc\string functions.h(120): or       'Bool EE::operator ==(CChar8 *,const EE::Str &)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\misc\string functions.h(121): or       'Bool EE::operator ==(const EE::Str &,Char)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\misc\string functions.h(122): or       'Bool EE::operator ==(const EE::Str &,Char8)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\misc\string functions.h(123): or       'Bool EE::operator ==(Char,const EE::Str &)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\misc\string functions.h(124): or       'Bool EE::operator ==(Char8,const EE::Str &)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\misc\string functions.h(138): or       'Bool EE::operator ==(const EE::Str8 &,const EE::Str8 &)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\misc\string functions.h(139): or       'Bool EE::operator ==(const EE::Str8 &,CChar *)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\misc\string functions.h(140): or       'Bool EE::operator ==(const EE::Str8 &,CChar8 *)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\misc\string functions.h(141): or       'Bool EE::operator ==(CChar *,const EE::Str8 &)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\misc\string functions.h(142): or       'Bool EE::operator ==(CChar8 *,const EE::Str8 &)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\misc\string functions.h(143): or       'Bool EE::operator ==(const EE::Str8 &,Char)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\misc\string functions.h(144): or       'Bool EE::operator ==(const EE::Str8 &,Char8)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\misc\string functions.h(145): or       'Bool EE::operator ==(Char,const EE::Str8 &)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\misc\string functions.h(146): or       'Bool EE::operator ==(Char8,const EE::Str8 &)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\file\io.h(57): or       'Bool EE::operator ==(EE::FileInfo &,EE::FileInfo &)'
1>          while trying to match the argument list '(EE::SockAddr, const EE::SockAddr)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\memory\mem continuous.h(43) : while compiling class template member function 'Int EE::Memc<TYPE>::find(const TYPE &) const'
1>          with
1>          [
1>              TYPE=EE::SockAddr
1>          ]
1>          e:\ee\fuckyea\sources\server\chunkmanager.h(59) : see reference to class template instantiation 'EE::Memc<TYPE>' being compiled
1>          with
1>          [
1>              TYPE=EE::SockAddr
1>          ]

clients is the Memc<SockAddr> container.
(This post was last modified: 09-21-2011 07:20 PM by kulesz.)
09-21-2011 07:08 PM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #5
RE: Storing client addresses
(09-21-2011 07:08 PM)kulesz Wrote:  
Code:
e:\ee\fuckyea\sources\server\chunkmanager.h

lol, nice path.. lol

----------

Try:

Code:
void RemoveChunk(SockAddr address, UInt x, UInt z)
09-22-2011 12:06 AM
Find all posts by this user Quote this message in a reply
Dandruff Offline
Member

Post: #6
RE: Storing client addresses
lol grin
09-22-2011 06:00 AM
Find all posts by this user Quote this message in a reply
kulesz Offline
Member

Post: #7
RE: Storing client addresses
Heh, nothing came on my mind when I was trying to think of some title for the project :-P
Well, I tried without const and it's still the same :-/
09-22-2011 07:03 AM
Find all posts by this user Quote this message in a reply
kulesz Offline
Member

Post: #8
RE: Storing client addresses
Still... Doing:
Code:
Client* client;
Memc<SockAddr> clients;

if (clients.has(client->connection.address())) {};

gives me:
Code:
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\memory\mem continuous.h(43): error C2679: binary '==' : no operator found which takes a right-hand operand of type 'const EE::SockAddr' (or there is no acceptable conversion)
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\net\socket.h(38): could be 'Bool EE::operator ==(EE::SockAddr &,EE::SockAddr &)' [found using argument-dependent lookup]
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\misc\string functions.h(116): or       'Bool EE::operator ==(const EE::Str &,const EE::Str &)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\misc\string functions.h(117): or       'Bool EE::operator ==(const EE::Str &,CChar *)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\misc\string functions.h(118): or       'Bool EE::operator ==(const EE::Str &,CChar8 *)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\misc\string functions.h(119): or       'Bool EE::operator ==(CChar *,const EE::Str &)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\misc\string functions.h(120): or       'Bool EE::operator ==(CChar8 *,const EE::Str &)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\misc\string functions.h(121): or       'Bool EE::operator ==(const EE::Str &,Char)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\misc\string functions.h(122): or       'Bool EE::operator ==(const EE::Str &,Char8)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\misc\string functions.h(123): or       'Bool EE::operator ==(Char,const EE::Str &)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\misc\string functions.h(124): or       'Bool EE::operator ==(Char8,const EE::Str &)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\misc\string functions.h(138): or       'Bool EE::operator ==(const EE::Str8 &,const EE::Str8 &)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\misc\string functions.h(139): or       'Bool EE::operator ==(const EE::Str8 &,CChar *)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\misc\string functions.h(140): or       'Bool EE::operator ==(const EE::Str8 &,CChar8 *)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\misc\string functions.h(141): or       'Bool EE::operator ==(CChar *,const EE::Str8 &)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\misc\string functions.h(142): or       'Bool EE::operator ==(CChar8 *,const EE::Str8 &)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\misc\string functions.h(143): or       'Bool EE::operator ==(const EE::Str8 &,Char)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\misc\string functions.h(144): or       'Bool EE::operator ==(const EE::Str8 &,Char8)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\misc\string functions.h(145): or       'Bool EE::operator ==(Char,const EE::Str8 &)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\misc\string functions.h(146): or       'Bool EE::operator ==(Char8,const EE::Str8 &)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\file\io.h(57): or       'Bool EE::operator ==(EE::FileInfo &,EE::FileInfo &)'
1>          while trying to match the argument list '(EE::SockAddr, const EE::SockAddr)'
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\esenthelengine\memory\mem continuous.h(43) : while compiling class template member function 'Int EE::Memc<TYPE>::find(const TYPE &) const'
1>          with
1>          [
1>              TYPE=EE::SockAddr
1>          ]

But clients.add(client->connection.address()) works OK.
(This post was last modified: 09-23-2011 07:26 PM by kulesz.)
09-23-2011 07:26 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #9
RE: Storing client addresses
comparators for SockAddr don't take const parameter,
I'll try to improve it for next sdk

btw: you can use Client destructor call information to get the time of removing the client from client list
09-23-2011 07:30 PM
Find all posts by this user Quote this message in a reply
Post Reply