blob: f1a4b43f8323f8b20b13ad39788a30b0f13638b9 [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:
Josef Kindberg6d358ae2011-02-23 12:40:44 +010026 static const int CMD_ARGS_MAX = 26;
Robert Greenwalt8702bb12012-02-07 12:23:14 -080027
28 /* 1 out of errorRate will be dropped */
29 int errorRate;
Josef Kindberg6d358ae2011-02-23 12:40:44 +010030
San Mehat168415b2009-05-06 11:14:21 -070031private:
Robert Greenwalt8702bb12012-02-07 12:23:14 -080032 int mCommandCount;
33 bool mWithSeq;
San Mehat168415b2009-05-06 11:14:21 -070034 FrameworkCommandCollection *mCommands;
35
36public:
37 FrameworkListener(const char *socketName);
Robert Greenwalt8702bb12012-02-07 12:23:14 -080038 FrameworkListener(const char *socketName, bool withSeq);
San Mehat168415b2009-05-06 11:14:21 -070039 virtual ~FrameworkListener() {}
40
41protected:
42 void registerCmd(FrameworkCommand *cmd);
San Mehatfa644ff2009-05-08 11:15:53 -070043 virtual bool onDataAvailable(SocketClient *c);
San Mehat168415b2009-05-06 11:14:21 -070044
45private:
San Mehatc73a3a52009-06-15 14:06:03 -070046 void dispatchCommand(SocketClient *c, char *data);
Robert Greenwalt8702bb12012-02-07 12:23:14 -080047 void init(const char *socketName, bool withSeq);
San Mehat168415b2009-05-06 11:14:21 -070048};
49#endif