Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/network/src/network/dummyclient3.cc @ 1494

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