session->orig_remote_id = strdup(session->remote_id);
session->remote_service = strdup(remote_service);
+ #ifdef ASSUME_STATELESS
+ session->stateless = 1;
+ debug_handler("session is stateless");
+ #else
+ session->stateless = 0;
+ debug_handler("session is NOT stateless");
+ #endif
+
/* build a chunky, random session id */
char id[256];
memset(id,0,256);
- //srand((int)time(NULL));
sprintf(id, "%lf.%d%d", get_timestamp_millis(), (int)time(NULL), getpid());
session->session_id = strdup(id);
session->session_id = strdup(session_id);
session->remote_service = strdup(remote_service);
+ #ifdef ASSUME_STATELESS
+ session->stateless = 1;
+ #else
+ session->stateless = 0;
+ #endif
+
debug_handler( "Building a new server session [%s] with id [%s]",
session->remote_service, session_id );
if(session->state == OSRF_SESSION_DISCONNECTED)
return 1;
+
+ if(session->stateless && session->state != OSRF_SESSION_CONNECTED) {
+ debug_handler(
+ "Exiting disconnect on stateless session %s",
+ session->session_id);
+ return 1;
+ }
+
debug_handler( "AppSession disconnecting from %s", session->remote_id );
osrf_message* dis_msg = osrf_message_init( DISCONNECT, session->thread_trace, 1 );
debug_handler( "AppSession sending type %d, and thread_trace %d",
msg->m_type, msg->thread_trace );
- if( (msg->m_type != CONNECT) && (msg->m_type != DISCONNECT) &&
- (session->state != OSRF_SESSION_CONNECTED) ) {
- if(!osrf_app_session_connect( session ))
- return 0;
+ if(session->stateless) {
+ osrf_app_session_reset_remote(session);
+
+ } else {
+
+ if( (msg->m_type != CONNECT) && (msg->m_type != DISCONNECT) &&
+ (session->state != OSRF_SESSION_CONNECTED) ) {
+ if(!osrf_app_session_connect( session ))
+ return 0;
+ }
}
char* xml = osrf_message_to_xml(msg);
#include "opensrf/osrf_message.h"
+#include "utils.h"
+#include "objson/object.h"
+#include "objson/json_parser.h"
+
/* default to true */
int parse_json_result = 1;
int parse_json_params = 1;
msg->result_string = strdup(json_string);
+ /* ----------------------------------------------------- */
+ object* o = json_parse_string(json_string);
+ char* string = o->to_json(o);
+ debug_handler("---------------------------------------------------");
+ debug_handler("Parsed JSON string \n%s\n", string);
+ if(o->classname)
+ debug_handler("Class is %s\n", o->classname);
+ debug_handler("---------------------------------------------------");
+ free_object(o);
+ free(string);
+ /* ----------------------------------------------------- */
+
debug_handler( "Message Parse JSON is set to: %d", msg->parse_json_result );
if(msg->parse_json_result)
if( msg->parse_json_params ) {
if( msg->params != NULL ) {
- params_node = xmlNewChild( method_node, NULL,
- BAD_CAST "params", BAD_CAST json_object_to_json_string( msg->params ) );
+
+ char* jj = json_object_to_json_string( msg->params );
+ params_node = xmlNewChild( method_node, NULL, BAD_CAST "params", NULL );
+ xmlNodePtr tt = xmlNewDocTextLen( doc, BAD_CAST jj, strlen(jj) );
+ xmlAddChild(params_node, tt);
}
+
} else {
if( msg->parray != NULL ) {