本文整理汇总了C#中ASC.Xmpp.Core.protocol.client.IQ类的典型用法代码示例。如果您正苦于以下问题:C# IQ类的具体用法?C# IQ怎么用?C# IQ使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IQ类属于ASC.Xmpp.Core.protocol.client命名空间,在下文中一共展示了IQ类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:vipwan,项目名称:CommunityServer,代码行数:7,代码来源:ServiceDiscoHandler.cs
示例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;
}
开发者ID:vipwan,项目名称:CommunityServer,代码行数:27,代码来源:PrivateHandler.cs
示例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);
}
开发者ID:ridhouan,项目名称:teamlab.v6.5,代码行数:7,代码来源:VCardSearchHandler.cs
示例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));
}
}
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:32,代码来源:AuthIQHandler.cs
示例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);
}
开发者ID:vipwan,项目名称:CommunityServer,代码行数:8,代码来源:PrivateHandler.cs
示例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;
}
开发者ID:vipwan,项目名称:CommunityServer,代码行数:8,代码来源:RosterHandler.cs
示例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;
}
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:8,代码来源:TransferHandler.cs
示例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);
}
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:8,代码来源:MessageArchiveHandler.cs
示例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;
}
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:11,代码来源:BindSessionHandler.cs
示例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;
}
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:12,代码来源:VCardHandler.cs
示例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);
}
开发者ID:vipwan,项目名称:CommunityServer,代码行数:12,代码来源:MucRoomMemberStanzaHandler.cs
示例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;
}
开发者ID:ridhouan,项目名称:teamlab.v6.5,代码行数:13,代码来源:MessageArchiveHandler.cs
示例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;
}
开发者ID:vipwan,项目名称:CommunityServer,代码行数:14,代码来源:ServiceDiscoHandler.cs
示例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;
}
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:14,代码来源:VCardHandler.cs
示例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;
}
开发者ID:vipwan,项目名称:CommunityServer,代码行数:49,代码来源:BindSessionHandler.cs
示例16: GetVCardSearch
private IQ GetVCardSearch(XmppStream stream, IQ iq, XmppHandlerContext context)
{
var answer = new IQ(IqType.result);
answer.Id = iq.Id;
answer.To = iq.From;
answer.From = iq.To;
var search = new Search();
search.Nickname = string.Empty;
search.Firstname = string.Empty;
search.Lastname = string.Empty;
answer.Query = search;
return answer;
}
开发者ID:ridhouan,项目名称:teamlab.v6.5,代码行数:15,代码来源:VCardSearchHandler.cs
示例17: HandleIQ
public override IQ HandleIQ(XmppStream stream, IQ iq, XmppHandlerContext context)
{
Unique unique = (Unique)iq.SelectSingleElement(typeof(Unique));
if (unique != null)
{
// Gen unique id
unique.Value = UniqueId.CreateNewId(16);
iq.Type = IqType.result;
iq.SwitchDirection();
return iq;
}
iq.SwitchDirection();
iq.Type = IqType.error;
iq.Error = new Error(ErrorType.cancel, ErrorCondition.ItemNotFound);
return iq;
}
开发者ID:vipwan,项目名称:CommunityServer,代码行数:16,代码来源:MucStanzaHandler.cs
示例18: GetDiscoItems
protected virtual IQ GetDiscoItems(XmppStream stream, IQ iq, XmppHandlerContext context)
{
if (((DiscoItems)iq.Query).Node != null) return XmppStanzaError.ToServiceUnavailable(iq);
var answer = new IQ(IqType.result);
answer.Id = iq.Id;
answer.From = Jid;
answer.To = iq.From;
var items = new DiscoItems();
answer.Query = items;
foreach (var service in ServiceManager.GetChildServices(Jid))
{
if (service.DiscoItem != null) items.AddDiscoItem(service.DiscoItem);
}
return answer;
}
开发者ID:vipwan,项目名称:CommunityServer,代码行数:16,代码来源:ServiceDiscoHandler.cs
示例19: GetDiscoItems
protected override IQ GetDiscoItems(XmppStream stream, IQ iq, XmppHandlerContext context)
{
if (((DiscoItems)iq.Query).Node != null) return XmppStanzaError.ToServiceUnavailable(iq);
var answer = new IQ(IqType.result);
answer.Id = iq.Id;
answer.From = Jid;
answer.To = iq.From;
var items = new DiscoItems();
answer.Query = items;
if (realJid != null)
{
items.AddDiscoItem().Jid = realJid;
}
return answer;
}
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:16,代码来源:MucRoomMemberDiscoHandler.cs
示例20: SetRegister
private IQ SetRegister(XmppStream stream, IQ iq, XmppHandlerContext context)
{
var register = (Register)iq.Query;
iq.Type = IqType.result;
if (register.RemoveAccount)
{
if (!stream.Authenticated || !iq.From.HasUser) context.Sender.SendToAndClose(stream, XmppStreamError.NotAuthorized);
context.UserManager.RemoveUser(iq.From);
foreach (var s in context.SessionManager.GetBareJidSessions(iq.From))
{
if (s.Stream.Id == stream.Id) continue;
context.Sender.SendToAndClose(s.Stream, XmppStreamError.Conflict);
}
//TODO: remove roster subscriptions
register.RemoveAllChildNodes();
iq.SwitchDirection();
return iq;
}
if (string.IsNullOrEmpty(register.Username) ||
string.IsNullOrEmpty(register.Password) ||
Stringprep.NamePrep(register.Username) != register.Username)
{
var error = XmppStanzaError.ToNotAcceptable(iq);
if (string.IsNullOrEmpty(register.Username)) error.Error.Message = "Empty required field Username.";
else if (string.IsNullOrEmpty(register.Password)) error.Error.Message = "Empty required field Password.";
else if (Stringprep.NamePrep(register.Username) != register.Username) error.Error.Message = "Invalid character.";
return error;
}
var userJid = new Jid(register.Username, stream.Domain, null);
if (context.UserManager.IsUserExists(userJid))
{
return XmppStanzaError.ToConflict(iq);
}
var user = new User(userJid, register.Password);
context.UserManager.SaveUser(user);
register.RemoveAllChildNodes();
if (stream.Authenticated) iq.SwitchDirection();
else iq.To = null;
iq.From = null;
return iq;
}
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:47,代码来源:RegisterHandler.cs
注:本文中的ASC.Xmpp.Core.protocol.client.IQ类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论