XPSession.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 __XPSESSION_H__
00012 #define __XPSESSION_H__
00013 #include "RNPlatform/Inc/DLLExportAPI.h"
00014 
00015 #define _XPSESSION_VERSION 5900
00016 // All DLL versions with the same major version are compatible
00017 #define _XPSESSION_DLLVERSIONMAJOR 16
00018 #define _XPSESSION_DLLVERSIONMINOR 0
00019 
00020 #include <string>
00021 
00022 #include "RNXPURL/Inc/Transport.h"
00023 
00024 namespace RNReplicaNet
00025 {
00026 
00027 const int kXPSessionUnknownID = -1;
00028 const int kXPSessionBroadcastID = -2;
00029 
00030 /* These are the internal message types for session messages */
00031 const unsigned char kXPSessionPacketType_Unreliable     = 0;
00032 const unsigned char kXPSessionPacketType_Reliable       = (1<<0);
00033 const unsigned char kXPSessionPacketType_Certain        = (1<<1);
00034 
00048 class XPSESSIONDLL_API XPSession
00049 {
00050 public:
00051 
00055     enum Error
00056     {
00057         kXPSession_EOK = 0,                     
00058         kXPSession_EERROR = -1,                 
00059         kXPSession_ETRANSPORT_CLOSED = -2,
00060         kXPSession_ETRANSPORT_ERROR = -3
00061     };
00062 
00066     XPSession() {};
00067 
00072     virtual ~XPSession() {};
00073 
00078     static XPSession *Allocate(void);
00079 
00085     virtual void Create(const std::string name) = 0;
00086 
00093     virtual void Create(const std::string name,const std::string protocols) = 0;
00094 
00106     virtual std::string ExportURL(const bool shortAddress = true) = 0;
00107 
00113     virtual void Join(const std::string url) = 0;
00114 
00118     virtual void Find(void) = 0;
00119 
00124     virtual void Find(const std::string protocols) = 0;
00125 
00130     virtual std::string EnumerateFound(void) = 0;
00131 
00136     virtual int GetGameChannel(void) = 0;
00137 
00142     virtual void SetGameChannel(const int channel = TransportAnyGameChannel) = 0;
00143 
00148     virtual int GetSessionID(void) = 0;
00149 
00154     virtual bool IsStable(void) = 0;
00155 
00161     virtual Error GetStatus(void) = 0;
00162 
00171     virtual Error GetSessionErrorReason(void) = 0;
00172 
00185     virtual void DataSendToSession(const int sessionid,const char *data,const int length,const bool reliable = true,const bool certain = false,const unsigned int band = 0) = 0;
00186 
00193     virtual void DataSendToSessionUnreliable(const int sessionid,const char *data,const int length) = 0;
00194 
00202     virtual void DataSendToSessionReliable(const int sessionid,const char *data,const int length,const unsigned int band = 0) = 0;
00203 
00210     virtual void DataSendToSessionCertain(const int sessionid,const char *data,const int length) = 0;
00211 
00219     virtual bool DataReceivePeek(int *const fromsessionid,int *const length,unsigned char *const type = 0) = 0;
00220 
00229     virtual bool DataReceive(int *const fromsessionid,char *const data,int *const length,unsigned char *const type = 0) = 0;
00230 
00235     virtual bool IsMaster(void) = 0;
00236 
00241     virtual int GetJoiner(void) = 0;
00242 
00247     virtual int GetLeaver(void) = 0;
00248 
00253     virtual float GetTime(void) = 0;
00254 
00259     virtual float GetLocalTime(void) = 0;
00260 
00265     virtual float GetNetworkSendRate(void) = 0;
00266 
00271     virtual float GetNetworkReceiveRate(void) = 0;
00272 
00277     virtual int GetNetworkPacketsLost(void) = 0;
00278 
00286     virtual void Poll(void) = 0;
00287 
00293     virtual void SetPollLayerBelow(bool enable = true) = 0;
00294 
00299     virtual bool GetPollLayerBelow(void) = 0;
00300 
00307     virtual void SetManualPoll(void) = 0;
00308 
00316     virtual void SetAutomaticPoll(void) = 0;
00317 
00321     virtual void SetManualPollXPURL(void) = 0;
00322 
00326     virtual void SetAutomaticPollXPURL(void) = 0;
00327 
00328 
00334     virtual void SetCanSpider(const bool canSpider = true) = 0;
00335 
00340     virtual bool GetCanSpider(void) = 0;
00341 
00348     virtual void SetCanBecomeMaster(const bool canBeMaster = true) = 0;
00349 
00354     virtual bool GetCanBecomeMaster(void) = 0;
00355 
00360     virtual float GetLatencyToMasterSession(void) = 0;
00361 
00366     virtual float GetLatencyToSessionID(const int sessionID) = 0;
00367 
00372     virtual void SetLatencyRecalculationDelay(const float seconds = 1.0f) = 0;
00373 
00378     virtual void SetEncryption(const bool enable = false) = 0;
00379 
00383     virtual bool GetEncryption(void) = 0;
00384 
00385 
00390     virtual void Disconnect(const int sessionID = kXPSessionUnknownID) = 0;
00391 
00396     virtual bool GetPreConnectStatus(void) = 0;
00397 
00408     virtual void SetPreConnect(const bool enable = false) = 0;
00409 
00414     virtual bool GetPreConnect(void) = 0;
00415 
00419     virtual void PreConnectHasFinished(void) = 0;
00420 
00425     virtual void SetAutomaticPacketCompression(const bool enable = false) = 0;
00426 
00431     virtual bool GetAutomaticPacketCompression(void) = 0;
00432 
00439     virtual void GetCompressionStatistics(int *const before=0,int *const after=0,const bool reset = false) = 0;
00440 
00448     virtual void GetMergedStatistics(int *const sent=0,int *const received=0,const bool reset = false) = 0;
00449 
00454     virtual int GetMasterSessionID(void) = 0;
00455 
00462     virtual std::string GetURLFromSessionID(const int sessionID) = 0;
00463 
00469     virtual void SetClientOnly(const bool isClient = false) = 0;
00470 
00475     virtual bool GetClientOnly(void) = 0;
00476 
00487     virtual bool GetBandwidthFromSessionID(const int sessionID,Transport::Bandwidth *const bandwidth,int *const output,int *const input) = 0;
00488 
00493     virtual void SetAllowConnections(const bool allow = true) = 0;
00494 
00499     virtual bool GetAllowConnections(void) = 0;
00500 
00505     virtual void SetNodeBuffers(const bool enable = false) = 0;
00506 
00511     virtual bool GetNodeBuffers(void) = 0;
00512 
00513 private:
00514 };
00515 
00516 } // namespace RNReplicaNet
00517 
00518 #endif

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