#!/usr/bin/env python
"""
This script demonstrates the way of requesting service.
"""
#-*- encoding: utf-8 -*-
__author__ = 'shehzad ahmed'
import rospy
from ros_services_examples.srv import *

class DemoClass():
    def __init__(self):
        self.server = rospy.Service('node_info_query', NodeInfoQuery, self.service_callback)

    def service_callback(self, req):
        rospy.loginfo("pequest recieved from: %s",req.node_name.data)

        resp = NodeInfoQueryResponse()
        resp.node_id.data = 1.0
        return resp

def initlize_node():
    '''
    Initilize node and spin which simply keeps python 
    from exiting until this node is stopped
    '''
    rospy.init_node('server_python_class_based_example_node', anonymous=False)
    rospy.loginfo("server_python_class_based_example_node is now running")

    demo_class = DemoClass()
    rospy.spin()

if __name__ == '__main__':
    initlize_node()