Rev 1598 | Rev 1642 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1598 | Rev 1604 | ||
|---|---|---|---|
| 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 | 26 | ||
| 27 | namespace atom { |
27 | namespace atom { |
| 28 | namespace net { |
28 | namespace net { |
| 29 | 29 | ||
| 30 | Subscriber::Subscriber() |
30 | Subscriber::Subscriber() |
| 31 | { |
31 | { |
| 32 | Manager::Instance()->ConnectSlots(Manager::SignalOnNewState::slot_type(&Subscriber::SlotOnNewState, this, _1, _2, _3).track(this->tracker_), |
32 | Manager::Instance()->ConnectSlots(Manager::SignalOnNewState::slot_type(&Subscriber::SlotOnNewState, this, _1, _2, _3).track(this->tracker_), |
| 33 | Manager::SignalOnNewData::slot_type(&Subscriber::SlotOnNewData, this, _1, _2, _3).track(this->tracker_)); |
33 | Manager::SignalOnNewData::slot_type(&Subscriber::SlotOnNewData, this, _1, _2, _3).track(this->tracker_)); |
| 34 | } |
34 | } |
| 35 | 35 | ||
| 36 | Subscriber::~Subscriber() |
36 | Subscriber::~Subscriber() |
| 37 | { |
37 | { |
| 38 | } |
38 | } |
| 39 | 39 | ||
| 40 | void Subscriber::SlotOnNewData(ClientId client_id, ServerId server_id, type::Byteset data) |
40 | void Subscriber::SlotOnNewData(ClientId client_id, ServerId server_id, type::Byteset data) |
| 41 | { |
41 | { |
| 42 | type::Byteset temp_buffer |
42 | type::Byteset temp_buffer(data); |
| 43 | this->io_service_.post(boost::bind(&Subscriber::SlotOnNewDataHandler, this, client_id, server_id, temp_buffer)); |
43 | this->io_service_.post(boost::bind(&Subscriber::SlotOnNewDataHandler, this, client_id, server_id, temp_buffer)); |
| 44 | } |
44 | } |
| 45 | 45 | ||
| 46 | void Subscriber::SlotOnNewState(ClientId client_id, ServerId server_id, ClientState client_state) |
46 | void Subscriber::SlotOnNewState(ClientId client_id, ServerId server_id, ClientState client_state) |
| 47 | { |
47 | { |
| 48 | this->io_service_.post(boost::bind(&Subscriber::SlotOnNewStateHandler, this, client_id, server_id, client_state)); |
48 | this->io_service_.post(boost::bind(&Subscriber::SlotOnNewStateHandler, this, client_id, server_id, client_state)); |
| 49 | } |
49 | } |
| 50 | 50 | ||
| 51 | }; // namespace net |
51 | }; // namespace net |
| 52 | }; // namespace atom |
52 | }; // namespace atom |
| 53 | 53 | ||