Main Page | Class List | Directories | File List | Class Members

Transport.h

00001 /* START_LICENSE_HEADER
00002 
00003 Copyright (C) 2000 Martin Piper, original design and program code
00004 Copyright (C) 2001-2005 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 
00199     virtual std::string ExportURL(void) = 0;
00200 
00205     virtual Transport *Allocate(void) = 0;
00206 
00212     virtual Error Listen(const int channel = TransportAnyGameChannel) = 0;
00213 
00219     virtual Error Connect(const std::string address) = 0;
00220 
00225     virtual Transport *Accept(void) = 0;
00226 
00234     virtual Error Send(const char *data,const int len) = 0;
00235 
00243     virtual Error SendReliable(const char *data,const int len) = 0;
00244 
00252     virtual Error SendCertain(const char *data,const int len) = 0;
00253 
00260     virtual int Recv(char *const data,const int maxlen) = 0;
00261 
00266     virtual int GetMaxPacketSize(void) = 0;
00267 
00272     virtual std::string HandleDiscovery(void) = 0;
00273 
00278     virtual void HandleDiscoveryReply(const std::string reply) = 0;
00279 
00283     virtual void BeginDiscovery(void) = 0;
00284 
00289     virtual std::string GetNextDiscovery(void) = 0;
00290 
00295     virtual Error GetStatus(void) = 0;
00296 
00297 private:
00298 };
00299 
00300 } // namespace RNReplicaNet
00301 
00302 #endif

Generated on Sun Oct 30 01:12:16 2005 for XPURL by  doxygen 1.4.1