2 * Copyright (C) 2007 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 * IPC messaging library.
29 typedef struct MqMessage MqMessage
;
31 /** A destination to which messages can be sent. */
32 typedef struct MqDestination MqDestination
;
35 typedef struct MqBytes MqBytes
;
40 * @param destination to which the message was sent
41 * @param message the message to hear
43 typedef void MqMessageListener(MqDestination
* destination
, MqMessage
* message
);
46 * Hears a destination close.
48 * @param destination that closed
50 typedef void MqCloseListener(MqDestination
* destination
);
52 /** Message functions. */
55 * Creates a new Message.
57 * @param header as defined by user
58 * @param body as defined by user
59 * @param replyTo destination to which replies should be sent, NULL if none
61 MqMessage
* mqCreateMessage(MqBytes header
, MqBytes body
,
62 MqDestination
* replyTo
);
64 /** Sends a message to a destination. */
65 void mqSendMessage(MqMessage
* message
, MqDestination
* destination
);
67 /** Destination functions. */
70 * Creates a new destination. Acquires a reference implicitly.
72 * @param messageListener function to call when a message is recieved
73 * @param closeListener function to call when the destination closes
74 * @param userData user-specific data to associate with the destination.
75 * Retrieve using mqGetDestinationUserData().
77 MqDestination
* mqCreateDestination(MqMessageListener
* messageListener
,
78 MqCloseListener
* closeListener
, void* userData
);
81 * Gets user data which was associated with the given destination at
84 * It is only valid to call this function in the same process that the
85 * given destination was created in.
86 * This function returns a null pointer if you call it on a destination
87 * created in a remote process.
89 void* mqGetUserData(MqDestination
* destination
);
92 * Returns 1 if the destination was created in this process, or 0 if
93 * the destination was created in a different process, in which case you have
96 int mqIsDestinationLocal(MqDestination
* destination
);
99 * Increments the destination's reference count.
101 void mqKeepDestination(MqDesintation
* destination
);
104 * Decrements the destination's reference count.
106 void mqFreeDestination(MqDestination
* desintation
);
111 * Gets the destination bound to a name.
113 MqDestination
* mqGetDestination(char* name
);
116 * Binds a destination to a name.
118 void mqPutDestination(char* name
, MqDestination
* desintation
);