本文整理汇总了C#中ASC.Xmpp.Core.protocol.client.IQ类的典型用法代码示例。如果您正苦于以下问题:C# IQ类的具体用法?C# IQ怎么用?C# IQ使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IQ类属于ASC.Xmpp.Core.protocol.client命名空间,在下文中一共展示了IQ类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleIQ
public override IQ HandleIQ(XmppStream stream, IQ iq, XmppHandlerContext context)
{
if (iq.HasTo && iq.To != Jid) return XmppStanzaError.ToServiceUnavailable(iq);
if (iq.Query is DiscoInfo && iq.Type == IqType.get) return GetDiscoInfo(stream, iq, context);
if (iq.Query is DiscoItems && iq.Type == IqType.get) return GetDiscoItems(stream, iq, context);
return XmppStanzaError.ToServiceUnavailable(iq);
}
示例2: GetPrivate
private IQ GetPrivate(XmppStream stream, IQ iq, XmppHandlerContext context)
{
var privateStore = (Private)iq.Query;
if (!privateStore.HasChildElements) return XmppStanzaError.ToNotAcceptable(iq);
var retrived = new List<Element>();
foreach (var childNode in privateStore.ChildNodes)
{
if (childNode is Element)
{
var elementToRetrive = (Element)childNode;
var elementRestored = context.StorageManager.PrivateStorage.GetPrivate(iq.From, elementToRetrive);
retrived.Add(elementRestored ?? elementToRetrive);
}
}
privateStore.RemoveAllChildNodes();
foreach (var element in retrived)
{
privateStore.AddChild(element);
}
iq.SwitchDirection();
iq.Type = IqType.result;
return iq;
}
示例3: HandleIQ
public override IQ HandleIQ(XmppStream stream, IQ iq, XmppHandlerContext context)
{
if (!iq.HasTo) iq.To = iq.From;
if (iq.Type == IqType.get) return GetVCardSearch(stream, iq, context);
else if (iq.Type == IqType.set) return SetVCardSearch(stream, iq, context);
else return XmppStanzaError.ToBadRequest(iq);
}
示例4: ProcessAuthIQSet
private void ProcessAuthIQSet(XmppStream stream, AuthIq iq, XmppHandlerContext context)
{
if (string.IsNullOrEmpty(iq.Query.Username) || string.IsNullOrEmpty(iq.Query.Resource))
{
context.Sender.SendTo(stream, XmppStanzaError.ToNotAcceptable(iq));
return;
}
bool authorized = false;
if (!string.IsNullOrEmpty(iq.Query.Digest))
{
authorized = AuthDigest(iq.Query.Username, iq.Query.Digest, stream, context.UserManager);
}
if (!string.IsNullOrEmpty(iq.Query.Password))
{
authorized = AuthPlain(iq.Query.Username, iq.Query.Password, stream, context.UserManager);
}
if (authorized)
{
stream.Authenticate(iq.Query.Username);
var answer = new IQ(IqType.result);
answer.Id = iq.Id;
answer.To = iq.From;
answer.From = iq.To;
context.Sender.SendTo(stream, answer);
}
else
{
context.Sender.SendTo(stream, XmppStanzaError.ToNotAuthorized(iq));
}
}
示例5: HandleIQ
public override IQ HandleIQ(XmppStream stream, IQ iq, XmppHandlerContext context)
{
if (iq.To != null && iq.From != iq.To) return XmppStanzaError.ToForbidden(iq);
if (iq.Type == IqType.get) return GetPrivate(stream, iq, context);
else if (iq.Type == IqType.set) return SetPrivate(stream, iq, context);
else return XmppStanzaError.ToBadRequest(iq);
}
示例6: HandleIQ
public override IQ HandleIQ(XmppStream stream, IQ iq, XmppHandlerContext context)
{
if (iq.HasTo && iq.To != iq.From) return XmppStanzaError.ToForbidden(iq);
if (iq.Type == IqType.get) return GetRoster(stream, iq, context);
else if (iq.Type == IqType.set) return SetRoster(stream, iq, context);
else return null;
}
示例7: HandleIQ
public override IQ HandleIQ(XmppStream stream, IQ iq, XmppHandlerContext context)
{
if (!iq.HasTo || !iq.To.HasUser) return XmppStanzaError.ToServiceUnavailable(iq);
var session = context.SessionManager.GetSession(iq.To);
if (session != null) context.Sender.SendTo(session, iq);
return null;
}
示例8: HandleIQ
public override IQ HandleIQ(XmppStream stream, IQ iq, XmppHandlerContext context)
{
if (iq.Query is PrivateLog && iq.Type == IqType.get) return GetPrivateLog(stream, iq, context);
if (iq.Query is PrivateLog && iq.Type == IqType.set) return SetPrivateLog(stream, iq, context);
if (iq.Query is PrivateLog && (iq.Type == IqType.result || iq.Type == IqType.error)) return null;
if (iq.Query is History && iq.Type == IqType.get) return GetHistory(stream, iq, context);
return XmppStanzaError.ToServiceUnavailable(iq);
}
示例9: ProcessSession
private IQ ProcessSession(XmppStream stream, IQ iq, XmppHandlerContext context)
{
var session = context.SessionManager.GetSession(iq.From);
if (session == null) return XmppStanzaError.ToItemNotFound(iq);
var answer = new IQ(IqType.result);
answer.Id = iq.Id;
answer.Session = new Core.protocol.iq.session.Session();
session.Active = true;
return answer;
}
示例10: SetVCard
private IQ SetVCard(XmppStream stream, IQ iq, XmppHandlerContext context)
{
if (iq.From != iq.To) return XmppStanzaError.ToForbidden(iq);
var answer = new IQ(IqType.result);
answer.Id = iq.Id;
answer.To = iq.From;
answer.From = iq.To;
context.StorageManager.VCardStorage.SetVCard(iq.To, iq.Vcard);
answer.Vcard = iq.Vcard;
return answer;
}
示例11: HandleIQ
public override IQ HandleIQ(ASC.Xmpp.Server.Streams.XmppStream stream, IQ iq, XmppHandlerContext context)
{
if (iq.Vcard!=null && iq.Type==IqType.get)
{
//Handle vcard
iq.Vcard = Member.GetVcard();
iq.Type = IqType.result;
iq.SwitchDirection();
return iq;
}
return base.HandleIQ(stream, iq, context);
}
示例12: GetPrivateLog
private IQ GetPrivateLog(XmppStream stream, IQ iq, XmppHandlerContext context)
{
if (!iq.HasTo) return XmppStanzaError.ToBadRequest(iq);
var privateLog = (PrivateLog)iq.Query;
privateLog.RemoveAllChildNodes();
var logging = archiveStore.GetMessageLogging(iq.From, iq.To);
privateLog.AddChild(new PrivateLogItem() { Jid = iq.To, Log = logging });
iq.SwitchDirection();
iq.Type = IqType.result;
return iq;
}
示例13: GetDiscoInfo
protected virtual IQ GetDiscoInfo(XmppStream stream, IQ iq, XmppHandlerContext context)
{
if (((DiscoInfo)iq.Query).Node != null) return XmppStanzaError.ToServiceUnavailable(iq);
var service = ServiceManager.GetService(Jid);
if (service == null) return XmppStanzaError.ToItemNotFound(iq);
var answer = new IQ(IqType.result);
answer.Id = iq.Id;
answer.From = Jid;
answer.To = iq.From;
answer.Query = service.DiscoInfo;
return answer;
}
示例14: GetVCard
private IQ GetVCard(XmppStream stream, IQ iq, XmppHandlerContext context)
{
var answer = new IQ(IqType.result);
answer.Id = iq.Id;
answer.To = iq.From;
answer.From = iq.To;
answer.Vcard = iq.To.HasUser ?
context.StorageManager.VCardStorage.GetVCard(iq.To) :
GetServiceVcard(iq.To, context);
if (answer.Vcard == null) return XmppStanzaError.ToNotFound(iq);
return answer;
}
示例15: ProcessBind
private IQ ProcessBind(XmppStream stream, IQ iq, XmppHandlerContext context)
{
if (iq.Type != IqType.set) return XmppStanzaError.ToBadRequest(iq);
var answer = new IQ(IqType.result);
answer.Id = iq.Id;
var bind = (Bind)iq.Bind;
var resource = !string.IsNullOrEmpty(bind.Resource) ? bind.Resource : stream.User;
if (bind.TagName.Equals("bind", StringComparison.OrdinalIgnoreCase))
{
var jid = new Jid(stream.User, stream.Domain, resource);
var session = context.SessionManager.GetSession(jid);
if (session != null)
{
if (session.Stream.Id != stream.Id)
{
context.Sender.SendToAndClose(session.Stream, XmppStreamError.Conflict);
}
else
{
return XmppStanzaError.ToConflict(iq);
}
}
stream.BindResource(resource);
context.SessionManager.AddSession(new XmppSession(jid, stream));
answer.Bind = new Bind(jid);
}
else if (bind.TagName.Equals("unbind", StringComparison.OrdinalIgnoreCase))
{
if (!stream.Resources.Contains(resource)) return XmppStanzaError.ToNotFound(iq);
context.SessionManager.CloseSession(iq.From);
stream.UnbindResource(resource);
if (stream.Resources.Count == 0)
{
context.Sender.CloseStream(stream);
}
}
else
{
return XmppStanzaError.ToBadRequest(iq);
}
if (stream.MultipleResources) answer.To = iq.From;
return answer;
}