OpenMortal Apocalypse mirror
Sourceforge mirror
SourceForge.net Logo
      News | Info | Characters | Arenas | Screenshots | Forums | Download  
Developer: Making of | Character-HOWTO | AI Design | Submit a Character
Documentation: Main Page | Modules | Class Hierarchy | Class List | File List

OnlineChatBE.h

Go to the documentation of this file.
00001 //
00002 // C++ Interface: onlinechatbe
00003 //
00004 // Description: 
00005 //
00006 //
00007 // Author: upi <upi@apocalypse.rulez.org>, (C) 2004
00008 //
00009 // Copyright: See COPYING file that comes with this distribution
00010 //
00011 //
00012 #ifndef ONLINECHATBE_H
00013 #define ONLINECHATBE_H
00014 
00015 
00016 #include <string>
00017 
00018 
00019 class IOnlineEventSink;
00020 struct SOnlineChatBE_P;
00021 
00030 class IOnlineChatBE
00031 {
00032 public:
00033     enum ConnectionStateEnum
00034     {
00035         CS_Disconnected,                    
00036         CS_Connecting,                      
00037         CS_Connected,                       
00038         CS_Disconnecting,
00039     };
00040     
00041     enum ClientModeEnum
00042     {
00043         CM_Chatroom,                        
00044         CM_Game,                            
00045         CM_Away,                            
00046         CM_WaitingForChallenge,             
00047     };
00048     
00049     enum ChatEventEnum
00050     {
00051         CE_Nothing,
00052         CE_MyNick,                          
00053         CE_Challenge,                       
00054         CE_Message,                         
00055         CE_Joins,                           
00056         CE_Leaves,                          
00057         CE_NickChange,                      
00058         CE_ServerMessage,                   
00059     };
00060     
00061     struct UserInfo
00062     {
00063         std::string     m_sNick;            
00064         ClientModeEnum  m_enClientMode;     
00065         std::string     m_sHostName;        
00066         std::string     m_sHostAddress;     
00067         
00068         UserInfo();
00069         UserInfo( const UserInfo& a_roRhs );
00070         UserInfo& operator=( const UserInfo& a_roRhs );
00071     };
00072     
00073     struct SChatEvent
00074     {
00075         ChatEventEnum   m_enEvent;
00076         UserInfo        m_sUser;
00077         std::string     m_sMessage;
00078     };
00079     
00080 protected:
00081     
00082     // Lifecycle control
00083                         IOnlineChatBE() {}
00084     virtual             ~IOnlineChatBE() {}
00085 
00086 public:
00087     static void         create();
00088     
00089     // Connection
00090     
00091     virtual void                connect( std::string a_sNick ) = 0;
00092     virtual void                disconnect() = 0;
00093     virtual ConnectionStateEnum getConnectionState() const = 0;
00094     
00095     // Getting/setting my connection parameters
00096     
00097     virtual std::string         getMyNick() const = 0;
00098     virtual void                setMyNick( std::string a_sNick ) = 0;
00099     virtual ClientModeEnum      getMyClientMode() const = 0;
00100     virtual void                setMyClientMode( ClientModeEnum a_enClientMode ) = 0;
00101     virtual const UserInfo&     getMyUserInfo() const = 0;              
00102     
00103     // User control
00104     
00105     virtual int                 getUserCount() const = 0;
00106     virtual const UserInfo&     getUserInfo( int a_iUserNumber ) const = 0;
00107     virtual ClientModeEnum      getClientMode() const = 0;
00108     virtual void                setClientMode( ClientModeEnum a_newMode ) = 0;
00109     
00110     // Event sinks
00111     
00112     virtual void                addEventSink( IOnlineEventSink* a_poSink ) = 0;
00113     virtual void                removeEventSink( IOnlineEventSink* a_poSink ) = 0;
00114     virtual void                removeAllEventSinks() = 0;
00115 };
00116 
00117 
00118 extern IOnlineChatBE*   g_poChatBE;
00119 
00120 
00121 
00127 class IOnlineEventSink
00128 {
00129 public:
00130                         IOnlineEventSink() {}
00131     virtual             ~IOnlineEventSink() {}
00132     
00133     virtual void        receiveEvent( const IOnlineChatBE::SChatEvent& a_roEvent ) = 0;
00134     virtual void        connectionStateChange( IOnlineChatBE::ConnectionStateEnum a_enOldState, 
00135                                                IOnlineChatBE::ConnectionStateEnum a_enNewState,
00136                                                const std::string& a_rsMessage ) = 0;
00137 };
00138 
00139 
00140 
00141 
00142 #endif