I have an application which relies on a dedicated Lync client sitting on a server to manage ad-hoc MeetNow rooms.
Lync automatically closes the conversation after 15 minutes of inactivity. I found a blog describing a way to surreptitiously keep the conversation alive by sending a "cancel transfer" message, but that solution uses UCMA and I only have the 2013 Lync Client SDK available.
The way it's done there is (basically):
var contentType = new System.Net.Mime.ContentType("text/x-msmsgsinvite");
var s = @"Application-Name: File Transfer\r\nInvitation-Command: CANCEL\r\nInvitation-Cookie: 12345\r\n");
byte[] htmlBytes = Encoding.UTF8.GetBytes(s);
Flow.BeginSendInstantMessage(contentType, htmlBytes, EndSendInstantMessage, Flow);
But, again, this is using UCMA. The Lync Client SDK doesn't work exactly the same.
I need to use a Modality of the Conversation to send a message, and I can't set the content type to text/x-msmsgsinvite
because it uses InstantMessageContentType
, an Enum
where the only content types available are: Invalid, PlainText, Html, RichText, Gif, Ink, Unknown
.
Attempts I've made using the 2013 Client SDK:
(first, I make sure the Modality.State
is connected - it is).
I tried sending an empty message - Received an exception saying that the Value does not fall within the expected range
. I may be misunderstanding this, but I took it to mean that an empty string does not a message make.
I tried sending just a random message with content type set to Invalid
- Received an exception with the message Unknown InstantMessageContentType. Type is Invalid
. (wasn't actually expecting this one to succeed)
I tried sending a message with content type set to Html
, where the message contained a <div>
with style="display: none;"
- this manages to keep the conversation alive, but, of course, this displays an empty message from the Applicative User
I would very much like to avoid sending an actual message that displays in the MeetNow room (even if all it shows is the Applicative User's name).
Any ideas?
&tldr; : Set the AutoTerminateOnIdle
property to true
. This will keep the conversation from terminating!
Full disclosure:
It seems the answer was hiding somewhere else entirely.
I found some interesting information in Google Books in a book titled "Professional Unified Communications Development with Microsoft Lync Server 2010" By George Durzi, Michael Greenlee.
On the subject of the Conversation
's property AutoTerminateOnIdle
it states:
[...] Setting the
AutoTerminateOnIdle
property of the conversation tofalse
when in UI Suppression mode ensures that the application can still access the conversation and its properties after the Audio Video modality is no longer active. This allows the application to reastart the audio or video channels of the modality because the conversation i not in a terminated state. If a conversation contains both the InstantMessage and Audio Video modalities, it will only terminate when both modalities become inactive. Setting theAutoTerminateOnIdle
property totrue
ensures that the underlying conversation never enters a terminated state, allowing the application to connect to either modality again as needed. [...]
Is it just me or is the part marked in bold THE EXACT OPPISITE OF WHAT ONE WOULD EXPECT FROM THE PROPERTY NAME?!?! If true
, never enter a terminated state?! WTF?
Either way, I tested it - left a room simply sitting there for, like, half an hour not doing anything. The client even went into "away" status => conversation stayed open. Huzzah!