<html>
<body>
<div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
<table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
<tr>
<td>
This is an automatically generated e-mail. To reply, visit:
<a href="https://reviewboard.asterisk.org/r/3025/">https://reviewboard.asterisk.org/r/3025/</a>
</td>
</tr>
</table>
<br />
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<p style="margin-top: 0;">On November 22nd, 2013, 12:04 a.m. UTC, <b>Mark Michelson</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
<thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
<a href="https://reviewboard.asterisk.org/r/3025/diff/1/?file=48549#file48549line142" style="color: black; font-weight: bold; text-decoration: underline;">branches/12/res/res_stasis_device_state.c</a>
<span style="font-weight: normal;">
(Diff revision 1)
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
<th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">142</font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="tb"> </span><span class="n">RAII_VAR</span><span class="p">(</span><span class="k">struct</span> <span class="n">device_state_subscription</span> <span class="o">*</span><span class="p">,</span> <span class="n">sub</span><span class="p">,</span></pre></td>
</tr>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
<th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">143</font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="tb"> </span><span class="tb"> </span> <span class="n">device_state_subscription_create</span><span class="p">(</span><span class="n">app</span><span class="p">,</span> <span class="n">name</span><span class="p">),</span> <span class="n">ao2_cleanup</span><span class="p">);</span></pre></td>
</tr>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
<th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">144</font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
</tr>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
<th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">145</font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="tb"> </span><span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">sub</span><span class="p">)</span> <span class="p">{</span></pre></td>
</tr>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
<th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">146</font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="tb"> </span><span class="tb"> </span><span class="k">return</span> <span class="nb">NULL</span><span class="p">;</span></pre></td>
</tr>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
<th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">147</font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="tb"> </span><span class="p">}</span></pre></td>
</tr>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
<th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">148</font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
</tr>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
<th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">149</font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="tb"> </span><span class="k">return</span> <span class="n">ao2_find</span><span class="p">(</span><span class="n">device_state_subscriptions</span><span class="p">,</span> <span class="n">sub</span><span class="p">,</span> <span class="n">OBJ_SEARCH_OBJECT</span><span class="p">);</span></pre></td>
</tr>
</tbody>
</table>
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Instead of constructing a device_state_subscription and searching by OBJ_SEARCH_OBJECT, just use the name that was passed in and search by OBJ_SEARCH_KEY. That way, you save the overhead of the creation and destruction of an ao2_object whenever this function is called.</pre>
</blockquote>
<p>On November 22nd, 2013, 12:23 a.m. UTC, <b>Kevin Harwell</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">I need to search by the app name and device name in order to find the device subscribed to and OBJ_SEARCH_KEY only allows me to search using a single string field, so I create the object and search on that instead.</pre>
</blockquote>
</blockquote>
<pre style="margin-left: 1em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">This is not true. The OBJ_SEARCH_KEY could be anything you setup the container callbacks to take as the key. The template code on the wiki assumes the key is a simple string.
In this case you could pass a struct pointer that contains two string pointers.
struct device_container_key {
const char *app_name;
const char *device_name;
}</pre>
<br />
<p>- rmudgett</p>
<br />
<p>On November 22nd, 2013, 12:25 a.m. UTC, Kevin Harwell wrote:</p>
<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('https://reviewboard.asterisk.org/static/rb/images/review_request_box_top_bg.ab6f3b1072c9.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
<tr>
<td>
<div>Review request for Asterisk Developers, David Lee and Matt Jordan.</div>
<div>By Kevin Harwell.</div>
<p style="color: grey;"><i>Updated Nov. 22, 2013, 12:25 a.m.</i></p>
<div style="margin-top: 1.5em;">
<b style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Bugs: </b>
<a href="https://issues.asterisk.org/jira/browse/ASTERISK-22838">ASTERISK-22838</a>
</div>
<div style="margin-top: 1.5em;">
<b style="color: #575012; font-size: 10pt;">Repository: </b>
Asterisk
</div>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Created a data model and implemented functionality for an ARI device state resource. The following operations have been added that allow a user to manipulate an ARI controlled device:
PUT /device-states/{deviceName}&{deviceState} - Create/Change the state of an ARI controlled device
GET /device-states/{deviceName} - Retrieve the current state of a device
DELETE /device-states/{deviceName} - Destroy a device-state controlled by ARI
The ARI controlled device must begin with 'Stasis:'. An example controlled device name would be Stasis:Example.
A 'DeviceStateChanged' event has also been added so that an application can subscribe and receive device change events. Any device state, ARI controlled or not, can be subscribed to.
While adding the event, the underlying subscription control mechanism was refactored so that all current and future resource subscriptions would be the same. Each event resource must now register itself in order to be able to properly handle [un]subscribes.</pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Some basic testing done using the swagger framework and a websocket connection. Testing adding, changing, and removing device state with regards to an ARI controlled device were successful. Also tested [un]subscribing to the events from device with success. Planning on writing some testsuite test cases as well.</pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">
<li>branches/12/rest-api/resources.json <span style="color: grey">(402993)</span></li>
<li>branches/12/rest-api/api-docs/events.json <span style="color: grey">(402993)</span></li>
<li>branches/12/rest-api/api-docs/deviceStates.json <span style="color: grey">(PRE-CREATION)</span></li>
<li>branches/12/rest-api/api-docs/applications.json <span style="color: grey">(402993)</span></li>
<li>branches/12/rest-api-templates/ari.make.mustache <span style="color: grey">(402993)</span></li>
<li>branches/12/res/stasis/app.c <span style="color: grey">(402993)</span></li>
<li>branches/12/res/stasis/app.h <span style="color: grey">(402993)</span></li>
<li>branches/12/res/res_stasis_device_state.exports.in <span style="color: grey">(PRE-CREATION)</span></li>
<li>branches/12/res/res_stasis_device_state.c <span style="color: grey">(PRE-CREATION)</span></li>
<li>branches/12/res/res_stasis.c <span style="color: grey">(402993)</span></li>
<li>branches/12/res/res_ari_device_states.c <span style="color: grey">(PRE-CREATION)</span></li>
<li>branches/12/res/ari/resource_device_states.c <span style="color: grey">(PRE-CREATION)</span></li>
<li>branches/12/res/ari/resource_device_states.h <span style="color: grey">(PRE-CREATION)</span></li>
<li>branches/12/res/ari/resource_applications.h <span style="color: grey">(402993)</span></li>
<li>branches/12/res/ari/ari_model_validators.c <span style="color: grey">(402993)</span></li>
<li>branches/12/res/ari/ari_model_validators.h <span style="color: grey">(402993)</span></li>
<li>branches/12/res/ari.make <span style="color: grey">(402993)</span></li>
<li>branches/12/main/devicestate.c <span style="color: grey">(402993)</span></li>
<li>branches/12/include/asterisk/stasis_app_device_state.h <span style="color: grey">(PRE-CREATION)</span></li>
<li>branches/12/include/asterisk/stasis_app.h <span style="color: grey">(402993)</span></li>
<li>branches/12/include/asterisk/devicestate.h <span style="color: grey">(402993)</span></li>
</ul>
<p><a href="https://reviewboard.asterisk.org/r/3025/diff/" style="margin-left: 3em;">View Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>