1168415b822cae1f8b54ef09c41c11a9b97b87f40San Mehat/*
2168415b822cae1f8b54ef09c41c11a9b97b87f40San Mehat * Copyright (C) 2008 The Android Open Source Project
3168415b822cae1f8b54ef09c41c11a9b97b87f40San Mehat *
4168415b822cae1f8b54ef09c41c11a9b97b87f40San Mehat * Licensed under the Apache License, Version 2.0 (the "License");
5168415b822cae1f8b54ef09c41c11a9b97b87f40San Mehat * you may not use this file except in compliance with the License.
6168415b822cae1f8b54ef09c41c11a9b97b87f40San Mehat * You may obtain a copy of the License at
7168415b822cae1f8b54ef09c41c11a9b97b87f40San Mehat *
8168415b822cae1f8b54ef09c41c11a9b97b87f40San Mehat *      http://www.apache.org/licenses/LICENSE-2.0
9168415b822cae1f8b54ef09c41c11a9b97b87f40San Mehat *
10168415b822cae1f8b54ef09c41c11a9b97b87f40San Mehat * Unless required by applicable law or agreed to in writing, software
11168415b822cae1f8b54ef09c41c11a9b97b87f40San Mehat * distributed under the License is distributed on an "AS IS" BASIS,
12168415b822cae1f8b54ef09c41c11a9b97b87f40San Mehat * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13168415b822cae1f8b54ef09c41c11a9b97b87f40San Mehat * See the License for the specific language governing permissions and
14168415b822cae1f8b54ef09c41c11a9b97b87f40San Mehat * limitations under the License.
15168415b822cae1f8b54ef09c41c11a9b97b87f40San Mehat */
16168415b822cae1f8b54ef09c41c11a9b97b87f40San Mehat#ifndef _FRAMEWORKSOCKETLISTENER_H
17168415b822cae1f8b54ef09c41c11a9b97b87f40San Mehat#define _FRAMEWORKSOCKETLISTENER_H
18168415b822cae1f8b54ef09c41c11a9b97b87f40San Mehat
19168415b822cae1f8b54ef09c41c11a9b97b87f40San Mehat#include "SocketListener.h"
20168415b822cae1f8b54ef09c41c11a9b97b87f40San Mehat#include "FrameworkCommand.h"
21168415b822cae1f8b54ef09c41c11a9b97b87f40San Mehat
22fa644ffe944c01a9b00f8d7676d58394fabee285San Mehatclass SocketClient;
23fa644ffe944c01a9b00f8d7676d58394fabee285San Mehat
24168415b822cae1f8b54ef09c41c11a9b97b87f40San Mehatclass FrameworkListener : public SocketListener {
25c73a3a5771a2d29d1bae666bfde12f751d66fc96San Mehatpublic:
261159d7f800e5ddaf9d2d994e23d11e2f6dd67b8eDmitry Shmidt    static const int CMD_ARGS_MAX = 16;
278702bb17f40022e970e8acd40b348d074e39afc7Robert Greenwalt
288702bb17f40022e970e8acd40b348d074e39afc7Robert Greenwalt    /* 1 out of errorRate will be dropped */
298702bb17f40022e970e8acd40b348d074e39afc7Robert Greenwalt    int errorRate;
30168415b822cae1f8b54ef09c41c11a9b97b87f40San Mehatprivate:
318702bb17f40022e970e8acd40b348d074e39afc7Robert Greenwalt    int mCommandCount;
328702bb17f40022e970e8acd40b348d074e39afc7Robert Greenwalt    bool mWithSeq;
33168415b822cae1f8b54ef09c41c11a9b97b87f40San Mehat    FrameworkCommandCollection *mCommands;
34168415b822cae1f8b54ef09c41c11a9b97b87f40San Mehat
35168415b822cae1f8b54ef09c41c11a9b97b87f40San Mehatpublic:
36168415b822cae1f8b54ef09c41c11a9b97b87f40San Mehat    FrameworkListener(const char *socketName);
378702bb17f40022e970e8acd40b348d074e39afc7Robert Greenwalt    FrameworkListener(const char *socketName, bool withSeq);
38168415b822cae1f8b54ef09c41c11a9b97b87f40San Mehat    virtual ~FrameworkListener() {}
39168415b822cae1f8b54ef09c41c11a9b97b87f40San Mehat
40168415b822cae1f8b54ef09c41c11a9b97b87f40San Mehatprotected:
41168415b822cae1f8b54ef09c41c11a9b97b87f40San Mehat    void registerCmd(FrameworkCommand *cmd);
42fa644ffe944c01a9b00f8d7676d58394fabee285San Mehat    virtual bool onDataAvailable(SocketClient *c);
43168415b822cae1f8b54ef09c41c11a9b97b87f40San Mehat
44168415b822cae1f8b54ef09c41c11a9b97b87f40San Mehatprivate:
45c73a3a5771a2d29d1bae666bfde12f751d66fc96San Mehat    void dispatchCommand(SocketClient *c, char *data);
468702bb17f40022e970e8acd40b348d074e39afc7Robert Greenwalt    void init(const char *socketName, bool withSeq);
47168415b822cae1f8b54ef09c41c11a9b97b87f40San Mehat};
48168415b822cae1f8b54ef09c41c11a9b97b87f40San Mehat#endif
49