|
S60 3rd Edition SDK for Symbian OS Example Applications Guide |
#include <SIPExGameEngine.h>
Inheritance diagram for CSIPExEngine:

Public Types | |
| enum | TPeer { EUnknown, EClient, EServer } |
| enum | TEngineState { EIdle, EEnabled, EActivating, EActive } |
Public Member Functions | |
| IMPORT_C | ~CSIPExEngine () |
| IMPORT_C void | SendInstantMsgL (const TDesC &aAddress, const TDesC &aMsg) |
| IMPORT_C void | InviteL (const TDesC &aAddress) |
| IMPORT_C void | EnableProfileL () |
| IMPORT_C void | DisableProfileL () |
| IMPORT_C void | EndGameL () |
| IMPORT_C TBool | DrawCursor () |
| IMPORT_C TBool | DrawBoard () |
| IMPORT_C void | CursorLeft () |
| IMPORT_C void | CursorRight () |
| IMPORT_C void | CursorPressed () |
| IMPORT_C void | MoveCursorL (const TInt aNewCursorPosition) |
| IMPORT_C TInt | BoardValue (TInt aX, TInt aY) |
| IMPORT_C TInt | Cursor () |
| IMPORT_C void | SetViewNotifier (MSIPExStateViewNotifier &aNotifier) |
| void | SocketState (TInt aNewState) |
| void | SocketData (TDesC8 &aData) |
Static Public Member Functions | |
| static IMPORT_C CSIPExEngine * | NewL (MSIPExGameObserver &aGameObserver) |
| static IMPORT_C CSIPExEngine * | NewLC (MSIPExGameObserver &aGameObserver) |
Private Member Functions | |
| void | InviteReceived (const TDesC8 &aFrom, const TUint32 aIapId) |
| void | InviteReceivedByRemote (const TInt aResponse) |
| void | InviteDeclinedByRemote (const TInt aResponse) |
| void | InviteAcceptedByRemote (const TInetAddr &aIPAddress, const TUint32 aIapId) |
| void | InviteAcceptedByUs () |
| void | InvitationCancelled () |
| void | EngineError (TInt aError) |
| void | CancelFailed () |
| void | SessionEnded () |
| void | ConnectionLost () |
| void | ProfileEnabled (TUint32 aSIPProfileId) |
| void | ProfileError (TInt aError) |
| void | IMReceived (const TDesC8 &aFrom, const TDesC8 &aMessage) |
| void | WriteLog (const TDesC8 &aLog) |
| void | ResetGame () |
| void | DestroySocketEngine () |
| void | ChangeState (TSIPExState &aNewState) |
| void | SendMessage (const TInt aX, const TInt aY) |
| void | StatusInfoL (const TDesC &aTxt) |
| void | InfoL (const TDesC &aInfoTxt) |
| TInt | CalculatePos () |
| TInt | IsWin (const TInt aX, const TInt aY) |
| TInt | Moves () |
| void | SetBoard (const TInt aX, const TInt aY, const TInt aValue) |
| void | IncreaseMovesBy (const TInt aAmount) |
| void | SetCursor (const TInt aNewValue) |
| TPeer | Peer () |
| void | SetPeer (TPeer aPeer) |
| void | SetRemote (const TInt aX, const TInt aY) |
| TBool | AcceptInvitationL (const TDesC8 &aFrom) |
| CSIPExSIPEngine * | SIPEngine () |
| CSIPExSocketEngine * | SocketEngineL () |
| MSIPExGameObserver & | GameObserver () |
| CSIPExEngine (MSIPExGameObserver &aGameObserver) | |
| void | ConstructL () |
Private Attributes | |
| TSIPExState * | iStateIdle |
| TSIPExState * | iStateRegistering |
| TSIPExState * | iStateRegistered |
| TSIPExState * | iStateInviting |
| TSIPExState * | iStateConnecting |
| TSIPExState * | iStateLocal |
| TSIPExState * | iStateRemote |
| TSIPExState * | iStateAcceptingSIP |
| MSIPExStateViewNotifier * | iNotifier |
| CSIPExSocketEngine * | iSocketEngine |
| CSIPExSIPEngine * | iSIPEngine |
| MSIPExGameObserver & | iGameObserver |
| TInt | iMoves |
| TInt | iBoard [KBoxCountX][KBoxCountY] |
| TInt | iCursor |
| TPeer | iPeer |
| TSIPExState * | iActiveState |
Friends | |
| class | TSIPExState |
| class | TSIPExStateAcceptingSIP |
| class | TSIPExStateConnecting |
| class | TSIPExStateIdle |
| class | TSIPExStateInviting |
| class | TSIPExStateLocal |
| class | TSIPExStateRegistered |
| class | TSIPExStateRegistering |
| class | TSIPExStateRemote |
Definition at line 46 of file SIPExGameEngine.h.
|
|
Enumerations for the application role. The inviting peer acts as a client and invited peer as a server. Definition at line 80 of file SIPExGameEngine.h.
|
|
|
Game engine states for UI. Definition at line 90 of file SIPExGameEngine.h.
|
|
|
Destructor. Definition at line 82 of file SIPExGameEngine.cpp. References DestroySocketEngine(), iSIPEngine, iStateAcceptingSIP, iStateConnecting, iStateIdle, iStateInviting, iStateLocal, iStateRegistered, iStateRegistering, and iStateRemote. 00083 { 00084 DestroySocketEngine(); 00085 delete iSIPEngine; 00086 00087 // Delete all state objects 00088 delete iStateIdle; 00089 delete iStateRegistering; 00090 delete iStateRegistered; 00091 delete iStateInviting; 00092 delete iStateConnecting; 00093 delete iStateLocal; 00094 delete iStateRemote; 00095 delete iStateAcceptingSIP; 00096 }
|
|
|
Constructor
Definition at line 72 of file SIPExGameEngine.cpp. 00073 : iGameObserver( aGameObserver ) 00074 { 00075 }
|
|
|
Create new instance of GameEngine.
Definition at line 47 of file SIPExGameEngine.cpp. References NewLC(). 00048 { 00049 CSIPExEngine* self = NewLC( aGameObserver ); 00050 CleanupStack::Pop(self); 00051 return self; 00052 }
|
|
|
Create new instance of GameEngine. The GameEngine pointer is left to the CleanupStack returned.
Definition at line 59 of file SIPExGameEngine.cpp. References CSIPExEngine(). 00060 { 00061 CSIPExEngine* self = new (ELeave) CSIPExEngine( aGameObserver ); 00062 CleanupStack::PushL(self); 00063 self->ConstructL(); 00064 return self; 00065 }
|
|
||||||||||||
|
The instant message is send to the remote user. Redirects the call to the active State object.
Definition at line 383 of file SIPExGameEngine.cpp. References iActiveState, and TSIPExState::SendInstantMsgL(). 00386 { 00387 iActiveState->SendInstantMsgL( this, aAddress, aMsg ); 00388 }
|
|
|
Player invites the remote peer to the game. Redirectes the call to the active State object.
Definition at line 353 of file SIPExGameEngine.cpp. References iActiveState, and TSIPExState::InviteL(). 00354 { 00355 iActiveState->InviteL( this, aAddress ); 00356 }
|
|
|
The SIP profile is enabled. Redirectes the call to the active State object. Definition at line 363 of file SIPExGameEngine.cpp. References TSIPExState::EnableProfileL(), and iActiveState. 00364 { 00365 iActiveState->EnableProfileL( this ); 00366 }
|
|
|
The SIP profile is disabled. Redirectes the call to the active State object. Definition at line 373 of file SIPExGameEngine.cpp. References TSIPExState::DisableProfileL(), and iActiveState. 00374 { 00375 iActiveState->DisableProfileL( this ); 00376 }
|
|
|
The user ends the game. Redirectes the call to the active State object. Definition at line 395 of file SIPExGameEngine.cpp. References TSIPExState::EndGameL(), and iActiveState. 00396 { 00397 iActiveState->EndGameL( this ); 00398 }
|
|
|
Resolves whether we should draw cursor or not.
Definition at line 405 of file SIPExGameEngine.cpp. References TSIPExState::DrawCursor(), and iActiveState. 00406 { 00407 return iActiveState->DrawCursor(); 00408 }
|
|
|
Resolves whether we should draw board or not.
Definition at line 415 of file SIPExGameEngine.cpp. References TSIPExState::DrawBoard(), and iActiveState. 00416 { 00417 return iActiveState->DrawBoard(); 00418 }
|
|
|
Updates the game state. User has pressed left key. Definition at line 425 of file SIPExGameEngine.cpp. References TSIPExState::CursorLeft(), and iActiveState. 00426 { 00427 iActiveState->CursorLeft( this ); 00428 }
|
|
|
Updates the game state. User has pressed right key. Definition at line 435 of file SIPExGameEngine.cpp. References TSIPExState::CursorRight(), and iActiveState. 00436 { 00437 iActiveState->CursorRight( this ); 00438 }
|
|
|
Updates the game state. User has pressed enter key. Definition at line 445 of file SIPExGameEngine.cpp. References TSIPExState::CursorPressed(), and iActiveState. 00446 { 00447 iActiveState->CursorPressed( this ); 00448 }
|
|
|
Updatas the game state. User moves the cursor with pointer.
Definition at line 455 of file SIPExGameEngine.cpp. References iActiveState, and TSIPExState::MoveCursorL(). 00456 { 00457 iActiveState->MoveCursorL( this, aNewValue ); 00458 }
|
|
||||||||||||
|
Returns value in specified place in the board.
Definition at line 188 of file SIPExGameEngine.cpp. References iBoard. 00189 { 00190 __ASSERT_DEBUG( aX < KBoxCountX && aY < KBoxCountY, 00191 Panic( EBoardValueOOR ) ); 00192 return iBoard[ aX ][ aY ]; 00193 }
|
|
|
Returns the cursor position.
Definition at line 200 of file SIPExGameEngine.cpp. References iCursor. 00201 { 00202 return iCursor; 00203 }
|
|
|
Sets the iNotifier.
Definition at line 136 of file SIPExGameEngine.cpp. References iNotifier. 00137 { 00138 iNotifier = &aNotifier; 00139 }
|
|
|
Callback from socket observer. Called when the state changes in the socket engine.
Implements MSIPExSocketEngineObserver. Definition at line 534 of file SIPExGameEngine.cpp. References iActiveState, and TSIPExState::SocketState(). 00535 { 00536 iActiveState->SocketState( this, aNewState ); 00537 }
|
|
|
Callback from socket observer. Called when the data is received from the socket.
Implements MSIPExSocketEngineObserver. Definition at line 545 of file SIPExGameEngine.cpp. References iActiveState, and TSIPExState::SocketData(). 00546 { 00547 iActiveState->SocketData( this, aData ); 00548 }
|
|
||||||||||||
|
InviteReceived Called when an INVITE is received by the SIP Client.
Implements MSIPExSIPEngineObserver. Definition at line 559 of file SIPExGameEngine.cpp. References iActiveState, and TSIPExState::InviteReceived(). 00560 { 00561 iActiveState->InviteReceived( this, aFrom, aIapId ); 00562 }
|
|
|
InviteReceivedByRemote Called when a provisional response (1xx, not 100 (Trying)) is received after sending INVITE. Implements MSIPExSIPEngineObserver. Definition at line 601 of file SIPExGameEngine.cpp. References iActiveState, and TSIPExState::InviteReceivedByRemote(). 00602 { 00603 iActiveState->InviteReceivedByRemote( this, aResponse ); 00604 }
|
|
|
InviteDeclinedByRemote Called when a 4xx, 5xx, or 6xx response is received after sending INVITE. As the session isn't established, the engine should be deleted.
Implements MSIPExSIPEngineObserver. Definition at line 591 of file SIPExGameEngine.cpp. References iActiveState, and TSIPExState::InviteDeclinedByRemote(). 00592 { 00593 iActiveState->InviteDeclinedByRemote( this, aResponse ); 00594 }
|
|
||||||||||||
|
InviteAcceptedByRemote Called when the response 200 (OK) is received after sending INVITE.
Implements MSIPExSIPEngineObserver. Definition at line 569 of file SIPExGameEngine.cpp. References iActiveState, and TSIPExState::InviteAcceptedByRemote(). 00572 { 00573 iActiveState->InviteAcceptedByRemote( this, aIPAddress, aIapId ); 00574 }
|
|
|
InviteAcceptedByUs Called when the response ACK is received after responding with 200 (OK) to an invitation. Implements MSIPExSIPEngineObserver. Definition at line 581 of file SIPExGameEngine.cpp. References iActiveState, and TSIPExState::InviteAcceptedByUs(). 00582 { 00583 iActiveState->InviteAcceptedByUs( this ); 00584 }
|
|
|
InvitationCancelled Called when an INVITE has been successfully cancelled. Implements MSIPExSIPEngineObserver. Definition at line 621 of file SIPExGameEngine.cpp. References iActiveState, and TSIPExState::InvitationCancelled(). 00622 { 00623 iActiveState->InvitationCancelled( this ); 00624 }
|
|
|
EngineError Called when an error occurs in the SIP Example SIP Engine.
Implements MSIPExSIPEngineObserver. Definition at line 611 of file SIPExGameEngine.cpp. References TSIPExState::EngineError(), and iActiveState. 00612 { 00613 iActiveState->EngineError( this, aError ); 00614 }
|
|
|
CancelFailed Called when the cancellation of an INVITE fails. Implements MSIPExSIPEngineObserver. Definition at line 631 of file SIPExGameEngine.cpp. References TSIPExState::CancelFailed(), and iActiveState. 00632 { 00633 iActiveState->CancelFailed( this ); 00634 }
|
|
|
SessionEnded Called when the session has been closed, ie. when the the response 200 (OK) is received after sending BYE, or after 200 (OK) has been sent after receiving BYE. Or we have declined a received INVITE. The observer should delete the engine. Implements MSIPExSIPEngineObserver. Definition at line 641 of file SIPExGameEngine.cpp. References iActiveState, and TSIPExState::SessionEnded(). 00642 { 00643 iActiveState->SessionEnded( this ); 00644 }
|
|
|
ConnectionLost Called when the connection is lost because of an error. The observer should delete the engine. Implements MSIPExSIPEngineObserver. Definition at line 651 of file SIPExGameEngine.cpp. References TSIPExState::ConnectionLost(), and iActiveState. 00652 { 00653 iActiveState->ConnectionLost( this ); 00654 }
|
|
|
ProfileEnabled Called when the EnableProfile method has completed successfully.
Implements MSIPExSIPEngineObserver. Definition at line 661 of file SIPExGameEngine.cpp. References iActiveState, and TSIPExState::ProfileEnabled(). 00662 { 00663 iActiveState->ProfileEnabled( this, aSIPProfileId ); 00664 }
|
|
|
ProfileError An error has occurred during a profile operation
Implements MSIPExSIPEngineObserver. Definition at line 671 of file SIPExGameEngine.cpp. References iActiveState, and TSIPExState::ProfileError(). 00672 { 00673 iActiveState->ProfileError( this, aError ); 00674 }
|
|
||||||||||||
|
IMReceived Called when an Instant Message is received.
Implements MSIPExSIPEngineObserver. Definition at line 681 of file SIPExGameEngine.cpp. References iActiveState, and TSIPExState::IMReceived(). 00683 { 00684 iActiveState->IMReceived( this, aFrom, aMessage ); 00685 }
|
|
|
WriteLog
Implements MSIPExSIPEngineObserver. Definition at line 692 of file SIPExGameEngine.cpp. References iNotifier, and MSIPExStateViewNotifier::ShowInfoL(). 00693 { 00694 if( iNotifier ) 00695 { 00696 TRAPD( ignore, iNotifier->ShowInfoL( aLog ) ); 00697 } 00698 }
|
|
|
Initilizes the game state. Definition at line 146 of file SIPExGameEngine.cpp. References iBoard, iCursor, iMoves, and iPeer. 00147 { 00148 for ( TInt i=0 ; i < KBoxCountX; i++ ) 00149 { 00150 for ( TInt j=0 ; j < KBoxCountY; j++ ) 00151 { 00152 iBoard[i][j] = -1; 00153 } 00154 } 00155 00156 iCursor = 0; 00157 iMoves = 0; 00158 iPeer = EUnknown; 00159 }
|
|
|
Destroys the iSocketEngine. Definition at line 303 of file SIPExGameEngine.cpp. References iSocketEngine. 00304 { 00305 delete iSocketEngine; 00306 iSocketEngine = NULL; 00307 }
|
|
|
Changes the active state.
Definition at line 220 of file SIPExGameEngine.cpp. References MSIPExGameObserver::GameStateChanged(), iActiveState, iGameObserver, iStateAcceptingSIP, iStateConnecting, iStateIdle, iStateInviting, iStateLocal, iStateRegistered, iStateRegistering, and iStateRemote. 00221 { 00222 iActiveState = &aNewState; 00223 00224 TEngineState state( EIdle ); 00225 if( iActiveState == iStateIdle || iActiveState == iStateRegistering ) 00226 { 00227 state = EIdle; 00228 } 00229 else if( iActiveState == iStateRegistered ) 00230 { 00231 state = EEnabled; 00232 } 00233 else if ( iActiveState == iStateInviting || 00234 iActiveState == iStateAcceptingSIP || 00235 iActiveState == iStateConnecting ) 00236 { 00237 state = EActivating; 00238 } 00239 else if( iActiveState == iStateLocal || iActiveState == iStateRemote ) 00240 { 00241 state = EActive; 00242 } 00243 else { /*Nothing to do*/ } 00244 00245 iGameObserver.GameStateChanged( state ); 00246 }
|
|
||||||||||||
|
Send the move to the remote peer.
Definition at line 253 of file SIPExGameEngine.cpp. References iSocketEngine, and CSIPExSocketEngine::Write(). 00254 { 00255 __ASSERT_DEBUG( aX < KBoxCountX && aY < KBoxCountY, 00256 Panic( EBoardValueOOR ) ); 00257 00258 TBuf8<8> msg; 00259 msg.Format( KMoveFormatStr(), aX, aY ); 00260 00261 iSocketEngine->Write( msg ); 00262 }
|
|
|
Shows the text in the status info area. The call is redirected to the view notifier.
Definition at line 281 of file SIPExGameEngine.cpp. References iNotifier, and MSIPExStateViewNotifier::ShowStatusInfoL(). 00282 { 00283 __ASSERT_DEBUG( iNotifier, Panic( ENoGameViewNotifier ) ); 00284 00285 iNotifier->ShowStatusInfoL( aTxt ); 00286 }
|
|
|
Shows the text in the info area. The call is redirected to the view notifier.
Definition at line 269 of file SIPExGameEngine.cpp. References iNotifier, and MSIPExStateViewNotifier::ShowInfoL(). 00270 { 00271 __ASSERT_DEBUG( iNotifier, Panic( ENoGameViewNotifier ) ); 00272 00273 iNotifier->ShowInfoL( aInfoTxt ); 00274 }
|
|
|
Calculates the next free place in cursor's column.
Definition at line 465 of file SIPExGameEngine.cpp. References TSIPExState::CalculatePos(), and iActiveState. 00466 { 00467 return iActiveState->CalculatePos( this ); 00468 }
|
|
||||||||||||
|
Checks if the move is win move.
Definition at line 475 of file SIPExGameEngine.cpp. References iActiveState, and TSIPExState::IsWin(). 00476 { 00477 return iActiveState->IsWin( this, aX, aY ); 00478 }
|
|
|
Returns the count of moves in this game.
Definition at line 485 of file SIPExGameEngine.cpp. References iMoves. 00486 { 00487 return iMoves; 00488 }
|
|
||||||||||||||||
|
Sets the specified value in to the specified place in the board.
Definition at line 166 of file SIPExGameEngine.cpp. References iBoard. 00167 { 00168 __ASSERT_DEBUG( aX < KBoxCountX && aY < KBoxCountY, 00169 Panic( EBoardValueOOR ) ); 00170 iBoard[ aX ][ aY ] = aValue; 00171 }
|
|
|
Increases the moves value by specified amount.
Definition at line 178 of file SIPExGameEngine.cpp. References iMoves. 00179 { 00180 iMoves += aAmount; 00181 }
|
|
|
Set cursor the specified position.
Definition at line 210 of file SIPExGameEngine.cpp. References iCursor. 00211 { 00212 iCursor = aNewValue; 00213 }
|
|
|
Returns the peer value.
Definition at line 495 of file SIPExGameEngine.cpp. References iPeer. 00496 { 00497 return iPeer; 00498 }
|
|
|
Sets the iPeer's value
Definition at line 505 of file SIPExGameEngine.cpp. References iPeer. 00506 { 00507 iPeer = aPeer; 00508 }
|
|
||||||||||||
|
Sets remote peer's move to the board.
Definition at line 293 of file SIPExGameEngine.cpp. References SetBoard(). 00294 { 00295 SetBoard( aX, aY, 2 ); 00296 }
|
|
|
The acceptance is asked from the user Redirectes the call to the game observer.
Definition at line 515 of file SIPExGameEngine.cpp. References MSIPExGameObserver::AcceptInvitationL(), and iGameObserver. 00516 { 00517 HBufC* from = HBufC::NewLC( aFrom.Length() ); 00518 from->Des().Copy( aFrom ); 00519 TBool retVal = iGameObserver.AcceptInvitationL( *from ); 00520 CleanupStack::PopAndDestroy( from ); 00521 return retVal; 00522 }
|
|
|
Returns the SIP Engine pointer.
Definition at line 314 of file SIPExGameEngine.cpp. References iSIPEngine. 00315 { 00316 return iSIPEngine; 00317 }
|
|
|
Returns the socket engine. If the socket engine (iSocketEngine) is NULL it will be created.
Definition at line 325 of file SIPExGameEngine.cpp. References iSocketEngine, and CSIPExSocketEngine::NewL(). 00326 { 00327 if( !iSocketEngine ) 00328 { 00329 iSocketEngine = CSIPExSocketEngine::NewL( *this ); 00330 } 00331 return iSocketEngine; 00332 }
|
|
|
Returns the game observer reference.
Definition at line 339 of file SIPExGameEngine.cpp. References iGameObserver. 00340 { 00341 return iGameObserver; 00342 }
|
|
|
© Nokia 2006 |