Browse Source

added delete/remove functions

FlorianPalm 10 years ago
parent
commit
bb1509967b

+ 5 - 0
src/ua_services_session.c

@@ -31,11 +31,16 @@ UA_Int32 Service_CreateSession(UA_Session session, const UA_CreateSessionRequest
 UA_Int32 Service_ActivateSession(UA_Session session, const UA_ActivateSessionRequest *request, UA_ActivateSessionResponse *response) {
 
 	// FIXME: activate session
+
+	//UA_Session_bind(session,)
+
+
 	UA_NodeId_printf("ActivateSession - authToken=", &(request->requestHeader.authenticationToken));
 	// 321 == AnonymousIdentityToken_Encoding_DefaultBinary
 	UA_NodeId_printf("ActivateSession - uIdToken.type=", &(request->userIdentityToken.typeId));
 	UA_ByteString_printx_hex("ActivateSession - uIdToken.body=", &(request->userIdentityToken.body));
 	UA_Session_setApplicationPointer(session,&appMockup);
+
 	// FIXME: channel->session->application = <Application Ptr>
 	//FIXME channel->session = &sessionMockup;
 	return UA_SUCCESS;

+ 19 - 1
src/ua_stack_session.c

@@ -13,7 +13,6 @@ typedef struct UA_SessionType
 	UA_NodeId authenticationToken;
 	UA_NodeId sessionId;
 	UA_String name;
-	void *applicationPayload;
 	Application *application;
 	UA_list_List pendingRequests;
 	SL_secureChannel channel;
@@ -52,6 +51,18 @@ UA_Int32 UA_Session_generateAuthenticationToken(UA_NodeId *newToken)
 
 	return retval;
 }
+
+UA_Int32 UA_Session_bind(UA_Session session, SL_secureChannel channel)
+{
+
+	if(channel && session)
+	{
+		((UA_SessionType*)session)->channel = channel;
+		return UA_SUCCESS;
+	}
+	return UA_ERROR;
+}
+
 UA_Int32 UA_Session_new(UA_Session **newSession)
 {
 	UA_Int32 retval = UA_SUCCESS;
@@ -66,6 +77,13 @@ UA_Int32 UA_Session_new(UA_Session **newSession)
 	return retval;
 }
 
+UA_Int32 UA_Session_delete(UA_Session *session)
+{
+	UA_Int32 retval = UA_SUCCESS;
+	retval |= UA_free((UA_SessionType*)(*session));
+	return retval;
+}
+
 UA_Int32 UA_Session_init(UA_Session session, UA_String *sessionName, UA_Double requestedSessionTimeout,
 		UA_UInt32 maxRequestMessageSize,
 		UA_UInt32 maxResponseMessageSize,

+ 2 - 2
src/ua_stack_session.h

@@ -20,12 +20,12 @@ UA_Int32 UA_Session_init(UA_Session session, UA_String *sessionName, UA_Double r
 		UA_UInt32 maxRequestMessageSize,
 		UA_UInt32 maxResponseMessageSize,
 		UA_Session_idProvider idProvider);
-
+UA_Int32 UA_Session_delete(UA_Session *session);
 
 UA_Boolean UA_Session_compare(UA_Session session1, UA_Session session2);
 UA_Boolean UA_Session_compareByToken(UA_Session session, UA_NodeId *token);
 UA_Boolean UA_Session_compareById(UA_Session session, UA_NodeId *sessionId);
-
+UA_Int32 UA_Session_bind(UA_Session session, SL_secureChannel channel);
 UA_Int32 UA_Session_getId(UA_Session session, UA_NodeId *sessionId);
 UA_Int32 UA_Session_getToken(UA_Session session, UA_NodeId *authenticationToken);
 UA_Int32 UA_Session_getChannel(UA_Session session, SL_secureChannel *channel);

+ 11 - 2
src/ua_stack_session_manager.c

@@ -118,7 +118,16 @@ UA_Int32 UA_SessionManager_addSession(UA_Session *session)
 }
 
 
-/*UA_Int32 UA_SessionManager_removeSession(UA_Int32 channelId);
+UA_Int32 UA_SessionManager_removeSession(UA_NodeId *sessionId)
+{
+	UA_Int32 retval = UA_SUCCESS;
+	UA_list_Element *element = UA_list_search(&sessionManager->sessions,(UA_list_PayloadComparer)UA_Session_compare,sessionId);
+	if(element)
+	{
+		retval |= UA_list_removeElement(element,(UA_list_PayloadVisitor)UA_Session_delete);
+	}
+	return retval;
+}
 
 UA_Int32 UA_SessionManager_getSession(UA_UInt32 sessionId, UA_Session *session);
 
@@ -129,4 +138,4 @@ UA_Int32 UA_SessionManager_getSessionLifeTime(UA_DateTime *lifeTime);
 UA_Int32 SL_UA_SessionManager_generateToken(SL_secureChannel channel, UA_Int32 requestedLifeTime, SecurityTokenRequestType requestType, UA_ChannelSecurityToken* newToken);
 
 UA_Int32 SL_UA_SessionManager_generateSessionId(UA_UInt32 *newChannelId);
-*/
+

+ 2 - 2
src/ua_stack_session_manager.h

@@ -36,10 +36,10 @@ UA_Int32 UA_SessionManager_addSession(UA_Session *session);
 
 /**
  * @brief removes a session from the manager list
- * @param sessionId removes a session by its id
+ * @param sessionId id which assign to a session
  * @return error code if all goes well UA_SUCCESS is returned
  */
-UA_Int32 UA_SessionManager_removeSession(UA_Int32 sessionId);
+UA_Int32 UA_SessionManager_removeSession(UA_NodeId *sessionId);
 
 /**
  * @brief finds the session which is identified by the sessionId