blob: 756bacfd0232f408f5ffa3e5bd6e2b98d5783985 [file] [log] [blame]
San Mehat168415b2009-05-06 11:14:21 -07001/*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#ifndef _FRAMEWORKSOCKETLISTENER_H
17#define _FRAMEWORKSOCKETLISTENER_H
18
19#include "SocketListener.h"
20#include "FrameworkCommand.h"
21
San Mehatfa644ff2009-05-08 11:15:53 -070022class SocketClient;
23
San Mehat168415b2009-05-06 11:14:21 -070024class FrameworkListener : public SocketListener {
San Mehatc73a3a52009-06-15 14:06:03 -070025public:
Dmitry Shmidt1159d7f2010-03-09 10:45:27 -080026 static const int CMD_ARGS_MAX = 16;
Robert Greenwalt8702bb12012-02-07 12:23:14 -080027
28 /* 1 out of errorRate will be dropped */
29 int errorRate;
San Mehat168415b2009-05-06 11:14:21 -070030private:
Robert Greenwalt8702bb12012-02-07 12:23:14 -080031 int mCommandCount;
32 bool mWithSeq;
San Mehat168415b2009-05-06 11:14:21 -070033 FrameworkCommandCollection *mCommands;
34
35public:
36 FrameworkListener(const char *socketName);
Robert Greenwalt8702bb12012-02-07 12:23:14 -080037 FrameworkListener(const char *socketName, bool withSeq);
San Mehat168415b2009-05-06 11:14:21 -070038 virtual ~FrameworkListener() {}
39
40protected:
41 void registerCmd(FrameworkCommand *cmd);
San Mehatfa644ff2009-05-08 11:15:53 -070042 virtual bool onDataAvailable(SocketClient *c);
San Mehat168415b2009-05-06 11:14:21 -070043
44private:
San Mehatc73a3a52009-06-15 14:06:03 -070045 void dispatchCommand(SocketClient *c, char *data);
Robert Greenwalt8702bb12012-02-07 12:23:14 -080046 void init(const char *socketName, bool withSeq);
San Mehat168415b2009-05-06 11:14:21 -070047};
48#endif