// Connections public void SendTag(string id, Tags.Tag tag) { if (_backendRuntime._connections != null) { _backendRuntime._connections.Send(id, tag); } }
public void AddMessage(Tags.jabber.client.message message) { JID senderJid = new JID(message.from); string sender = null; // Get the contact the message is from if( senderJid.Bare == Self ) sender = Self; else if( senderJid.Bare == Other ) sender = Other; else return; // The conversationitem we will be adding items to ConversationItem current = null; // Look if we have to add a new item or reuse an old one if (Items.Count > 0) { ConversationItem last = Items.First(); if (last != null && last.Identifier == senderJid) // The last item is from the same sender as this item { if (last.Messages.Count > 0) // It has messages { ConversationMessage lastMessage = last.Messages.Last(); if ((message.Timestamp - lastMessage.Timestamp).Minutes < 1) // The last messag is no older than two minutes current = last; } else // It has no messages, we don't know why but we should add our items to it because an emtpy item looks bad { current = last; } } } if (current == null) { current = new ConversationItem(new ConversationSender(Self, sender), senderJid, message.Timestamp); Items.Insert(0, current); } current.AddMessage(message); }
//public void OnBackgroundTaskCanceled(IBackgroundTaskInstance instance, string name, BackgroundTaskCancellationReason reason) //{ // var canceled = true; // var strreason = reason.ToString(); // switch (name) // { // case "ControlChannelReset": PushEvent(WindowsType.ControlChannelReset, canceled, strreason); break; // case "InternetAvailable": PushEvent(WindowsType.InternetAvailable, canceled, strreason); break; // case "InternetNotAvailable": PushEvent(WindowsType.InternetNotAvailable, canceled, strreason); break; // case "ServicingComplete": PushEvent(WindowsType.ServicingComplete, canceled, strreason); break; // case "SessionConnected": PushEvent(WindowsType.SessionConnected, canceled, strreason); break; // case "UserAway": PushEvent(WindowsType.UserAway, canceled, strreason); break; // case "UserPresent": PushEvent(WindowsType.UserPresent, canceled, strreason); break; // case "LockScreenApplicationAdded": PushEvent(WindowsType.LockScreenApplicationAdded, canceled, strreason); break; // case "LockScreenApplicationRemoved": PushEvent(WindowsType.LockScreenApplicationRemoved, canceled, strreason); break; // case "TimeZoneChange": PushEvent(WindowsType.TimeZoneChange, canceled, strreason); break; // } //} #endregion #region helper private void PushEvent(Tags.Tag tag) { OnEvent(new BackendEventMessage("", tag)); }
public void AddMessage(Tags.jabber.client.message message) { foreach (var body in message.bodyElements) // Add all body elements Messages.Add(new ConversationMessage(message.Timestamp, body.Value)); }
private void PushEvent(Tags.Tag tag) { PushEvent(new BackendEventMessage(Id, tag)); }
public bool Send(Tags.Tag tag) { if (_XMPP.Connected) { _XMPP.Send(tag); return true; } PushEvent(ErrorType.NotConnected, ErrorPolicyType.Informative); return false; }
public bool Send(string id, Tags.Tag tag) { Connection connection = _connectionList[id]; if (connection != null) { connection.Send(tag); return true; } else { return false; } }
public BackendEventMessage(string id, Tags.Tag tag, string uuid = "") : base(id, EventType.Message) { Tag = tag; if (uuid == "") UUID = Guid.NewGuid().ToString(); else UUID = uuid; }