Exemplo n.º 1
0
//--------------------------------------------------------------------------------------------------
void avData_Init
(
    void
)
{
    SessionStateEvent = le_event_CreateId("Session state", sizeof(le_avdata_SessionState_t));

    // Create safe reference map for session request references. The size of the map should be based on
    // the expected number of simultaneous requests for session. 5 of them seems reasonable.
    AvSessionRequestRefMap = le_ref_CreateMap("AVSessionRequestRef", 5);

    FieldEventDataPoolRef = le_mem_CreatePool("Field event data pool", sizeof(FieldEventData_t));
    InstanceRefDataPoolRef = le_mem_CreatePool("Instance ref data pool", sizeof(InstanceRefData_t));

    // Create safe reference map for instance references. The size of the map should be based on
    // the expected number of user data instances across all apps.  For now, budget for 30 apps
    // and 10 instances per app.  This can always be increased/decreased later, if needed.
    InstanceRefMap = le_ref_CreateMap("InstRefMap", 300);

    // Add a handler for client session closes
    le_msg_AddServiceCloseHandler(le_avdata_GetServiceRef(), ClientCloseSessionHandler, NULL);

    // Use a timer to delay releasing the session for 2 seconds.
    le_clk_Time_t timerInterval = { .sec=2, .usec=0 };

    SessionReleaseTimerRef = le_timer_Create("Session Release timer");
    le_timer_SetInterval(SessionReleaseTimerRef, timerInterval);
    le_timer_SetHandler(SessionReleaseTimerRef, SessionReleaseTimerHandler);
}
Exemplo n.º 2
0
//--------------------------------------------------------------------------------------------------
void AdvertiseService
(
    void
)
{
    LE_DEBUG("======= Starting Server %s ========", SERVICE_INSTANCE_NAME);

    le_msg_ProtocolRef_t protocolRef;

    // Create the server data pool
    _ServerDataPool = le_mem_CreatePool("ServerData", sizeof(_ServerData_t));

    // Create safe reference map for handler references.
    // The size of the map should be based on the number of handlers defined for the server.
    // Don't expect that to be more than 2-3, so use 3 as a reasonable guess.
    _HandlerRefMap = le_ref_CreateMap("ServerHandlers", 3);

    // Start the server side of the service
    protocolRef = le_msg_GetProtocolRef(PROTOCOL_ID_STR, sizeof(_Message_t));
    _ServerServiceRef = le_msg_CreateService(protocolRef, SERVICE_INSTANCE_NAME);
    le_msg_SetServiceRecvHandler(_ServerServiceRef, ServerMsgRecvHandler, NULL);
    le_msg_AdvertiseService(_ServerServiceRef);

    // Register for client sessions being closed
    le_msg_AddServiceCloseHandler(_ServerServiceRef, CleanupClientData, NULL);

    // Need to keep track of the thread that is registered to provide this service.
    _ServerThreadRef = le_thread_GetCurrent();
}
Exemplo n.º 3
0
//--------------------------------------------------------------------------------------------------
le_result_t le_mcc_Init
(
    void
)
{
    // Create a pool for Call objects
    MccCallPool = le_mem_CreatePool("MccCallPool", sizeof(struct le_mcc_Call));
    le_mem_ExpandPool(MccCallPool, MCC_MAX_CALL);
    le_mem_SetDestructor(MccCallPool, CallDestructor);

    SessionRefPool = le_mem_CreatePool("SessionRefPool", sizeof(SessionRefNode_t));
    le_mem_ExpandPool(SessionRefPool, MCC_MAX_CALL);

    // Create the Safe Reference Map to use for Call object Safe References.
    MccCallRefMap = le_ref_CreateMap("MccCallMap", MCC_MAX_CALL);

    // Initialize call wakeup source - succeeds or terminates caller
    WakeupSource = le_pm_NewWakeupSource(0, CALL_WAKEUP_SOURCE_NAME);

    CallStateEventId = le_event_CreateId("CallStateEventId", sizeof(le_mcc_CallRef_t));

    // Register a handler function for Call Event indications
    if(pa_mcc_SetCallEventHandler(NewCallEventHandler) != LE_OK)
    {
        LE_CRIT("Add pa_mcc_SetCallEventHandler failed");
        return LE_FAULT;
    }

    // Add a handler to the close session service
    le_msg_AddServiceCloseHandler( le_mcc_GetServiceRef(),
                                   CloseSessionEventHandler,
                                   NULL );

    return LE_OK;
}
Exemplo n.º 4
0
//--------------------------------------------------------------------------------------------------
void le_temp_Init
(
    void
)
{
    // Add a handler to the close session service
    le_msg_AddServiceCloseHandler(
                    le_temp_GetServiceRef(),
                    CloseSessionEventHandler,
                    NULL
    );

    // Create an event Id for temperature change notification
    TemperatureThresholdEventId = le_event_CreateIdWithRefCounting("TemperatureThresholdEvent");

    // Register a handler function for new temparute Threshold Event
    pa_temp_AddTempEventHandler (TemperatureChangeHandler);
}