Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 448


Ignore:
Timestamp:
Dec 9, 2007, 11:24:25 PM (17 years ago)
Author:
scheusso
Message:

some bugfixes(clientinformation, client), enhancements(client, server) and tests(chatserver/client)

Location:
code/branches/FICN/src/network
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/FICN/src/network/CMakeLists.txt

    r441 r448  
    22
    33SET( CHATCLIENT_SRC_FILES
     4  ClientConnection.cc
     5  Client.cc
     6  PacketBuffer.cc
     7  PacketDecoder.cc
     8  PacketGenerator.cc
    49  dummyclient3.cc
    510)
    611SET( CHATSERVER_SRC_FILES
     12  ConnectionManager.cc
     13  GameStateManager.cc
     14  PacketBuffer.cc
     15  PacketDecoder.cc
     16  PacketGenerator.cc
    717  dummyserver3.cc
    818)
  • code/branches/FICN/src/network/Client.cc

    r439 r448  
    100100    if(!isConnected)
    101101      return false;
    102     if(!client_connection.addPacket(pck_gen.chatMessage( message.c_str() )));
    103         return false;
     102    if(client_connection.addPacket(pck_gen.chatMessage( message.c_str() )));
     103      return client_connection.sendPackets();
    104104    // send packets
    105     return client_connection.sendPackets();
     105    return false;
    106106  }
    107107
  • code/branches/FICN/src/network/ClientConnection.cc

    r369 r448  
    8282    if(enet_peer_send(server, 1, packet)!=0)
    8383      return false;
    84     else
    85       return true;
     84    return true;
    8685  }
    8786
     
    8988    if(server==NULL)
    9089      return false;
    91     if(enet_host_service(client, event, NETWORK_SEND_WAIT)>=0)
    92       return true;
     90    if(enet_host_service(client, event, NETWORK_SEND_WAIT)>=0){
     91      return true;}
    9392    else
    9493      return false;
     
    9998    if(server==NULL)
    10099      return false;
    101     if(enet_host_service(client, &event, NETWORK_SEND_WAIT)>=0)
    102       return true;
     100    if(enet_host_service(client, &event, NETWORK_SEND_WAIT)>=0){
     101      return true;}
    103102    else
    104103      return false;
     
    130129      case ENET_EVENT_TYPE_CONNECT:
    131130      case ENET_EVENT_TYPE_RECEIVE:
     131        std::cout << "got packet" << std::endl;
    132132        processData(&event);
    133133        break;
  • code/branches/FICN/src/network/dummyclient3.cc

    r446 r448  
    66using namespace network;
    77
    8 int main(){
     8void sender(){
     9
    910  network::PacketGenerator pck;
    1011  const int PORT = 55556;
     
    1516  if(str.compare("")==0)
    1617    str="127.0.0.1";
    17  
     18
    1819  Client client( str, PORT );
    1920  if ( client.establishConnection() )
    20           std::cout << "connection established" << std::endl;
     21          std::cout << "connection established" << std::endl;
    2122  else std::cout << "problems establishing connection" << std::endl;
    22  
     23
    2324  while (true) {
    24           client.update();
    25           std::cout << "your message: ";
    26           std::getline( std::cin, str );
    27           client.sendChat( str );
    28           std::cout << "send message" << std::endl;
     25          client.update();
     26          std::cout << "your message: ";
     27          std::getline( std::cin, str );
     28          client.sendChat( str );
     29          std::cout << "send message" << std::endl;
    2930  }
     31
     32
     33
    3034}
     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) {
     52          client.update();
     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 TracChangeset for help on using the changeset viewer.