void xmppCon_OnPresence(object sender, agsXMPP.protocol.client.Presence pres) { string[] jIDRaw = pres.From.ToString().Split('/'); string jID = jIDRaw[0]; OSAEObjectCollection objects = OSAEObjectManager.GetObjectsByPropertyValue("JabberID", jID); if (objects != null) { foreach (OSAEObject oObj in objects) { Log.Info(String.Format("Received Presence from: {0} show: {1} status: {2}", oObj.Name, pres.Show.ToString(), pres.Status)); if (pres.Show.ToString() == "away") { OSAEObjectPropertyManager.ObjectPropertySet(oObj.Name, "JabberStatus", "Idle", "Jabber"); } else if (pres.Show.ToString() == "NONE") { OSAEObjectPropertyManager.ObjectPropertySet(oObj.Name, "JabberStatus", "Online", "Jabber"); } break; } } else { Log.Info(String.Format("No object found with address of: {0}", jID, pres.Show.ToString(), pres.Status)); } }
void xmppCon_OnRosterItem(object sender, agsXMPP.protocol.iq.roster.RosterItem item) { string[] jIDRaw = item.Jid.Bare.ToString().Split('/'); string jID = jIDRaw[0]; OSAEObjectCollection objects = OSAEObjectManager.GetObjectsByPropertyValue("JabberID", jID); if (objects == null) { bool dupName = OSAEObjectManager.ObjectExists(item.Name); if (dupName) { Log.Info(String.Format("Found Object {0} for {1}", item.Name, jID)); } else { Log.Info(String.Format("Creating new Object {0} for {1}", item.Name, jID)); OSAEObjectManager.ObjectAdd(item.Name, "", "Discovered Jabber contact", "PERSON", "", "Unknown", 10, false); } Log.Info(String.Format("Updating JabberID for {0}", item.Name)); OSAEObjectPropertyManager.ObjectPropertySet(item.Name, "JabberID", jID, gAppName); } else { Log.Info(String.Format("Found Object {0} for {1}", item.Name, jID)); } }
void xmppCon_OnMessage(object sender, agsXMPP.protocol.client.Message msg) { try { // ignore empty messages (events) if (msg.Body == null || oldMmsg == msg || msg.Type == agsXMPP.protocol.client.MessageType.error) { return; } oldMmsg = msg; string[] jIDRaw = msg.From.ToString().Split('/'); string jID = jIDRaw[0]; OSAEObjectCollection objects = OSAEObjectManager.GetObjectsByPropertyValue("JabberID", jID); if (objects != null) { foreach (OSAEObject oObj in objects) { if (oObj.Alias.Length > 0) { gCurrentUser = oObj.Alias; } else { gCurrentUser = oObj.Name; } } } else { Log.Info("Message from Unknown address: " + jID); } if (gDebug) { Log.Debug("Current User set to: " + gCurrentUser); } OSAEObjectPropertyManager.ObjectPropertySet(gCurrentUser, "Communication Method", "Jabber", gAppName); gCurrentAddress = jID; if (msg.Body.EndsWith("?") || msg.Body.EndsWith("!") || msg.Body.EndsWith(".")) { msg.Body = msg.Body.Substring(0, msg.Body.Length - 1); } RecognitionResult rr = oRecognizer.EmulateRecognize(msg.Body); if (rr == null) { if (gDebug) { Log.Debug("INPUT: No Matching Pattern found!"); } } } catch (Exception ex) { Log.Error("Error in _OnMessage!", ex); } }