Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 10, 2006, 1:13:49 PM (18 years ago)
Author:
rennerc
Message:

reimplemented NetworkStream

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/network/src/lib/network/network_stream.h

    r7540 r7565  
    99#include <vector>
    1010#include <list>
     11#include <map>
    1112
    1213#include "data_stream.h"
     
    2223class NetworkGameManager;
    2324
     25class PeerInfo
     26{
     27  public:
     28    PeerInfo() { clear(); }
     29    void clear() { userId = 0; isServer = false; socket = NULL; handshake = NULL; lastAckedState = 0; lastRecvedState = 0; }
     30    int             userId;
     31    bool            isServer;
     32    NetworkSocket * socket;
     33    Handshake *     handshake;
     34    int             lastAckedState;
     35    int             lastRecvedState;
     36};
     37
    2438typedef std::list<Synchronizeable*>  SynchronizeableList;
    25 typedef std::vector<NetworkSocket*>  NetworkSocketVector;
    26 typedef std::vector<Handshake*>      HandshakeVector;
     39typedef std::map<int,PeerInfo>       PeerList;
    2740
    2841
     
    4861
    4962    inline int getMaxConnections(){ return maxConnections; }
    50     void setMaxConnections( int n );
    5163
    5264    virtual void processData();
     
    5668    int getSyncCount();
    5769
    58     inline bool isUserIdActive( int userID ) { if (userID>=networkSockets.size()) return false; else return networkSockets[userID]!=NULL; }
     70    inline bool isUserIdActive( int userID ) { return (peers.find(userID) != peers.end()); }
    5971
    6072    void debug();
     73   
     74    inline PeerInfo & getPeerInfo( int userId ) { return peers[userId]; }
    6175
    6276
    6377  private:
    6478    void updateConnectionList();
     79    void handleHandshakes();
     80    void handleUpstream();
     81    void handleDownstream();
    6582
    6683
     
    6986    ConnectionMonitor*         connectionMonitor;
    7087    SynchronizeableList        synchronizeables;
    71     NetworkSocketVector        networkSockets;
    72     HandshakeVector            handshakes;
     88    PeerList                   peers;
    7389    ServerSocket*              serverSocket;
    7490    int                        type;
     
    7995    int                        myHostId;
    8096    int                        maxConnections;
     97   
     98    int                        currentState;
    8199
    82100    NetworkGameManager*        networkGameManager;
Note: See TracChangeset for help on using the changeset viewer.