diff --git a/internal/ccsmp/ccsmp_core.go b/internal/ccsmp/ccsmp_core.go index 7aa5e60..8cc7b61 100644 --- a/internal/ccsmp/ccsmp_core.go +++ b/internal/ccsmp/ccsmp_core.go @@ -300,9 +300,10 @@ func SolClientInitialize(props []string) *SolClientErrorInfoWrapper { func SolClientContextCreate() (context *SolClientContext, err *SolClientErrorInfoWrapper) { var contextP SolClientContextPt solClientErrorInfo := handleCcsmpError(func() SolClientReturnCode { - var contextFuncInfo C.solClient_context_createFuncInfo_t - return C.solClient_context_create(C.SOLCLIENT_CONTEXT_PROPS_DEFAULT_WITH_CREATE_THREAD, &contextP, &contextFuncInfo, 24) + // creates context with default properties + return C.SessionContextCreate(C.SOLCLIENT_CONTEXT_PROPS_DEFAULT_WITH_CREATE_THREAD, &contextP) }) + if solClientErrorInfo != nil { return nil, solClientErrorInfo } @@ -322,15 +323,13 @@ func (context *SolClientContext) SolClientSessionCreate(properties []string) (se sessionPropsP, sessionPropertiesFreeFunction := ToCArray(properties, true) defer sessionPropertiesFreeFunction() - var sessionFuncInfo C.solClient_session_createFuncInfo_t - sessionFuncInfo.rxMsgInfo.callback_p = (C.solClient_session_rxMsgCallbackFunc_t)(unsafe.Pointer(C.defaultMessageReceiveCallback)) - sessionFuncInfo.rxMsgInfo.user_p = nil - sessionFuncInfo.eventInfo.callback_p = (C.solClient_session_eventCallbackFunc_t)(unsafe.Pointer(C.eventCallback)) - sessionFuncInfo.eventInfo.user_p = nil - solClientErrorInfo := handleCcsmpError(func() SolClientReturnCode { - return C.solClient_session_create(sessionPropsP, context.pointer, &sessionP, &sessionFuncInfo, (C.size_t)(unsafe.Sizeof(sessionFuncInfo))) + // this will create a session and put the session pointer in sessionP + return C.SessionCreate(sessionPropsP, + context.pointer, + &sessionP) }) + if solClientErrorInfo != nil { return nil, solClientErrorInfo } diff --git a/internal/ccsmp/ccsmp_helper.c b/internal/ccsmp/ccsmp_helper.c index 431a093..cb74c62 100644 --- a/internal/ccsmp/ccsmp_helper.c +++ b/internal/ccsmp/ccsmp_helper.c @@ -24,12 +24,17 @@ solClient_rxMsgCallback_returnCode_t messageReceiveCallback(solClient_opaqueSession_pt opaqueSession_p, solClient_opaqueMsg_pt msg_p, void *user_p); +solClient_rxMsgCallback_returnCode_t +defaultMessageReceiveCallback(solClient_opaqueSession_pt opaqueSession_p, solClient_opaqueMsg_pt msg_p, void *user_p); + solClient_rxMsgCallback_returnCode_t requestResponseReplyMessageReceiveCallback(solClient_opaqueSession_pt opaqueSession_p, solClient_opaqueMsg_pt msg_p, void *user_p); solClient_rxMsgCallback_returnCode_t flowMessageReceiveCallback(solClient_opaqueFlow_pt opaqueFlow_p, solClient_opaqueMsg_pt msg_p, void *user_p); +void eventCallback(solClient_opaqueSession_pt opaqueSession_p, solClient_session_eventCallbackInfo_pt eventInfo_p, void *user_p); + void flowEventCallback(solClient_opaqueFlow_pt opaqueFlow_p, solClient_flow_eventCallbackInfo_pt eventInfo_p, void *user_p); solClient_returnCode_t @@ -53,6 +58,37 @@ solClientgo_msg_isRequestReponseMsg(solClient_opaqueMsg_pt msg_p, char **correla return SOLCLIENT_OK; } +solClient_returnCode_t +SessionCreate( solClient_propertyArray_pt sessionPropsP, + solClient_opaqueContext_pt contextP, + solClient_opaqueSession_pt *opaqueSession_p) +{ + /* allocate the session create struct */ + solClient_session_createFuncInfo_t sessionCreateFuncInfo; + sessionCreateFuncInfo.rxMsgInfo.callback_p = (solClient_session_rxMsgCallbackFunc_t)defaultMessageReceiveCallback; + sessionCreateFuncInfo.rxMsgInfo.user_p = NULL; + sessionCreateFuncInfo.eventInfo.callback_p = (solClient_session_eventCallbackFunc_t)eventCallback; + sessionCreateFuncInfo.eventInfo.user_p = NULL; + + sessionCreateFuncInfo.rxMsgInfo.callback_p = flowMessageReceiveCallback; + sessionCreateFuncInfo.eventInfo.callback_p = (solClient_flow_eventCallbackFunc_t)flowEventCallback; + + return solClient_session_create(sessionPropsP, contextP, opaqueSession_p, &sessionCreateFuncInfo, sizeof(sessionCreateFuncInfo)); +} + +solClient_returnCode_t +SessionContextCreate( solClient_propertyArray_pt contextPropsP, + solClient_opaqueContext_pt *contextP) +{ + /* allocate the session context create struct to NULL */ + solClient_context_createFuncInfo_t contextCreateFuncInfo; + contextCreateFuncInfo.regFdInfo.regFdFunc_p = NULL; + contextCreateFuncInfo.regFdInfo.unregFdFunc_p = NULL; + contextCreateFuncInfo.regFdInfo.user_p = NULL; + + return solClient_context_create(contextPropsP, &contextP, &contextCreateFuncInfo, sizeof(contextCreateFuncInfo)); +} + solClient_returnCode_t SessionFlowCreate( solClient_opaqueSession_pt opaqueSession_p, solClient_propertyArray_pt flowPropsP, diff --git a/internal/ccsmp/ccsmp_helper.h b/internal/ccsmp/ccsmp_helper.h index 04f2d8e..a70eef6 100644 --- a/internal/ccsmp/ccsmp_helper.h +++ b/internal/ccsmp/ccsmp_helper.h @@ -44,6 +44,15 @@ typedef struct solClient_errorInfo_wrapper * operating systems are supported, this may need to change to a more complex * definition. */ +solClient_returnCode_t SessionCreate( + solClient_propertyArray_pt sessionPropsP, + solClient_opaqueContext_pt contextP, + solClient_opaqueSession_pt *opaqueSession_p); + +solClient_returnCode_t SessionContextCreate( + solClient_propertyArray_pt contextPropsP, + solClient_opaqueContext_pt *contextP); + solClient_returnCode_t SessionFlowCreate( solClient_opaqueSession_pt opaqueSession_p, solClient_propertyArray_pt flowPropsP,