george82 | 6598b74 | 2005-01-30 16:47:17 +0000 | [diff] [blame] | 1 | /* Copyright (C) 2004 TightVNC Team. All Rights Reserved. |
| 2 | * |
| 3 | * This is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License as published by |
| 5 | * the Free Software Foundation; either version 2 of the License, or |
| 6 | * (at your option) any later version. |
| 7 | * |
| 8 | * This software is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License |
| 14 | * along with this software; if not, write to the Free Software |
| 15 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
| 16 | * USA. |
| 17 | */ |
| 18 | |
george82 | ce8dc3a | 2005-01-31 13:06:54 +0000 | [diff] [blame] | 19 | // -=- rfbSessionReader.h |
george82 | 6598b74 | 2005-01-30 16:47:17 +0000 | [diff] [blame] | 20 | |
| 21 | #include <rfb/Threading.h> |
| 22 | |
| 23 | #include <rfbplayer/RfbProto.h> |
| 24 | |
| 25 | using namespace rfb; |
| 26 | |
| 27 | class rfbSessionReader : public Thread { |
| 28 | public: |
| 29 | rfbSessionReader(RfbProto *_rfbSession) { |
| 30 | rfbSession = _rfbSession; |
| 31 | fStop = false; |
george82 | 8edfb7a | 2005-03-03 16:36:10 +0000 | [diff] [blame] | 32 | rfbSession->interruptFrameDelay(); |
george82 | 6598b74 | 2005-01-30 16:47:17 +0000 | [diff] [blame] | 33 | }; |
| 34 | |
| 35 | ~rfbSessionReader() { |
george82 | 6598b74 | 2005-01-30 16:47:17 +0000 | [diff] [blame] | 36 | } |
| 37 | |
george82 | 2b9d03d | 2005-02-03 14:10:07 +0000 | [diff] [blame] | 38 | virtual Thread* join() { |
george82 | b4f969b | 2005-02-09 16:34:51 +0000 | [diff] [blame] | 39 | ((FbsInputStream*)(rfbSession->getInStream()))->resumePlayback(); |
george82 | 6598b74 | 2005-01-30 16:47:17 +0000 | [diff] [blame] | 40 | fStop = true; |
george82 | 2b9d03d | 2005-02-03 14:10:07 +0000 | [diff] [blame] | 41 | return Thread::join(); |
george82 | 6598b74 | 2005-01-30 16:47:17 +0000 | [diff] [blame] | 42 | } |
| 43 | |
george82 | 2b9d03d | 2005-02-03 14:10:07 +0000 | [diff] [blame] | 44 | virtual void rfbSessionReader::run() { |
george82 | 6598b74 | 2005-01-30 16:47:17 +0000 | [diff] [blame] | 45 | // Process the rfb messages |
| 46 | while (!fStop) { |
| 47 | try { |
| 48 | rfbSession->processMsg(); |
| 49 | } catch (rdr::Exception e) { |
Constantin Kaplinsky | 4aaf63b | 2005-09-28 16:49:36 +0000 | [diff] [blame] | 50 | MessageBox(0, e.str(), "RFB Player", MB_OK | MB_ICONERROR); |
george82 | 6598b74 | 2005-01-30 16:47:17 +0000 | [diff] [blame] | 51 | break; |
| 52 | } |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | protected: |
| 57 | bool fStop; |
| 58 | RfbProto *rfbSession; |
| 59 | }; |