private static void OnIq(object sender, IQ iq) { try { if (iq.Query == null) { return; } if (iq.Type != IqType.get) { return; } if (iq.Query.GetType() == typeof(agsXMPP.protocol.iq.version.Version)) { VersionIq _iq = new VersionIq(); _iq.To = iq.From; _iq.Id = iq.Id; _iq.Type = IqType.result; _iq.Query.Name = ""; _iq.Query.Ver = ""; _iq.Query.Os = ""; _mCon.Send(_iq); } else if (iq.Query.GetType() == typeof(Time)) { TimeIq _iq = new TimeIq(); _iq.To = iq.From; _iq.Id = iq.Id; _iq.Type = IqType.result; _iq.Query.Tz = Common.Now.ToString(); _mCon.Send(_iq); } else if (iq.Query.GetType() == typeof(Ping)) { PingIq _iq = new PingIq(); _iq.To = iq.From; _iq.Id = iq.Id; _iq.Type = IqType.result; _mCon.Send(_iq); } } catch (Exception e) { LogManager.GetLogger("Debug").Error(e.Message); } }
public XmppVersionHandler() { Handle( el => el.OfType <Iq>() && el.Cast <Iq>().Type == IqType.Get && el.Cast <Iq>().Query.OfType <Version>(), async(context, xmppXElement) => { var iq = xmppXElement.Cast <Iq>(); var resIq = new VersionIq(); resIq.Id = iq.Id; resIq.To = iq.From; resIq.Type = IqType.Result; resIq.Version.Name = "Matrix-Client"; resIq.Version.Os = "Windows"; resIq.Version.Ver = "1.2.0"; await SendAsync(resIq); }); }