summaryrefslogtreecommitdiff
path: root/utils/LocIpc.h
diff options
context:
space:
mode:
Diffstat (limited to 'utils/LocIpc.h')
-rw-r--r--utils/LocIpc.h25
1 files changed, 15 insertions, 10 deletions
diff --git a/utils/LocIpc.h b/utils/LocIpc.h
index 8bc13b7..738d4fb 100644
--- a/utils/LocIpc.h
+++ b/utils/LocIpc.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017 The Linux Foundation. All rights reserved.
+/* Copyright (c) 2017-2018 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -66,15 +66,6 @@ public:
// Stop listening to new messages.
void stopListening();
- // Callback function for receiving incoming messages.
- // Override this function in your derived class to process incoming messages.
- // For each received message, this callback function will be called once.
- // This callback function will be called in the calling thread of startListeningBlocking
- // or in the new LocThread created by startListeningNonBlocking.
- //
- // Argument data contains the received message. You need to parse it.
- virtual void onReceive(const std::string& /*data*/) {}
-
// Send out a message.
// Call this function to send a message in argument data to socket in argument name.
//
@@ -84,6 +75,20 @@ public:
static bool send(const char name[], const std::string& data);
static bool send(const char name[], const uint8_t data[], uint32_t length);
+protected:
+ // Callback function for receiving incoming messages.
+ // Override this function in your derived class to process incoming messages.
+ // For each received message, this callback function will be called once.
+ // This callback function will be called in the calling thread of startListeningBlocking
+ // or in the new LocThread created by startListeningNonBlocking.
+ //
+ // Argument data contains the received message. You need to parse it.
+ inline virtual void onReceive(const std::string& /*data*/) {}
+
+ // LocIpc client can overwrite this function to get notification
+ // when the socket for LocIpc is ready to receive messages.
+ inline virtual void onListenerReady() {}
+
private:
static bool sendData(int fd, const sockaddr_un& addr,
const uint8_t data[], uint32_t length);