Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/network/dummyclient3.cc @ 1056

Last change on this file since 1056 was 1056, checked in by landauf, 16 years ago

don't panic, no codechanges!
added a link to www.orxonox.net

File size: 2.8 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      ...
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#include <iostream>
30#include <string>
31
32#include "util/Sleep.h"
33#include "PacketManager.h"
34#include "PacketTypes.h"
35#include "Client.h"
36
37using namespace network;
38
39void sender(){
40
41  network::PacketGenerator pck;
42  const int PORT = 55556;
43  COUT(0) << "Enter address of the server xxx.xxx.xxx.xxx (enter for localhost)" << std::endl;
44  std::string str;
45  std::getline(std::cin, str);
46  COUT(3) << "You entered: " << str << std::endl;
47  if(str.compare("")==0)
48    str="127.0.0.1";
49
50  Client client( str, PORT );
51  if ( client.establishConnection() )
52    COUT(3) << "connection established" << std::endl;
53  else COUT(0) << "problems establishing connection" << std::endl;
54  char message[10000];
55  char signs[] = "abcdefghijklmnopqrstuvwxy";
56  while (true) {
57    client.tick(0);
58
59    std::cout << "your message2: ";
60    for ( int i=0; i<9999; i++ ) {
61      message[i] = signs[0];
62    }
63    message[9999] = 'z';
64    std::string str( message );
65    client.sendChat( str );
66    std::cout << str << std::endl;
67    std::cin.get(); std::cin.get();
68  }
69
70
71
72}
73
74void listener(){
75
76  const int PORT = 55556;
77  std::cout << "Enter address of the server xxx.xxx.xxx.xxx (enter for localhost)" << std::endl;
78  std::string str;
79  std::getline(std::cin, str);
80  std::cout << "You entered: " << str << std::endl;
81  if(str.compare("")==0)
82    str="127.0.0.1";
83
84  Client client( str, PORT );
85  if ( client.establishConnection() )
86    std::cout << "connection established" << std::endl;
87  else std::cout << "problems establishing connection" << std::endl;
88
89  while (true) {
90    client.tick(0);
91    usleep(100);
92  }
93
94
95
96}
97
98
99int main(int argc, char **argv[]){
100  std::string in;
101  std::cout << "Please choose: sender(s) oder listener(l)" << std::endl;
102  std::getline(std::cin, in);
103  if(in.compare("l")==0)
104    listener();
105  else if(in.compare("s")==0)
106    sender();
107  else
108    std::cout << "wrong answer" << std::endl;
109}
Note: See TracBrowser for help on using the repository browser.