/// <summary> /// Post text to the session /// </summary> /// <param name="text"></param> public void PostText(TextBlobModel text, DeviceProfile device) { try { string relativeUri = String.Format(UriTemplates.POST_TEXT_URI, _session.SessionId, device.profile.id); string absoluteUri = TywiConfiguration.TywiServiceUri + relativeUri; SessionApiRequest<TextBlobModel, TextBlobModel> request = new SessionApiRequest<TextBlobModel, TextBlobModel>( device, absoluteUri, Http.HttpUtilities.Methods.POST, text); this.ProcessRequest<TextBlobModel, TextBlobModel>(request); } catch (Exception exc) { throw new AccessDeniedException(String.Format("Failed to post text from device {0}: {1}", device.profile.id, exc.Message), exc); } }
/// <summary> /// /// </summary> /// <param name="index"></param> /// <param name="stream"></param> /// <param name="device"></param> private void HandleInputText(int index, TywiTextStream stream, DeviceProfile device) { string text = stream.ReadText(); if (text != null) { TextBlobModel textBlob = new TextBlobModel() { receivedTime = DateTime.Now, text = text }; _service.PostText(textBlob, device); } }