Savarese Software Research Corporation
group_session/ws.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2006-2009 Savarese Software Research Corporation
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     https://www.savarese.com/software/ApacheLicense-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00022 #ifndef __SSRC_WSPR_GROUP_SESSION_WS_H
00023 #define __SSRC_WSPR_GROUP_SESSION_WS_H
00024 
00025 #include <ssrc/wispers/ws/protocol.h>
00026 #include <ssrc/wispers/group_session/protocol.h>
00027 
00028 __BEGIN_NS_SSRC_WSPR_GROUP_SESSION
00029 
00030 using NS_SSRC_WSPR_WS::WebServiceCall;
00031 
00032 WS_CALL_PARAM(param_find_sessions,
00033                   ((db_limit_type, limit))((db_offset_type, offset)));
00034 
00035 template<typename CallType,
00036          typename ParamType, typename DestinationType, typename CallerType>
00037 inline void call_find_sessions(CallerType & caller,
00038                                const WebServiceCall & call,
00039                                const ParamType & param,
00040                                const DestinationType & service,
00041                                const db_limit_type max_limit = 50)
00042 {
00043   if(call.session) {
00044     db_limit_type limit(param.limit);
00045     db_offset_type offset(param.offset);
00046 
00047     if(limit > max_limit || limit < 1)
00048       limit = max_limit;
00049     if(offset < 0)
00050       offset = 0;
00051     caller.template
00052       sendp<CallType>(service, call.session->uid, limit, offset);
00053   }
00054 }
00055 
00056 template<typename ResultType, typename DestinationType, typename CallerType>
00057 inline void
00058 process_find_group_sessions_result(CallerType & caller,
00059                                    const ResultType & msg,
00060                                    const string & session_type,
00061                                    const DestinationType & event_queue)
00062 {
00063   using NS_SSRC_WSPR_WS::WebServiceProtocol;
00064   using NS_SSRC_WSPR_WS::web_event_indirect;
00065   using NS_SSRC_WSPR_UTILITY::Properties;
00066   using NS_SSRC_WSPR_UTILITY::property_vector;
00067 
00068   WISP_IMPORT_T(WebServiceProtocol, MessageDeliverEvent);
00069   WISP_IMPORT_T(WebServiceProtocol, CallDeliverEvent);
00070 
00071   MessageDeliverEvent delivery;
00072   Properties & event =
00073     web_event_indirect(*delivery.template_data,
00074                        "wspr.GroupSession", "FindGroupSessions");
00075 
00076   delivery.keys.push_back(msg.requestor);
00077 
00078   event.set(msg.total_sessions, "total_sessions");
00079   event.set(msg.limit, "limit");
00080   event.set(msg.offset, "offset");
00081   event.set(session_type, "type");
00082   event.set(msg.gs_name, "gs_name");
00083 
00084   if(!msg.sessions.empty()) {
00085     property_vector & sessions = event.create_property_vector("sessions");
00086 
00087     for(group_session_container::const_iterator it = msg.sessions.begin(),
00088           end = msg.sessions.end(); it != end; ++it)
00089     {
00090       sessions.push_back(new Properties);
00091       bind_group_session_properties(*it, sessions.back());
00092     }
00093   }
00094 
00095   caller.template
00096     send<CallDeliverEvent>(event_queue, delivery);
00097 }
00098 
00099 __END_NS_SSRC_WSPR_GROUP_SESSION
00100 
00101 #endif

Savarese Software Research Corporation
Copyright © 2006-2011 Savarese Software Research Corporation. All rights reserved.