CEL

Public API Reference

physicallayer/network.h

00001 /*
00002     Crystal Space Entity Layer
00003     Copyright (C) 2005 by Christian Van Brussel
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public
00016     License along with this library; if not, write to the Free
00017     Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00018 */
00019 
00020 #ifndef __CEL_PL_NETWORK__
00021 #define __CEL_PL_NETWORK__
00022 
00023 #include "cstypes.h"
00024 #include "csutil/scf.h"
00025 #include "csutil/strset.h"
00026 
00027 struct iCelEntity;
00028 struct iCelDataBuffer;
00029 enum celNetworkGameType;
00030 enum celServerNetworkState;
00031 enum celPlayerNetworkState;
00032 struct celGame;
00033 class celGameInfo;
00034 class celPlayer;
00035 struct iCelPlayerList;
00036 class celServerEventData;
00037 class celClientEventData;
00038 class celNetworkLinkData;
00039 class celGameFactoryManager;
00040 class celGameClientManager;
00041 class celGameServerManager;
00042 struct celNetworkServerStats;
00043 struct celNetworkPlayerStats;
00044 struct celNetworkServerTotalStats;
00045 
00046 SCF_VERSION (iCelGame, 0, 0, 1);
00047 
00052 struct iCelGame : public iBase
00053 {
00057   virtual celNetworkGameType GetGameType () const = 0;
00058 
00062   virtual celGameInfo* GetGameInfo () = 0;
00063 
00068   virtual bool IsServerAvailable () const = 0;
00069 
00073   virtual iCelGameServer* GetGameServer () const = 0;
00074 
00079   virtual bool IsClientAvailable () const = 0;
00080 
00084   virtual iCelGameClient* GetGameClient () const = 0;
00085 };
00086 
00087 SCF_VERSION (iCelGameFactory, 0, 0, 1);
00088 
00101 struct iCelGameFactory : public iBase
00102 {
00109   virtual void SetGameName (csString game_name) = 0;
00110 
00115   virtual csString GetGameName () const = 0;
00116 
00129   virtual void SetProtocolVersion (const csString protocol_version) = 0;
00130 
00136   virtual csString GetProtocolVersion () const = 0;
00137 
00144   virtual void RegisterGameFactoryManager (
00145         celGameFactoryManager* manager) = 0;
00146 
00156   virtual void StartSearchForGameList (celNetworkGameType game_type, 
00157         celGameInfo* filter = 0) = 0;
00158 
00163   virtual void StopSearchForGameList () = 0;
00164 
00168   virtual iCelGame* GetCurrentGame () const = 0;
00169 
00183   virtual bool CreateNewGame (celNetworkGameType game_type, 
00184         celGameInfo* game_info, celPlayer* player = 0) = 0;
00185 
00198   virtual bool ConnectGame (celGameInfo* game_info, 
00199         celPlayer* player) = 0;
00200 
00206   virtual bool CloseGame () = 0;
00207 
00211   virtual void StartRecordingGame (csString filename) = 0;
00212 
00216   virtual void StopRecordingGame () = 0;
00217 
00224   virtual void StartPlayBackGame (csString filename, 
00225         csTicks start_time, csTicks stop_time) = 0;
00226 };
00227 
00240 class celGameFactoryManager
00241 {
00242  public:
00251   virtual void GameInfoReceived (celGameInfo* game_info, 
00252         csTicks server_latency) {}
00253 
00271   virtual void ServerNetworkStateChanged (celServerNetworkState new_state, 
00272         celServerNetworkState previous_state, csString reason = "") = 0;
00273 
00285   virtual bool InitClient (iCelGame* game) { return true; }
00286 
00294   virtual bool InitServer (iCelGame* game) { return true; }
00295 
00304   virtual csPtr<iCelDataBuffer> GetClientEventBaseline (
00305         celClientEventType event_type) { return 0; }
00306 
00312   virtual csPtr<iCelDataBuffer> GetServerEventBaseline (
00313         celServerEventType event_type) { return 0; }
00314 
00320   virtual csPtr<iCelDataBuffer> GetNetworkLinkBaseline (
00321         celNetworkLinkType link_type) { return 0; }
00322 
00323 };
00324 
00325 SCF_VERSION (iCelGameServer, 0, 0, 1);
00326 
00341 struct iCelGameServer : public iBase
00342 {
00347   virtual void RegisterServerManager (celGameServerManager* manager) = 0;
00348 
00353   virtual void SetAdministrator (celPlayer* new_admin) = 0;
00354 
00359   virtual celPlayer* GetAdministrator () = 0;
00360 
00364   virtual iCelPlayerList* GetPlayerList () = 0;
00365 
00369   virtual celPlayerNetworkState GetPlayerState (celPlayer* player) = 0;
00370 
00376   virtual void KickPlayer (celPlayer* player, csString reason) = 0;
00377 
00385   virtual iCelPlayerList* CreateChannel (csStringID channel_id) = 0;
00386 
00391   virtual void RemoveChannel (csStringID channel_id) = 0;
00392 
00396   virtual void LaunchServerEvent (celPlayer* player, 
00397         celServerEventData &event_data) = 0;
00398 
00402   virtual void LaunchServerEvent (csStringID channel_id, 
00403         celServerEventData &event_data) = 0;
00404 
00421   virtual void SetNetworkLink (celPlayer* player, 
00422         celNetworkLinkData &link_data, bool player_controlled) = 0;
00423 
00433   virtual void ChangeLinkControl (iCelEntity* entity, celPlayer* player, 
00434         bool player_controlled) = 0;
00435 
00446   virtual void SetNetworkLink (csStringID channel_id, 
00447         celNetworkLinkData &link_data) = 0;
00448 
00453   virtual void RemoveNetworkLink (iCelEntity* entity, celPlayer* player) = 0;
00454 
00459   virtual void RemoveNetworkLink (iCelEntity* entity,
00460         csStringID channel_id) = 0;
00461 
00469   virtual void ChangeLevel (celGameInfo* new_game) = 0;
00470 
00476   virtual void SetNetworkPeriod (csTicks period) = 0;
00477 
00482   virtual void SetMaximumBandwidth (size_t width) = 0;
00483 
00489   virtual void SetClientTimeOut (csTicks timeout) = 0;
00490 
00494   virtual void GetNetworkPlayerStats (celPlayer* player, 
00495         celNetworkPlayerStats& stats) const = 0;
00496 
00500   virtual void GetNetworkTotalStats (
00501         celNetworkPlayerTotalStats& stats) const = 0;
00502 };
00503 
00504 SCF_VERSION (iCelGameClient, 0, 0, 1);
00505 
00519 struct iCelGameClient : public iBase
00520 {
00525   virtual void RegisterClientManager (celGameClientManager* manager) = 0;
00526 
00530   virtual celPlayer* GetPlayer () = 0;
00531 
00537   virtual void UpdatePlayer (celPlayer* player) = 0;
00538 
00542   virtual csTicks ConvertServerClock (csTicks server_time) const = 0;
00543 
00548   virtual uint GetMappedID (uint entity_id) const = 0;
00549 
00554   virtual iCelEntity* GetMappedEntity (uint entity_id) const = 0;
00555 
00559   virtual void SetReady () = 0;
00560 
00564   virtual void LaunchClientEvent (celClientEventData &event_data) = 0;
00565 
00569   virtual void SetNetworkPeriod (csTicks period) = 0;
00570 
00575   virtual void SetMaximumBandwidth (size_t width) = 0;
00576 
00581   virtual void SetServerTimeOut (csTicks timeout) = 0;
00582 
00586   virtual void GetNetworkStats (celNetworkServerStats& stats) const = 0;
00587 };
00588 
00602 class celGameServerManager
00603 {
00604  public:
00611   virtual bool AuthorizePlayer (celPlayer* player, csString &reason) = 0;
00612 
00618   virtual celPlayer* ValidatePlayerUpdate (celPlayer* previous_player_data) = 0;
00619 
00623   virtual void PlayerNetworkStateChanged (celPlayer* player, 
00624         celPlayerNetworkState new_state, 
00625         celPlayerNetworkState previous_state) = 0;
00626 
00630   virtual void HandleClientEvent (celPlayer* player, 
00631         celClientEventType event_type, csTicks event_time, 
00632         iCelDataBuffer* event_data) = 0;
00633 
00642   virtual void PersistenceProblem (celPlayer* player, iCelEntity* entity,
00643         iCelPropertyClass* pc, celPersistenceResult persist_code) = 0;
00644 
00649   virtual void ServerEnd () = 0;
00650 };
00651 
00664 class celGameClientManager
00665 {
00666  public:
00670   virtual void PlayerValidated (celPlayer* player) = 0;
00671 
00675   virtual void HandleServerEvent (celServerEventType event_type, 
00676         csTicks event_time, iCelDataBuffer* event_data) = 0;
00677 
00693   virtual iCelEntity* CreateNetworkLinkTarget (celNetworkLinkType link_type, 
00694         csTicks creation_time, iCelPersistentDataList* creation_data, 
00695         bool player_controlled) = 0;
00696 
00710   virtual void NetworkLinkControlChanged (iCelEntity* entity, 
00711         bool player_controlled) = 0;
00712 
00717   virtual void NetworkLinkRemoved (csTicks deletion_time,
00718         iCelEntity* entity) = 0;
00719 
00724   virtual void LevelChanged (celGameInfo* new_game) = 0;
00725 
00730   virtual void ClientEnd () = 0;
00731 };
00732 
00733 #endif // __CEL_PL_NETWORK__

Generated for CEL: Crystal Entity Layer by doxygen 1.4.7