今回も前回と前々回に引き続いてMessenger LibraryによるWebアプリケーションの作成です。そして,
localhostでの開発をサポート
はじめにMessenger Libraryのアップデート情報を紹介します。本連載 第11回のLive Messenger Library 前編の記事中で,
プレゼンスの変更
さて,
Messenger Libraryの場合,
Gihyo.LiveSample.changePresence = function() {
var presence = Gihyo.LiveSample.User.get_presence();
if (presence.get_status() === Microsoft.Live.Messenger.PresenceStatus.offline) {
return;
}
presence.set_displayName($('displayNameText').value);
presence.set_personalMessage($('personalMessageText').value);
var selectedIndex = $('selectStatus').selectedIndex;
var statuses = [Microsoft.Live.Messenger.PresenceStatus.appearOffline,
Microsoft.Live.Messenger.PresenceStatus.away,
Microsoft.Live.Messenger.PresenceStatus.beRightBack,
Microsoft.Live.Messenger.PresenceStatus.busy,
Microsoft.Live.Messenger.PresenceStatus.idle,
Microsoft.Live.Messenger.PresenceStatus.inACall,
Microsoft.Live.Messenger.PresenceStatus.online,
Microsoft.Live.Messenger.PresenceStatus.outToLunch];
presence.set_status(statuses[selectedIndex]);
}
サインインしていない状態では変更しないように条件文を入れています。状態の変更は,
<div>
<table>
<tr><td>Display Name: </td><td><input id="displayNameText" type="text" /></td></tr>
<tr><td>Message: </td><td><input id="personalMessageText" type="text" /></td></tr>
<tr><td>Status: </td>
<td>
<select id="selectStatus">
<option>オフライン</option>
<option>退席中</option>
<option>一時退席中</option>
<option>取り込み中</option>
<option>退席中 (自動)</option>
<option>通話中</option>
<option>オンライン</option>
<option>昼休み</option>
</select>
</td></tr>
</table>
<div><input type="button" value="Change Presence" onclick="Gihyo.LiveSample.changePresence();" /></div>
</div>
実行した結果は図1のようになります。