getting a handle to another connection?
Hi, I need to send ip information of a client to the other one (as they will connect to each other directly now). I used async echo server sample http://www.boost.org/doc/libs/1_39_0/doc/html/boost_asio/example/echo/async_...as a starting point. I guess sessions are recorded in io_service instance, since in the server constructor when we create session, we pass io_service to it. session* new_session = new session(io_service_); Can I get information of connected sessions from io_service? (or any other recommendations on how to better design it?) To expand my question: I am implementing a chat server, but the chats will not go over the server (is it a bad idea?). many clients connects, I keep their status (online or not) in a database. when A wants to talk to B, I need to pass request to B, how can I get a handle to my connection to B while I am in the instance of session with A? I am still not sure I understand io_service concept. Is this proactor thing similar to observer pattern? When we pass io_service as a parameter to something, are we registering it to be observed in io_service? Thanks in advance, (*Thanks for all the previous answers too, *I have made significant progress...) Best regards, Ozgur (Oscar) Ozturk www.DrOzturk.com Phone: +1 (908) DROZGUR i.e, +1 (908) 376-9487
Ozgur Ozturk wrote:
Hi, I need to send ip information of a client to the other one (as they will connect to each other directly now). I used async echo server sample http://www.boost.org/doc/libs/1_39_0/doc/html/boost_asio/example/echo/async_...as a starting point. I guess sessions are recorded in io_service instance, since in the server constructor when we create session, we pass io_service to it. session* new_session = new session(io_service_); Can I get information of connected sessions from io_service? (or any other recommendations on how to better design it?)
Sounds like we are doing similar projects :D.
To expand my question: I am implementing a chat server, but the chats will not go over the server (is it a bad idea?).
many clients connects, I keep their status (online or not) in a database.
One of my hurdles at the moment :D
when A wants to talk to B, I need to pass request to B, how can I get a handle to my connection to B while I am in the instance of session with A?
You need some sigslot implementation and a message queue/multi-index view. I am planning on using this approach so that I can abstract my server<-->server and client<-->server implementations. In other words the "router" of my code is in pieces in the client and server classes that will look for the class stream* (lookup via multi-index) to call to relay the message to the appropriate agent(s). (Both classes have a base class called stream). YMMV...
I am still not sure I understand io_service concept. Is this proactor thing similar to observer pattern? When we pass io_service as a parameter to something, are we registering it to be observed in io_service?
io_service = epoll/poll/select... (IO Multiplex object)
Thanks in advance, (*Thanks for all the previous answers too, *I have made significant progress...)
Best regards, Ozgur (Oscar) Ozturk www.DrOzturk.com Phone: +1 (908) DROZGUR i.e, +1 (908) 376-9487
------------------------------------------------------------------------
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
I used async echo server sample http://www.boost.org/doc/libs/1_39_0/doc/html/boost_asio/example/echo/async_...as a starting point. ... Can I get information of connected sessions from io_service? (or any other recommendations on how to better design it?)
Maybe I should keep a global array of sessions, instead of creating it with a pointer session* new_session is this a bad idea? It seems like in the current code ONLY ONE session pointer is passed around. I had thought (from the name "session") there would be a session per connection? Thanks again, Ozgur Ozturk www.DrOzturk.com
Ozgur Ozturk wrote:
I used async echo server sample
http://www.boost.org/doc/libs/1_39_0/doc/html/boost_asio/example/echo/async_...as a starting point.
... Can I get information of connected sessions from io_service? (or any other recommendations on how to better design it?)
Maybe I should keep a global array of sessions, instead of creating it with a pointer session* new_session
You could use shared_ptr to avoid having to write a copy constructor/assignment operator and all those other 'evil' things.
is this a bad idea?
It seems like in the current code ONLY ONE session pointer is passed around. I had thought (from the name "session") there would be a session per connection?
Thanks again, Ozgur Ozturk www.DrOzturk.com
------------------------------------------------------------------------
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Etienne Philip Pretorius
-
Ozgur Ozturk