ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/host/c++/SmallNet.cpp
(Generate patch)

Comparing projects/cms/source/host/c++/SmallNet.cpp (file contents):
Revision 1.1 by ab11, Wed Jan 24 19:33:13 2001 UTC vs.
Revision 1.7 by tdb, Tue May 21 16:47:11 2002 UTC

# Line 1 | Line 1
1 + /*
2 + * i-scream central monitoring system
3 + * http://www.i-scream.org.uk
4 + * Copyright (C) 2000-2002 i-scream
5 + *
6 + * This program is free software; you can redistribute it and/or
7 + * modify it under the terms of the GNU General Public License
8 + * as published by the Free Software Foundation; either version 2
9 + * of the License, or (at your option) any later version.
10 + *
11 + * This program is distributed in the hope that it will be useful,
12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 + * GNU General Public License for more details.
15 + *
16 + * You should have received a copy of the GNU General Public License
17 + * along with this program; if not, write to the Free Software
18 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19 + */
20 +
21   #include "SmallNet.h"
22  
23 < SmallNet::SmallNet(){
23 > SmallNet::SmallNet(int printDebug){
24          
25 +        debug = printDebug;
26 +        
27 +        if ( debug == 1 ){
28 +                std::cout << "SmallNet Constructor\n";
29 +        } // if
30 +        
31          return;
32          
33 < }; // SmallNet
33 > } // SmallNet
34  
35  
36   int SmallNet::connectHeartBeat(string host, int port){
37          
38 +        if ( debug == 1 ){
39 +                std::cout << "SmallNet::connectHeartBeat(" << host << "," << port << ")\n";
40 +        } // if
41          
42 <        return 0;
42 >        ssocket = new SubNet(host, port);
43          
44 < }; // connectHeartBeat
44 >        return ssocket->isConnected();
45 >        
46 > } // connectHeartBeat
47  
17
48   string SmallNet::heartBeatSend(string text){
49 +                
50 +        if ( debug == 1 ){
51 +                std::cout << "SmallNet::heartBeatSend()\n";
52 +        } // if
53          
54 +        return ssocket->sendTCP(text);
55          
56 <        return "";
22 <        
23 < }; // heartBeatSend
56 > } // heartBeatSend
57  
58  
59   void SmallNet::closeHeartBeatConnection(){
60 +        if ( debug == 1 ){
61 +                std::cout << "SmallNet::closeHeartBeatConnection()\n";
62 +                std::cout << "Deleting socket\n";
63 +        } // if
64          
65 <        
65 >        // closes automatically
66 >        delete ssocket;
67          return;
68          
69 < }; // closeHeartBeatConnection  
69 > } // closeHeartBeatConnection  
70  
71  
72 < int SmallNet::connectConfig(){
72 > int SmallNet::connectConfig(string host, int port){
73 >        if ( debug == 1 ){
74 >                std::cout << "SmallNet::connectConfig(" << host << "," << port << ")\n";
75 >        } // if
76          
77 +        return connectHeartBeat(host,port);
78          
79 <        return 0;
38 <        
39 < }; // makeConfigConnection
79 > } // makeConfigConnection
80  
81   string SmallNet::configSend(string text){
82 +        if ( debug == 1 ){
83 +                std::cout << "SmallNet::configSend()\n";
84 +        } // if
85 +                
86 +        return heartBeatSend(text);
87          
88 + } // configSend
89 +
90 + void SmallNet::closeConfigConnection(){
91 +        if ( debug == 1 ){
92 +                std::cout << "SmallNet::closeConfigConnection()\n";
93 +        } // if
94          
95 +        closeHeartBeatConnection();
96          
97 <        return "";
97 >    return;
98          
99 < }; // configSend
99 > } // closeConfigConnection
100  
101 + void SmallNet::sendUPDPacket( string host, int port, string message ){
102 +        
103 +        if ( debug == 1 ){
104 +                std::cout << "SmallNet::sendUPDPacket:" << host << ":" << port << "\n";
105 +        } // if
106 +        
107 +        ssocket = new SubNet();
108 +        ssocket->sendUPDPacket(host, port, message);
109 +        delete ssocket;
110 +
111 +        return;
112 + } // sendUDPPacket

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines