Rev 1963 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1963 | Rev 1986 | ||
|---|---|---|---|
| 1 | /* |
1 | /* |
| 2 | * |
2 | * |
| 3 | * Copyright (C) 2010 Mattias Runge |
3 | * Copyright (C) 2010 Mattias Runge |
| 4 | * |
4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
8 | * (at your option) any later version. |
| 9 | * |
9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
13 | * GNU General Public License for more details. |
| 14 | * |
14 | * |
| 15 | * You should have received a copy of the GNU General Public License along |
15 | * You should have received a copy of the GNU General Public License along |
| 16 | * with this program; if not, write to the Free Software Foundation, Inc., |
16 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | * |
18 | * |
| 19 | */ |
19 | */ |
| 20 | 20 | ||
| 21 | #include "Subscriber.h" |
21 | #include "Subscriber.h" |
| 22 | 22 | ||
| 23 | #include <boost/bind.hpp> |
23 | #include <boost/bind.hpp> |
| 24 | 24 | ||
| 25 | #include "Manager.h" |
25 | #include "Manager.h" |
| 26 | #include "common/log.h" |
26 | #include "common/log.h" |
| 27 | 27 | ||
| 28 | namespace atom { |
28 | namespace atom { |
| 29 | namespace net { |
29 | namespace net { |
| 30 | 30 | ||
| 31 | static const std::string log_module_ = "net::subscriber"; |
31 | static const std::string log_module_ = "net::subscriber"; |
| 32 | 32 | ||
| 33 | Subscriber::Subscriber() |
33 | Subscriber::Subscriber() |
| 34 | { |
34 | { |
| 35 | LOG_DEBUG_ENTER; |
35 | LOG_DEBUG_ENTER; |
| 36 | 36 | ||
| 37 | Manager::Instance()->ConnectSlots(Manager::SignalOnNewState::slot_type(&Subscriber::SlotOnNewState, this, _1, |
37 | Manager::Instance()->ConnectSlots(Manager::SignalOnNewState::slot_type(&Subscriber::SlotOnNewState, this, _1, _2).track(this->tracker_), |
| - | 38 | Manager::SignalOnNewClient::slot_type(&Subscriber::SlotOnNewClient, this, _1, _2).track(this->tracker_), |
|
| 38 | Manager::SignalOnNewData::slot_type(&Subscriber::SlotOnNewData, this, _1, |
39 | Manager::SignalOnNewData::slot_type(&Subscriber::SlotOnNewData, this, _1, _2).track(this->tracker_)); |
| 39 | 40 | ||
| 40 | LOG_DEBUG_EXIT; |
41 | LOG_DEBUG_EXIT; |
| 41 | } |
42 | } |
| 42 | 43 | ||
| 43 | Subscriber::~Subscriber() |
44 | Subscriber::~Subscriber() |
| 44 | { |
45 | { |
| 45 | LOG_DEBUG_ENTER; |
46 | LOG_DEBUG_ENTER; |
| 46 | LOG_DEBUG_EXIT; |
47 | LOG_DEBUG_EXIT; |
| 47 | } |
48 | } |
| 48 | 49 | ||
| 49 | void Subscriber::SlotOnNewData(SocketId |
50 | void Subscriber::SlotOnNewData(SocketId id, common::Byteset data) |
| 50 | { |
51 | { |
| 51 | LOG_DEBUG_ENTER; |
52 | LOG_DEBUG_ENTER; |
| 52 | 53 | ||
| 53 | this->io_service_.post(boost::bind(&Subscriber::SlotOnNewDataHandler, this, |
54 | this->io_service_.post(boost::bind(&Subscriber::SlotOnNewDataHandler, this, id, data)); |
| 54 | 55 | ||
| 55 | LOG_DEBUG_EXIT; |
56 | LOG_DEBUG_EXIT; |
| 56 | } |
57 | } |
| 57 | 58 | ||
| 58 | void Subscriber:: |
59 | void Subscriber::SlotOnNewClient(SocketId id, SocketId server_id) |
| 59 | { |
60 | { |
| 60 | LOG_DEBUG_ENTER; |
61 | LOG_DEBUG_ENTER; |
| 61 | 62 | ||
| - | 63 | this->io_service_.post(boost::bind(&Subscriber::SlotOnNewClientHandler, this, id, server_id)); |
|
| - | 64 | ||
| - | 65 | LOG_DEBUG_EXIT; |
|
| - | 66 | } |
|
| - | 67 | ||
| - | 68 | ||
| - | 69 | void Subscriber::SlotOnNewState(SocketId id, ClientState client_state) |
|
| - | 70 | { |
|
| - | 71 | LOG_DEBUG_ENTER; |
|
| - | 72 | ||
| 62 | this->io_service_.post(boost::bind(&Subscriber::SlotOnNewStateHandler, this, |
73 | this->io_service_.post(boost::bind(&Subscriber::SlotOnNewStateHandler, this, id, client_state)); |
| 63 | 74 | ||
| 64 | LOG_DEBUG_EXIT; |
75 | LOG_DEBUG_EXIT; |
| 65 | } |
76 | } |
| 66 | 77 | ||
| 67 | 78 | ||
| 68 | }; // namespace net |
79 | }; // namespace net |
| 69 | }; // namespace atom |
80 | }; // namespace atom |
| 70 | 81 | ||