2 * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
4 * This program is licensed under the terms and conditions of the
5 * Apache License, version 2.0. The full text of the Apache License is at
6 * http://www.apache.org/licenses/LICENSE-2.0
10 //==========================================================================
12 * @file CicoSCServer.h
14 * @brief This file is definition of CicoSCServer class
16 //==========================================================================
17 #ifndef __CICO_SC_SERVER_H__
18 #define __CICO_SC_SERVER_H__
30 #include <sys/epoll.h>
39 //==========================================================================
40 // forward declaration
41 //==========================================================================
42 class CicoSCUwsHandler;
45 class CicoSCWindowController;
46 class CicoSCInputController;
47 class CicoSCUserManager;
48 class CicoSCResourceManager;
50 //==========================================================================
52 * @brief This class has function of interprocess message server
54 //==========================================================================
58 // get CicoSCServer instance
59 static CicoSCServer* getInstance();
61 // set window controller instance
62 void setWindowCtrl(CicoSCWindowController* windowCtrl);
64 // set input controller instance
65 void setInputCtrl(CicoSCInputController* inputCtrl);
67 // set input controller instance
68 void setUserMgr(CicoSCUserManager* userMgr);
70 // set resource manager instance
71 void setResourceMgr(CicoSCResourceManager* resourceMgr);
74 int startup(int port, const char *protocol);
76 // send message to application client
77 int sendMessage(const string & appid, CicoSCMessage* msg);
79 // send message to homescreen
80 int sendMessageToHomeScreen(CicoSCMessage* msg);
82 // websocket callback function
83 void receiveEventCB(const struct ico_uws_context *context,
84 const ico_uws_evt_e event,
86 const ico_uws_detail *detail,
90 // default constructor
96 // assignment operator
97 CicoSCServer& operator=(const CicoSCServer &object);
100 CicoSCServer(const CicoSCServer &object);
102 // websocket utility callback function
103 static void uwsReceiveEventCB(const struct ico_uws_context *context,
104 const ico_uws_evt_e event,
106 const ico_uws_detail *detail,
109 // ecore file destructor callback fucntion
110 static Eina_Bool ecoreFdCallback(void *data,
111 Ecore_Fd_Handler *handler);
113 // add poll websocket file destructor
114 void addPollFd(CicoSCUwsHandler *handler);
116 // delete poll websocket file destructor
117 void delPollFd(CicoSCUwsHandler *handler);
119 // dispatch receive message process and send message process
120 void dispatch(const CicoSCUwsHandler *handler);
122 // find websocket handle by context and id
123 CicoSCUwsHandler* findUwsHandler(const struct ico_uws_context *context,
126 // find websocket handle by ecore file destructor handler
127 CicoSCUwsHandler* findUwsHandler(const Ecore_Fd_Handler *ecoreFdHandler);
129 // find websocket handle by appid
130 CicoSCUwsHandler* findUwsHandler(const string & appid);
132 // query whether the handler exists
133 bool isExistUwsHandler(const CicoSCUwsHandler *handler);
136 static CicoSCServer* ms_myInstance; ///< this class instance
138 struct ico_uws_context *m_uwsContext; ///< websocket utility context
140 CicoSCWindowController *m_windowCtrl; ///< window controller instance
141 CicoSCInputController *m_inputCtrl; ///< input controller instance
142 CicoSCUserManager *m_userMgr; ///< user manager instance
143 CicoSCResourceManager *m_resourceMgr; ///< resource manager instance
145 list<CicoSCUwsHandler*> m_uwsHandlerList;///< websocket handler list
146 list<CicoSCMessage*> m_sendMsgQueue; ///< send message queue
147 list<CicoSCCommand*> m_recvCmdQueue; ///< recieve message queue
149 #endif // __CICO_SC_SERVER_H__
150 // vim:set expandtab ts=4 sw=4: