const SessionCommon * OperationCommon_GetSessionCommon(const OperationCommon * operation) { const SessionCommon * sessionCommon = NULL; if (operation != NULL) { // to get the common Session, we must know what kind of session it is SessionType sessionType = SessionType_Invalid; const Session * sessionBlind = OperationCommon_GetSession(operation, &sessionType); // use SessionType to safely cast and dereference the Session pointer switch (sessionType) { case SessionType_Client: sessionCommon = ClientSession_GetSessionCommon((const AwaClientSession *)sessionBlind); break; case SessionType_Server: sessionCommon = ServerSession_GetSessionCommon((const AwaServerSession *)sessionBlind); break; default: LogErrorWithEnum(AwaError_Internal, "Invalid SessionType %d", sessionType); break; } } else { LogErrorWithEnum(AwaError_OperationInvalid, "operation is NULL"); } return sessionCommon; }
AwaError AwaServerSession_SetDefaultTimeout(AwaServerSession * session, AwaTimeout timeout) { AwaError result = AwaError_Unspecified; if (session != NULL) { SessionCommon * sessionCommon = ServerSession_GetSessionCommon(session); if (sessionCommon != NULL) { result = SessionCommon_SetDefaultTimeout(sessionCommon, timeout); } else { result = LogErrorWithEnum(AwaError_SessionInvalid, "sessionCommon is NULL"); } } else { result = LogErrorWithEnum(AwaError_SessionInvalid, "session is NULL"); } return result; }