fix stream creation to include channelNo; correctly return success

from sym_send; fix to build in standalone case.
This commit is contained in:
ehouse 2005-03-20 19:55:49 +00:00
parent 29ca361020
commit 2056f20002

View file

@ -226,12 +226,13 @@ CXWordsAppView::sym_util_getVTManager( XW_UtilCtxt* uc )
#ifndef XWFEATURE_STANDALONE_ONLY #ifndef XWFEATURE_STANDALONE_ONLY
/*static*/ XWStreamCtxt* /*static*/ XWStreamCtxt*
CXWordsAppView::sym_util_makeStreamFromAddr( XW_UtilCtxt* uc, CXWordsAppView::sym_util_makeStreamFromAddr( XW_UtilCtxt* uc,
XP_U16 /*channelNo*/ ) XP_U16 channelNo )
{ {
XP_LOGF( "sym_util_makeStreamFromAddr called" ); XP_LOGF( "sym_util_makeStreamFromAddr called" );
CXWordsAppView* self = (CXWordsAppView*)uc->closure; CXWordsAppView* self = (CXWordsAppView*)uc->closure;
XP_ASSERT( self->iGame.comms ); XP_ASSERT( self->iGame.comms );
return self->MakeSimpleStream( self->sym_send_on_close ); return self->MakeSimpleStream( self->sym_send_on_close,
channelNo );
} }
#endif #endif
@ -564,6 +565,11 @@ CXWordsAppView::MakeOrLoadGameL()
if ( iCurGameName.Length() > 0 && iGamesMgr->Exists( &iCurGameName ) ) { if ( iCurGameName.Length() > 0 && iGamesMgr->Exists( &iCurGameName ) ) {
LoadOneGameL( &iCurGameName ); LoadOneGameL( &iCurGameName );
} else { } else {
/***************************************************************
* PENDING The code here duplicates DoNewGame. Unify the two!!!!
***************************************************************/
gi_initPlayerInfo( MPPARM(mpool) &iGi, (XP_UCHAR*)"Player %d" ); gi_initPlayerInfo( MPPARM(mpool) &iGi, (XP_UCHAR*)"Player %d" );
#ifndef XWFEATURE_STANDALONE_ONLY #ifndef XWFEATURE_STANDALONE_ONLY
@ -599,9 +605,14 @@ CXWordsAppView::MakeOrLoadGameL()
&iUtil, iDraw, newGameID, &iCp, &iUtil, iDraw, newGameID, &iCp,
SYM_SEND, this ); SYM_SEND, this );
model_setDictionary( iGame.model, dict ); model_setDictionary( iGame.model, dict );
#ifndef XWFEATURE_STANDALONE_ONLY #ifndef XWFEATURE_STANDALONE_ONLY
if ( iGame.comms ) { if ( iGame.comms ) {
comms_setAddr( iGame.comms, &iCommsAddr ); comms_setAddr( iGame.comms, &iCommsAddr );
if ( iGi.serverRole == SERVER_ISCLIENT ) {
XWStreamCtxt* stream = MakeSimpleStream( sym_send_on_close );
server_initClientConnection( iGame.server, stream );
}
} }
#endif #endif
@ -762,6 +773,13 @@ CXWordsAppView::HandleCommand( TInt aCommand )
draw = board_toggle_showValues( iGame.board ); draw = board_toggle_showValues( iGame.board );
break; break;
#ifndef XWFEATURE_STANDALONE_ONLY
case XW_RESEND_COMMAND:
if ( iGame.comms != NULL ) {
(void)comms_resendAll( iGame.comms );
}
#endif
default: default:
return 0; return 0;
} }
@ -839,8 +857,11 @@ CXWordsAppView::TimerCallback( TAny* aPtr )
{ {
CXWordsAppView* me = (CXWordsAppView*)aPtr; CXWordsAppView* me = (CXWordsAppView*)aPtr;
if ( 0 ) {
#ifndef XWFEATURE_STANDALONE_ONLY
/* Only do one per call. Packets are higher priority */ /* Only do one per call. Packets are higher priority */
if ( me->iTimerReasons[EProcessPacket] > 0 ) { } else if ( me->iTimerReasons[EProcessPacket] > 0 ) {
--me->iTimerReasons[EProcessPacket]; --me->iTimerReasons[EProcessPacket];
XP_ASSERT( me->iTimerReasons[EProcessPacket] == 0 ); XP_ASSERT( me->iTimerReasons[EProcessPacket] == 0 );
@ -863,7 +884,7 @@ CXWordsAppView::TimerCallback( TAny* aPtr )
if ( draw ) { if ( draw ) {
me->DoImmediateDraw(); me->DoImmediateDraw();
} }
#endif
} else if ( me->iTimerReasons[EUtilRequest] > 0 ) { } else if ( me->iTimerReasons[EUtilRequest] > 0 ) {
--me->iTimerReasons[EUtilRequest]; --me->iTimerReasons[EUtilRequest];
if ( server_do( me->iGame.server ) ) { if ( server_do( me->iGame.server ) ) {
@ -875,11 +896,12 @@ CXWordsAppView::TimerCallback( TAny* aPtr )
} }
XWStreamCtxt* XWStreamCtxt*
CXWordsAppView::MakeSimpleStream( MemStreamCloseCallback cb ) CXWordsAppView::MakeSimpleStream( MemStreamCloseCallback cb,
XP_U16 channelNo )
{ {
return mem_stream_make( MPPARM(mpool) return mem_stream_make( MPPARM(mpool)
iVtMgr, (void*)this, iVtMgr, (void*)this,
CHANNEL_NONE, cb ); channelNo, cb );
} /* MakeSimpleStream */ } /* MakeSimpleStream */
void void
@ -1275,7 +1297,9 @@ CXWordsAppView::sym_send( XP_U8* aBuf, XP_U16 aLen, CommsAddrRec* aAddr,
aAddr = &addr; aAddr = &addr;
} }
self->iSendSock->SendL( aBuf, aLen, aAddr ); if ( self->iSendSock->SendL( aBuf, aLen, aAddr ) ) {
result = aLen;
}
/* Can't call listen until we've sent something.... */ /* Can't call listen until we've sent something.... */
self->iSendSock->Listen(); self->iSendSock->Listen();
@ -1288,7 +1312,6 @@ CXWordsAppView::sym_send_on_close( XWStreamCtxt* aStream, void* aClosure )
{ {
XP_LOGF( "sym_send_on_close called" ); XP_LOGF( "sym_send_on_close called" );
CXWordsAppView* self = (CXWordsAppView*)aClosure; CXWordsAppView* self = (CXWordsAppView*)aClosure;
CommsConnType conType = comms_getConType( self->iGame.comms );
comms_send( self->iGame.comms, aStream ); comms_send( self->iGame.comms, aStream );
} }