Transport.h

00001 /* START_LICENSE_HEADER
00002 
00003 Copyright (C) 2000 Martin Piper, original design and program code
00004 Copyright (C) 2001 Replica Software
00005 
00006 This program file is copyright (C) Replica Software and can only be used under license.
00007 For more information visit: http://www.replicanet.com/
00008 Or email: info@replicanet.com
00009 
00010 END_LICENSE_HEADER */
00011 #ifndef __TRANSPORT_H__
00012 #define __TRANSPORT_H__
00013 #include "RNPlatform/Inc/DLLExportAPI.h"
00014 
00015 #include <string>
00016 
00017 namespace RNReplicaNet
00018 {
00019 
00020 const int TransportAnyGameChannel = 0;
00021 const int TransportMinimumPacketSize = 512;
00022 
00035 class XPURLDLL_API Transport
00036 {
00037 public:
00038 
00042     enum Error
00043     {
00044         kTransport_EOK = 0,                     
00045         kTransport_EERROR = -1,                 
00046         kTransport_ECANTLISTENONCHANNEL = -2,   
00047         kTransport_EWAITING = -3                
00048     };
00049 
00050     enum Bandwidth
00051     {
00052         kBandwidth_Off = 0,
00053         kBandwidth_Connection = 1
00054     };
00055 
00059     Transport();
00060 
00064     virtual ~Transport();
00065 
00066     /* These virtual functions have a base implementation but can also be replaced by a new transport if needed */
00067 
00073     virtual int GetPacketsSent(const bool reset = false);
00074 
00080     virtual int GetPacketsSentMerged(const bool reset = false);
00081 
00087     virtual int GetPacketsSentSize(const bool reset = false);
00088 
00094     virtual int GetPacketsReceived(const bool reset = false);
00095 
00101     virtual int GetPacketsReceivedMerged(const bool reset = false);
00102 
00108     virtual int GetPacketsReceivedSize(const bool reset = false);
00109 
00115     virtual int GetPacketsLost(const bool reset = false);
00116 
00123     virtual void SetBandwidthLimit(const Bandwidth enable = kBandwidth_Off);
00124 
00129     virtual Bandwidth GetBandwidthLimit();
00130 
00135     virtual void SetMaximumOutputBandwidth(const int bytesPerSecond = 0);
00136 
00141     virtual int GetMaximumOutputBandwidth(void);
00142 
00147     virtual void SetMaximumInputBandwidth(const int bytesPerSecond = 0);
00148 
00153     virtual int GetMaximumInputBandwidth(void);
00154 
00159     virtual std::string GetPeerURL(void);
00160 
00165     virtual bool GetTransportClosed(void);
00166 
00171     virtual void SetEnableLANDiscovery(const bool enable = true);
00172 
00177     virtual bool GetEnableLANDiscovery(void);
00178 
00179     /* These pure virtual functions are the minimum feature set the transport has to support */
00180 
00186     virtual std::string CanAccept(void) = 0;
00187 
00193     virtual std::string CanRoute(void) = 0;
00194 
00200     virtual std::string ExportURL(void) = 0;
00201 
00206     virtual Transport *Allocate(void) = 0;
00207 
00213     virtual Error Listen(const int channel = TransportAnyGameChannel) = 0;
00214 
00220     virtual Error Connect(const std::string address) = 0;
00221 
00226     virtual Transport *Accept(void) = 0;
00227 
00236     virtual Error Send(const char *data,const int len) = 0;
00237 
00247     virtual Error SendReliable(const char *data,const int len,const unsigned int band = 0) = 0;
00248 
00257     virtual Error SendCertain(const char *data,const int len) = 0;
00258 
00265     virtual int Recv(char *const data,const int maxlen) = 0;
00266 
00271     virtual int GetMaxPacketSize(void) = 0;
00272 
00277     virtual std::string HandleDiscovery(void) = 0;
00278 
00283     virtual void HandleDiscoveryReply(const std::string reply) = 0;
00284 
00288     virtual void BeginDiscovery(void) = 0;
00289 
00294     virtual std::string GetNextDiscovery(void) = 0;
00295 
00300     virtual Error GetStatus(void) = 0;
00301 
00302 private:
00303 };
00304 
00305 } // namespace RNReplicaNet
00306 
00307 #endif

Generated on Sat Jun 28 22:02:16 2008 for ReplicaNet and RNLobby by  doxygen 1.5.3