Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 31, 2007, 7:40:23 PM (16 years ago)
Author:
rgrieder
Message:
  • added dll support to the network library
  • improved header file dependency in network
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/FICN/src/network/Client.cc

    r632 r777  
    11/*
    2  *   ORXONOX - the hottest 3D action shooter ever to exist
    3  *
    4  *
    5  *   License notice:
    6  *
    7  *   This program is free software; you can redistribute it and/or
    8  *   modify it under the terms of the GNU General Public License
    9  *   as published by the Free Software Foundation; either version 2
    10  *   of the License, or (at your option) any later version.
    11  *
    12  *   This program is distributed in the hope that it will be useful,
    13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15  *   GNU General Public License for more details.
    16  *
    17  *   You should have received a copy of the GNU General Public License
    18  *   along with this program; if not, write to the Free Software
    19  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    20  *
    21  *   Author:
    22  *      Oliver Scheuss, (C) 2007
    23  *   Co-authors:
    24  *      ...
    25  *
    26  */
     2*   ORXONOX - the hottest 3D action shooter ever to exist
     3*
     4*
     5*   License notice:
     6*
     7*   This program is free software; you can redistribute it and/or
     8*   modify it under the terms of the GNU General Public License
     9*   as published by the Free Software Foundation; either version 2
     10*   of the License, or (at your option) any later version.
     11*
     12*   This program is distributed in the hope that it will be useful,
     13*   but WITHOUT ANY WARRANTY; without even the implied warranty of
     14*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15*   GNU General Public License for more details.
     16*
     17*   You should have received a copy of the GNU General Public License
     18*   along with this program; if not, write to the Free Software
     19*   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     20*
     21*   Author:
     22*      Oliver Scheuss, (C) 2007
     23*   Co-authors:
     24*      ...
     25*
     26*/
    2727
    2828//
     
    3838//
    3939
     40#include "core/CoreIncludes.h"
    4041#include "Client.h"
    4142
    42 namespace network{
    43 
    44   /**
    45    * Constructor for the Client class
    46    * initializes the address and the port to default localhost:NETWORK_PORT
    47    */
     43namespace network
     44{
     45  /**
     46  * Constructor for the Client class
     47  * initializes the address and the port to default localhost:NETWORK_PORT
     48  */
    4849  Client::Client(): client_connection(NETWORK_PORT,"127.0.0.1"){
    4950    // set server address to localhost
     
    5253
    5354  /**
    54    * Constructor for the Client class
    55    * @param address the server address
    56    * @param port port of the application on the server
    57    */
     55  * Constructor for the Client class
     56  * @param address the server address
     57  * @param port port of the application on the server
     58  */
    5859  Client::Client(std::string address, int port) : client_connection(port, address){
    5960    isConnected=false;
     
    6162
    6263  /**
    63    * Constructor for the Client class
    64    * @param address the server address
    65    * @param port port of the application on the server
    66    */
     64  * Constructor for the Client class
     65  * @param address the server address
     66  * @param port port of the application on the server
     67  */
    6768  Client::Client(const char *address, int port) : client_connection(port, address){
    6869    isConnected=false;
     
    7071
    7172  /**
    72    * Establish the Connection to the Server
    73    * @return true/false
    74    */
     73  * Establish the Connection to the Server
     74  * @return true/false
     75  */
    7576  bool Client::establishConnection(){
    7677    isConnected=client_connection.createConnection();
     
    7980
    8081  /**
    81    * closes the Connection to the Server
    82    * @return true/false
    83    */
     82  * closes the Connection to the Server
     83  * @return true/false
     84  */
    8485  bool Client::closeConnection(){
    8586    isConnected=false;
     
    8889
    8990  /**
    90    * submits a MouseAction to the server
    91    * @param x x Coordinate
    92    * @param y y Coordinate
    93    * @return true/false
    94    */
     91  * submits a MouseAction to the server
     92  * @param x x Coordinate
     93  * @param y y Coordinate
     94  * @return true/false
     95  */
    9596  bool Client::sendMouse(double x, double y){
    9697    // generate packet and add it to the queue
     
    9899      return false;
    99100    if(!client_connection.addPacket(pck_gen.mousem(x, y)))
    100         return false;
     101      return false;
    101102    // send packets
    102103    return client_connection.sendPackets();
     
    104105
    105106  /**
    106    * submits a Keystrike to the server
    107    * @param key_code code to submit
    108    * @return true/false
    109    */
     107  * submits a Keystrike to the server
     108  * @param key_code code to submit
     109  * @return true/false
     110  */
    110111  bool Client::sendKeyboard(char key_code){
    111112    // generate packet and add it to queue
     
    113114      return false;
    114115    if(!client_connection.addPacket(pck_gen.keystrike(key_code)))
    115         return false;
     116      return false;
    116117    // send packets
    117118    return client_connection.sendPackets();
     
    119120
    120121  /**
    121    * submits a chat message to the server
    122    * @param message message to send
    123    * @return true/false
    124    */
     122  * submits a chat message to the server
     123  * @param message message to send
     124  * @return true/false
     125  */
    125126  bool Client::sendChat( std::string message ){
    126127    // generate packet and add it to queue
     
    134135
    135136  /**
    136    * Adds a MouseAction to the PacketQueue
    137    * @param x x Coordinate
    138    * @param y y Coordinate
    139    * @return true/false
    140    */
     137  * Adds a MouseAction to the PacketQueue
     138  * @param x x Coordinate
     139  * @param y y Coordinate
     140  * @return true/false
     141  */
    141142  bool Client::addMouse(double x, double y){
    142143    // generate packet and add it to the queue
     
    148149
    149150  /**
    150    * Adds a Keystrike to the PacketQueue
    151    * @param key_code
    152    * @return true/false
    153    */
     151  * Adds a Keystrike to the PacketQueue
     152  * @param key_code
     153  * @return true/false
     154  */
    154155  bool Client::addKeyboard(char key_code){
    155156    // generate packet and add it to queue
     
    161162
    162163  /**
    163    * Sends out all the packets queued by addXXX
    164    */
     164  * Sends out all the packets queued by addXXX
     165  */
    165166  bool Client::sendPackets(){
    166167    if(!isConnected)
     
    176177
    177178  /**
    178    * Performs a GameState update
    179    */
     179  * Performs a GameState update
     180  */
    180181  void Client::tick(float time){
    181182    ENetPacket *packet;
Note: See TracChangeset for help on using the changeset viewer.