ANSC_STATUS HttpTroRecvFromClient ( ANSC_HANDLE hThisObject, PVOID buffer, ULONG ulSize, ANSC_HANDLE hBufferContext ) { ANSC_STATUS returnStatus = ANSC_STATUS_SUCCESS; PHTTP_TRANS_RECORD_OBJECT pMyObject = (PHTTP_TRANS_RECORD_OBJECT )hThisObject; PHTTP_ADVANCED_PROXY_OBJECT pAdvancedProxy = (PHTTP_ADVANCED_PROXY_OBJECT )pMyObject->hOwnerContext; PHTTP_WAM_INTERFACE pWamIf = (PHTTP_WAM_INTERFACE )pMyObject->hWamIf; PHTTP_SBC_INTERFACE pSbcIf = (PHTTP_SBC_INTERFACE )pMyObject->hSbcIf; PANSC_DAEMON_SOCKET_TCP_OBJECT pClientSocket = (PANSC_DAEMON_SOCKET_TCP_OBJECT)pMyObject->hClientSocket; PANSC_BROKER_SOCKET_TCP_OBJECT pServerSocket = (PANSC_BROKER_SOCKET_TCP_OBJECT)pMyObject->hServerSocket; PANSC_BUFFER_DESCRIPTOR pBufferDesp = (PANSC_BUFFER_DESCRIPTOR )hBufferContext; PHTTP_BMO_REQ_OBJECT pBmoReq = (PHTTP_BMO_REQ_OBJECT )pMyObject->hBmoReq; ULONG ulBmoState = HTTP_BMO_STATE_EMPTY; /* * At time like this, you will always have two options on how to proceed with the message * processing: * * $ Examine the current object states and the content of the message payload * to make the processing decisions in this object. * * $ Offload the examination and certain state-transition functions to another * object and provide an interface to be notified when something happens. * * Guess which one we're using here ... */ buffer = AnscBdoGetBlock (pBufferDesp); ulSize = AnscBdoGetBlockSize(pBufferDesp); returnStatus = pBmoReq->Process ( (ANSC_HANDLE)pBmoReq, (ANSC_HANDLE)pBufferDesp ); if ( (returnStatus != ANSC_STATUS_SUCCESS ) && (returnStatus != ANSC_STATUS_DO_IT_AGAIN) ) { pMyObject->TransState = HTTP_TRO_STATE_FINISHED; } return returnStatus; }
ANSC_STATUS HttpWstoRecv ( ANSC_HANDLE hThisObject, PVOID buffer, ULONG ulSize, ANSC_HANDLE hBufferContext ) { ANSC_STATUS returnStatus = ANSC_STATUS_SUCCESS; PHTTP_WEBS_TRANS_OBJECT pMyObject = (PHTTP_WEBS_TRANS_OBJECT )hThisObject; PHTTP_SIMPLE_SERVER_OBJECT pSimpleServer = (PHTTP_SIMPLE_SERVER_OBJECT )pMyObject->hOwnerContext; PHTTP_WSP_INTERFACE pWspIf = (PHTTP_WSP_INTERFACE )pMyObject->hWspIf; PANSC_DAEMON_SOCKET_TCP_OBJECT pWebSocket = (PANSC_DAEMON_SOCKET_TCP_OBJECT)pMyObject->hWebSocket; PANSC_BUFFER_DESCRIPTOR pBufferDesp = (PANSC_BUFFER_DESCRIPTOR )hBufferContext; PHTTP_BMO_REQ_OBJECT pBmoReq = (PHTTP_BMO_REQ_OBJECT )pMyObject->hBmoReq; ULONG ulBmoState = HTTP_BMO_STATE_EMPTY; pBmoReq->SetFumIf((ANSC_HANDLE)pBmoReq, pSimpleServer->GetFumIf((ANSC_HANDLE)pSimpleServer)); pBmoReq->SetWebSessionId((ANSC_HANDLE)pBmoReq, (ULONG)pMyObject->hWebsSession); /* * At time like this, you will always have two options on how to proceed with the message * processing: * * $ Examine the current object states and the content of the message payload * to make the processing decisions in this object. * * $ Offload the examination and certain state-transition functions to another * object and provide an interface to be notified when something happens. * * Guess which one we're using here ... */ buffer = AnscBdoGetBlock (pBufferDesp); ulSize = AnscBdoGetBlockSize(pBufferDesp); returnStatus = pBmoReq->Process ( (ANSC_HANDLE)pBmoReq, (ANSC_HANDLE)pBufferDesp ); if ( (returnStatus != ANSC_STATUS_SUCCESS ) && (returnStatus != ANSC_STATUS_DO_IT_AGAIN) ) { pMyObject->TransState = HTTP_WSTO_STATE_FINISHED; } if ( (pMyObject->TransState == HTTP_WSTO_STATE_ESTABLISHED) || (pMyObject->TransState == HTTP_WSTO_STATE_FINISHED ) ) { /* * To avoid unnessary memory consumption, we release the resources allocated for this * transaction right away... */ pMyObject->Close((ANSC_HANDLE)pMyObject); } return returnStatus; }