Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/script_trigger/src/network/dummyclient3.cc @ 2125

Last change on this file since 2125 was 1293, checked in by scheusso, 17 years ago

merged changes from input & camera & network branch into trunk

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    COUT(3) << "connection established" << std::endl;
54  else COUT(0) << "problems establishing connection" << std::endl;
55  char message[10000];
56  char signs[] = "abcdefghijklmnopqrstuvwxy";
57  while (true) {
58    client.tick(0);
59
60    std::cout << "your message2: ";
61    for ( int i=0; i<9999; i++ ) {
62      message[i] = signs[0];
63    }
64    message[9999] = 'z';
65    std::string str( message );
66    client.sendChat( str );
67    std::cout << str << std::endl;
68    std::cin.get(); std::cin.get();
69  }
70
71
72
73}
74
75void listener(){
76
77  const int PORT = 55556;
78  std::cout << "Enter address of the server xxx.xxx.xxx.xxx (enter for localhost)" << std::endl;
79  std::string str;
80  std::getline(std::cin, str);
81  std::cout << "You entered: " << str << std::endl;
82  if(str.compare("")==0)
83    str="127.0.0.1";
84
85  Client client( str, PORT );
86  if ( client.establishConnection() )
87    std::cout << "connection established" << std::endl;
88  else std::cout << "problems establishing connection" << std::endl;
89
90  while (true) {
91    client.tick(0);
92    usleep(100);
93  }
94
95
96
97}
98
99
100int main(int argc, char **argv[]){
101  std::string in;
102  std::cout << "Please choose: sender(s) oder listener(l)" << std::endl;
103  std::getline(std::cin, in);
104  if(in.compare("l")==0)
105    listener();
106  else if(in.compare("s")==0)
107    sender();
108  else
109    std::cout << "wrong answer" << std::endl;
110}
Note: See TracBrowser for help on using the repository browser.