Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/FICN/src/network/dummyclient3.cc @ 489

Last change on this file since 489 was 459, checked in by scheusso, 17 years ago

preparing clone mode for game (one server steers, all clients view ;) )

File size: 1.7 KB
RevLine 
[438]1#include <iostream>
2#include <string>
3#include "PacketManager.h"
4#include "Client.h"
5
6using namespace network;
7
[448]8void sender(){
9
[438]10  network::PacketGenerator pck;
[441]11  const int PORT = 55556;
[438]12  std::cout << "Enter address of the server xxx.xxx.xxx.xxx (enter for localhost)" << std::endl;
13  std::string str;
14  std::getline(std::cin, str);
15  std::cout << "You entered: " << str << std::endl;
16  if(str.compare("")==0)
17    str="127.0.0.1";
[448]18
[438]19  Client client( str, PORT );
20  if ( client.establishConnection() )
[448]21          std::cout << "connection established" << std::endl;
[441]22  else std::cout << "problems establishing connection" << std::endl;
[448]23
[438]24  while (true) {
[459]25          client.tick(0);
[448]26          std::cout << "your message: ";
27          std::getline( std::cin, str );
28          client.sendChat( str );
29          std::cout << "send message" << std::endl;
[438]30  }
[448]31
32
33
[441]34}
[448]35
36void listener(){
37
38  const int PORT = 55556;
39  std::cout << "Enter address of the server xxx.xxx.xxx.xxx (enter for localhost)" << std::endl;
40  std::string str;
41  std::getline(std::cin, str);
42  std::cout << "You entered: " << str << std::endl;
43  if(str.compare("")==0)
44    str="127.0.0.1";
45
46  Client client( str, PORT );
47  if ( client.establishConnection() )
48          std::cout << "connection established" << std::endl;
49  else std::cout << "problems establishing connection" << std::endl;
50
51  while (true) {
[459]52          client.tick(0);
[448]53          usleep(100);
54  }
55
56
57
58}
59
60
61int main(int argc, char **argv[]){
62  std::string in;
63  std::cout << "Please choose: sender(s) oder listener(l)" << std::endl;
64  std::getline(std::cin, in);
65  if(in.compare("l")==0)
66    listener();
67  else if(in.compare("s")==0)
68    sender();
69  else
70    std::cout << "wrong answer" << std::endl;
71}
Note: See TracBrowser for help on using the repository browser.