srv-converse.h

Go to the documentation of this file.
00001 /*
00002  * srv-converse.h
00003  *
00004  * Copyright (C) 2008,2009  Thomas A. Vaughan
00005  * All rights reserved.
00006  *
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted provided that the following conditions are met:
00010  *     * Redistributions of source code must retain the above copyright
00011  *       notice, this list of conditions and the following disclaimer.
00012  *     * Redistributions in binary form must reproduce the above copyright
00013  *       notice, this list of conditions and the following disclaimer in the
00014  *       documentation and/or other materials provided with the distribution.
00015  *     * Neither the name of the <organization> nor the
00016  *       names of its contributors may be used to endorse or promote products
00017  *       derived from this software without specific prior written permission.
00018  *
00019  * THIS SOFTWARE IS PROVIDED BY THOMAS A. VAUGHAN ''AS IS'' AND ANY
00020  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00021  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00022  * DISCLAIMED. IN NO EVENT SHALL THOMAS A. VAUGHAN BE LIABLE FOR ANY
00023  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00024  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00025  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00026  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00027  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00028  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029  *
00030  *
00031  * Root header for the aesop server.  This is the core (game-independent) server
00032  * code that powers multiplayer online aesops.
00033  */
00034 
00035 #ifndef AESOP_SRV_CONVERSE_H__
00036 #define AESOP_SRV_CONVERSE_H__
00037 
00038 // includes --------------------------------------------------------------------
00039 #include "conversation/conversation.h"
00040 #include "crypto/crypto.h"
00041 
00042 
00043 namespace aesop {
00044 
00045 
00046 // forward declarations
00047 class StateUpdates;
00048 class UserManager;
00049 
00050 
00051 typedef dword_t conn_id_t;
00052 
00053 /// \ingroup aesop_srv
00054 /*@{*/
00055 
00056 
00057 ////////////////////////////////////////////////////////////////////////////////
00058 //
00059 //      data structures used by host creation APIs (below)
00060 //
00061 ////////////////////////////////////////////////////////////////////////////////
00062 
00063 #define VALID_CHECK(exp, msg) if (!(exp)) { DPRINTF(msg); return false; }
00064 
00065 
00066 /// used to create a conversation for new players
00067 struct new_player_conv_data_t {
00068         // constructor, manipulators
00069         new_player_conv_data_t(void) throw() { this->clear(); }
00070         void clear(void) throw() {
00071                         connId = 0;
00072                         playerId = 0;
00073                         updates = NULL;
00074                         userMgr = NULL;
00075                 }
00076         bool isValid(void) const throw() {
00077                         VALID_CHECK(connId, "invalid connection id");
00078                         VALID_CHECK(playerId > 0, "Invalid player id");
00079                         VALID_CHECK(updates, "null");
00080                         VALID_CHECK(userMgr, "null");
00081                         return true;
00082                 }
00083 
00084         // data fields
00085         conn_id_t               connId;
00086         int                     playerId;
00087         StateUpdates *          updates;
00088         UserManager *           userMgr;
00089 };
00090 
00091 
00092 
00093 /// used to create a conversation for server admins
00094 struct admin_conv_data_t {
00095         // constructor, manipulators
00096         admin_conv_data_t(void) throw() { this->clear(); }
00097         void clear(void) throw() {
00098                 }
00099         bool isValid(void) const throw() {
00100                         return true;
00101                 }
00102 
00103         // data fields
00104 };
00105 
00106 
00107 
00108 ////////////////////////////////////////////////////////////////////////////////
00109 //
00110 //      Host creation APIs
00111 //
00112 ////////////////////////////////////////////////////////////////////////////////
00113 
00114 smart_ptr<converse::ConversationHost> createNewPlayerConversationHost(
00115                                 IN smart_ptr<crypto::DESKey>& desKey,
00116                                 IN new_player_conv_data_t& data);
00117 
00118 
00119 smart_ptr<converse::ConversationHost> createAdminConversationHost(
00120                                 IN admin_conv_data_t& data);
00121 
00122 
00123 
00124 };      // aesop namespace
00125 
00126 #endif  // AESOP_SRV_CONVERSE_H__
00127