public void OnIndicationReceived(String xmlindication) { try { XmlSerializer serializer = new XmlSerializer(typeof(isComposing)); using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(xmlindication))) { isComposing state = serializer.Deserialize(stream) as isComposing; if (state != null && !String.IsNullOrEmpty(state.state)) { this.is_remote_active = (state.state.Equals("active")); if (this.is_remote_active) { double refresh = IMActivityIndicator.TIMER_REMOTE_ACTIVE_VALUE; if (!String.IsNullOrEmpty(state.refresh)) { #if PocketPC refresh = Convert.ToDouble(state.refresh); this.systimer_remote_active.Interval = refresh * 1000; #else if (double.TryParse(state.refresh, out refresh)) { this.systimer_remote_active.Interval = refresh * 1000; } else { return; // MUST NEVER HAPPEN } #endif } else { this.systimer_remote_active.Interval = refresh * 1000; } this.systimer_remote_active.Start(); } else { this.systimer_remote_active.Stop(); } EventHandlerTrigger.TriggerEvent(this.remoteStateChangedEvent, this); } } } catch (Exception e) { LOG.Error(e); } }
public String GetMessageIndicator() { String message = String.Empty; isComposing obj = new isComposing(); obj.state = (this.is_local_active ? "active" : "idle"); obj.contenttype = "text/plain"; if (is_local_active) { obj.refresh = IMActivityIndicator.TIMER_LOCAL_ACTIVE_VALUE.ToString(); } try { using (MemoryStream memoryStream = new MemoryStream()) { XmlWriterSettings settings = new XmlWriterSettings(); settings.Encoding = new UTF8Encoding(false); settings.OmitXmlDeclaration = false; settings.Indent = true; using (XmlWriter xmlWriter = XmlWriter.Create(memoryStream, settings)) { XmlSerializer serializer = new XmlSerializer(typeof(isComposing)); serializer.Serialize(xmlWriter, obj); xmlWriter.Flush(); xmlWriter.Close(); } #if PocketPC message = Encoding.UTF8.GetString(memoryStream.ToArray(), 0, (int)memoryStream.Length); #else message = Encoding.UTF8.GetString(memoryStream.ToArray()); #endif } } catch (Exception e) { LOG.Error(e); } return(message); }
public void OnIndicationReceived(string xmlindication) { try { XmlSerializer serializer = new XmlSerializer(typeof(isComposing)); using (System.IO.MemoryStream stream = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(xmlindication))) { isComposing state = serializer.Deserialize(stream) as isComposing; if (state != null && !string.IsNullOrEmpty(state.state)) { this.is_remote_active = state.state.Equals("active"); if (this.is_remote_active) { double refresh = 120.0; if (!string.IsNullOrEmpty(state.refresh)) { if (!double.TryParse(state.refresh, out refresh)) { return; } this.systimer_remote_active.Interval = refresh * 1000.0; } else { this.systimer_remote_active.Interval = refresh * 1000.0; } this.systimer_remote_active.Start(); } else { this.systimer_remote_active.Stop(); } EventHandlerTrigger.TriggerEvent(this.remoteStateChangedEvent, this); } } } catch (System.Exception e) { IMActivityIndicator.LOG.Error(e); } }
public string GetMessageIndicator() { string message = string.Empty; isComposing obj = new isComposing(); obj.state = (this.is_local_active ? "active" : "idle"); obj.contenttype = "text/plain"; if (this.is_local_active) { obj.refresh = 60.0.ToString(); } try { using (System.IO.MemoryStream memoryStream = new System.IO.MemoryStream()) { using (XmlWriter xmlWriter = XmlWriter.Create(memoryStream, new XmlWriterSettings { Encoding = new System.Text.UTF8Encoding(false), OmitXmlDeclaration = false, Indent = true })) { XmlSerializer serializer = new XmlSerializer(typeof(isComposing)); serializer.Serialize(xmlWriter, obj); xmlWriter.Flush(); xmlWriter.Close(); } message = System.Text.Encoding.UTF8.GetString(memoryStream.ToArray()); } } catch (System.Exception e) { IMActivityIndicator.LOG.Error(e); } return(message); }