Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 1505 was 1505, checked in by rgrieder, 16 years ago

f* svn: It doesn't even inform you if you attempt to set a non existing property. It is svn:eol-style and not eol-style when using the command by the way…

  • Property svn:eol-style set to native
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 "Client.h"
30
31#include <iostream>
32#include <string>
33
34#include "util/Sleep.h"
35#include "PacketManager.h"
36#include "PacketTypes.h"
37
38using namespace network;
39
40void sender(){
41
42  network::PacketGenerator pck;
43  const int PORT = 55556;
44  COUT(0) << "Enter address of the server xxx.xxx.xxx.xxx (enter for localhost)" << std::endl;
45  std::string str;
46  std::getline(std::cin, str);
47  COUT(3) << "You entered: " << str << std::endl;
48  if(str.compare("")==0)
49    str="127.0.0.1";
50
51  Client client( str, PORT );
52  if ( client.establishConnection() )
53  {
54    COUT(3) << "connection established" << std::endl;
55  }
56  else
57  {
58    COUT(0) << "problems establishing connection" << std::endl;
59  }
60  char message[10000];
61  char signs[] = "abcdefghijklmnopqrstuvwxy";
62  while (true) {
63    client.tick(0);
64
65    std::cout << "your message2: ";
66    for ( int i=0; i<9999; i++ ) {
67      message[i] = signs[0];
68    }
69    message[9999] = 'z';
70    std::string str( message );
71    client.sendChat( str );
72    std::cout << str << std::endl;
73    std::cin.get(); std::cin.get();
74  }
75
76
77
78}
79
80void listener(){
81
82  const int PORT = 55556;
83  std::cout << "Enter address of the server xxx.xxx.xxx.xxx (enter for localhost)" << std::endl;
84  std::string str;
85  std::getline(std::cin, str);
86  std::cout << "You entered: " << str << std::endl;
87  if(str.compare("")==0)
88    str="127.0.0.1";
89
90  Client client( str, PORT );
91  if ( client.establishConnection() )
92    std::cout << "connection established" << std::endl;
93  else std::cout << "problems establishing connection" << std::endl;
94
95  while (true) {
96    client.tick(0);
97    usleep(100);
98  }
99
100
101
102}
103
104
105int main(int argc, char **argv[]){
106  std::string in;
107  std::cout << "Please choose: sender(s) oder listener(l)" << std::endl;
108  std::getline(std::cin, in);
109  if(in.compare("l")==0)
110    listener();
111  else if(in.compare("s")==0)
112    sender();
113  else
114    std::cout << "wrong answer" << std::endl;
115}
Note: See TracBrowser for help on using the repository browser.