Rev 1963 | Details | Compare with Previous | Last modification | View Log | SVN | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1598 | runge | 1 | /* |
| 2 | * |
||
| 3 | * Copyright (C) 2010 Mattias Runge |
||
| 4 | * |
||
| 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 |
||
| 7 | * the Free Software Foundation; either version 2 of the License, or |
||
| 8 | * (at your option) any later version. |
||
| 9 | * |
||
| 10 | * This program is distributed in the hope that it will be useful, |
||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
| 13 | * GNU General Public License for more details. |
||
| 14 | * |
||
| 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., |
||
| 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
||
| 18 | * |
||
| 19 | */ |
||
| 20 | |||
| 21 | #include "Subscriber.h" |
||
| 22 | |||
| 23 | #include <boost/bind.hpp> |
||
| 24 | |||
| 25 | #include "Manager.h" |
||
| 1963 | runge | 26 | #include "common/log.h" |
| 1598 | runge | 27 | |
| 28 | namespace atom { |
||
| 29 | namespace net { |
||
| 1963 | runge | 30 | |
| 31 | static const std::string log_module_ = "net::subscriber"; |
||
| 1598 | runge | 32 | |
| 33 | Subscriber::Subscriber() |
||
| 34 | { |
||
| 1963 | runge | 35 | LOG_DEBUG_ENTER; |
| 36 | |||
| 1986 | runge | 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_), |
||
| 39 | Manager::SignalOnNewData::slot_type(&Subscriber::SlotOnNewData, this, _1, _2).track(this->tracker_)); |
||
| 1963 | runge | 40 | |
| 41 | LOG_DEBUG_EXIT; |
||
| 1598 | runge | 42 | } |
| 43 | |||
| 44 | Subscriber::~Subscriber() |
||
| 45 | { |
||
| 1963 | runge | 46 | LOG_DEBUG_ENTER; |
| 47 | LOG_DEBUG_EXIT; |
||
| 1598 | runge | 48 | } |
| 49 | |||
| 1986 | runge | 50 | void Subscriber::SlotOnNewData(SocketId id, common::Byteset data) |
| 1598 | runge | 51 | { |
| 1963 | runge | 52 | LOG_DEBUG_ENTER; |
| 53 | |||
| 1986 | runge | 54 | this->io_service_.post(boost::bind(&Subscriber::SlotOnNewDataHandler, this, id, data)); |
| 1963 | runge | 55 | |
| 56 | LOG_DEBUG_EXIT; |
||
| 1598 | runge | 57 | } |
| 58 | |||
| 1986 | runge | 59 | void Subscriber::SlotOnNewClient(SocketId id, SocketId server_id) |
| 1598 | runge | 60 | { |
| 1963 | runge | 61 | LOG_DEBUG_ENTER; |
| 62 | |||
| 1986 | runge | 63 | this->io_service_.post(boost::bind(&Subscriber::SlotOnNewClientHandler, this, id, server_id)); |
| 1963 | runge | 64 | |
| 65 | LOG_DEBUG_EXIT; |
||
| 1598 | runge | 66 | } |
| 67 | |||
| 1963 | runge | 68 | |
| 1986 | runge | 69 | void Subscriber::SlotOnNewState(SocketId id, ClientState client_state) |
| 70 | { |
||
| 71 | LOG_DEBUG_ENTER; |
||
| 72 | |||
| 73 | this->io_service_.post(boost::bind(&Subscriber::SlotOnNewStateHandler, this, id, client_state)); |
||
| 74 | |||
| 75 | LOG_DEBUG_EXIT; |
||
| 76 | } |
||
| 77 | |||
| 78 | |||
| 1598 | runge | 79 | }; // namespace net |
| 80 | }; // namespace atom |