本文整理汇总了C#中IQ类的典型用法代码示例。如果您正苦于以下问题:C# IQ类的具体用法?C# IQ怎么用?C# IQ使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IQ类属于命名空间,在下文中一共展示了IQ类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
public void Create()
{
Element.ResetID();
IQ iq = new IQ(doc);
Assert.AreEqual("<iq id=\"JN_1\" type=\"get\" />", iq.ToString());
iq = new IQ(doc);
Assert.AreEqual("<iq id=\"JN_2\" type=\"get\" />", iq.ToString());
iq.Query = new Auth(doc);
Assert.AreEqual("<iq id=\"JN_2\" type=\"get\"><query xmlns=\"jabber:iq:auth\" /></iq>", iq.ToString());
}
示例2: GotIQ
/// <summary>
/// Analyses an IQ paquet and chooses to handle it or not
/// </summary>
/// <param name="sender"></param>
/// <param name="iq"></param>
private void GotIQ(object sender, IQ iq)
{
if (!iq.Handled &&
iq.Query != null && iq.Type == IQType.get &&
iq.Query.NamespaceURI == URI.PING)
{
iq.Handled = true;
this.Write(iq.GetAcknowledge(m_stream.Document));
}
}
示例3: ProcessDiscoInfo
private void ProcessDiscoInfo(IQ iq)
{
IQ diiq = new IQ();
diiq.To = iq.From;
diiq.Id = iq.Id;
diiq.Type = IqType.result;
diiq.Query = xmppConnection.DiscoInfo;
xmppConnection.Send(diiq);
}
示例4: AddRosterItemComplete
void AddRosterItemComplete(object sender, IQ response, object data)
{
if (response.Type == IQType.set) {
QApplication.Invoke(delegate {
Gui.MainWindow.HideLightbox();
});
} else {
QApplication.Invoke(delegate {
QMessageBox.Critical(base.TopLevelWidget(), "Failed to add user", "Server returned an error.");
});
}
}
示例5: IQException
/// <summary>
/// An authorization exception from an IQ.
/// TODO: Add constructor for code/message
/// TODO: understand v1 errors
/// </summary>
/// <param name="iq"></param>
public IQException(IQ iq)
{
if (iq == null)
{
//timeout
m_code = 504;
m_message = "Request timed out";
}
else
{
Error e = iq.Error;
m_code = e.Code;
m_message = e.InnerText;
}
}
示例6: DiscoverCapabilities
public void DiscoverCapabilities()
{
IQ requestIq = new IQ();
ServiceQuery request = new ServiceQuery();
request.Node = this.DiscoveryInfoNode;
requestIq.From = this.Session.UserId.ToString();
requestIq.ID = XmppIdentifierGenerator.Generate();
requestIq.To = this.resource.ResourceId.ToString();
requestIq.Type = IQType.Get;
requestIq.Items.Add(request);
this.pendingMessages.Add(requestIq.ID);
this.Session.Send(requestIq);
}
示例7: Publish
public void Publish(string node, XmlElement item)
{
IQ iq = new IQ(m_Account.Client.Document);
iq.Type = IQType.set;
PubSub pubsub = new PubSub(m_Account.Client.Document);
pubsub.SetAttribute("xmlns", "http://jabber.org/protocol/pubsub");
Publish publish = new Publish(m_Account.Client.Document);
publish.SetAttribute("node", node);
publish.AddChild(item);
pubsub.AddChild(publish);
iq.AddChild(pubsub);
if (m_Account.ConnectionState == AccountConnectionState.Connected) {
m_Account.Send(iq);
} else {
lock (m_Queue) {
m_Queue.Enqueue(iq);
}
}
}
示例8: OnSetRegister
private void OnSetRegister(object sender, IQ iq, object data)
{
if (OnRegistered == null)
return;
if (InvokeRequired)
CheckedInvoke(OnRegistered, new object[] {this, iq});
else
OnRegistered(this, iq);
}
示例9: OnGetRegister
private void OnGetRegister(object sender, IQ iq, object data)
{
if (iq == null)
{
FireOnError(new IQTimeoutException((JID) data));
return;
}
if (iq.Type == IQType.Error)
{
if (OnRegistered != null)
{
if (InvokeRequired)
CheckedInvoke(OnRegistered, new object[] {this, iq});
else
OnRegistered(this, iq);
}
}
else if (iq.Type == IQType.Result)
{
JID jid = (JID) data;
iq.Type = IQType.Set;
iq.From = null;
iq.To = jid.Server;
iq.ID = Element.NextID();
Register r = iq.Query as Register;
if (r == null)
throw new BadProtocolException(iq, "Expected a register response");
protocol.x.Data xdata = r["x", URI.XDATA] as protocol.x.Data;
protocol.x.Field f;
if (xdata != null)
{
f = xdata.GetField("username");
if (f != null)
f.Val = jid.User;
f = xdata.GetField("password");
if (f != null)
f.Val = Password;
}
else
{
r.Username = jid.User;
r.Password = Password;
}
bool res = true;
if (OnRegisterInfo != null)
{
if (InvokeRequired)
// Don't use CheckedInvoke, since we want this to be synchronous
res = (bool)InvokeControl.Invoke(OnRegisterInfo, new object[] { this, r });
else
res = OnRegisterInfo(this, r);
if (xdata != null)
{
f = xdata.GetField("username");
if (f != null)
{
User = f.Val;
}
f = xdata.GetField("password");
if (f != null)
Password = f.Val;
}
else
{
User = r.Username;
Password = r.Password;
}
}
if (!res)
{
Close();
return;
}
if (xdata != null)
xdata.Type = protocol.x.XDataType.result;
Tracker.BeginIQ(iq, OnSetRegister, jid);
}
}
示例10: JabberClient_OnSASLEnd
private void JabberClient_OnSASLEnd(Object sender, protocol.stream.Features feat)
{
lock (StateLock)
{
State = BindState.Instance;
}
if (feat["bind", URI.BIND] != null)
{
IQ iq = new IQ(Document) {Type = IQType.Set};
protocol.stream.Bind bind = new protocol.stream.Bind(Document);
if (!string.IsNullOrEmpty(Resource))
bind.Resource = Resource;
iq.AddChild(bind);
Tracker.BeginIQ(iq, GotResource, feat);
}
else if (feat["session", URI.SESSION] != null)
{
IQ iq = new IQ(Document) {Type = IQType.Set};
iq.AddChild(new protocol.stream.Session(Document));
Tracker.BeginIQ(iq, GotSession, feat);
}
else
IsAuthenticated = true;
}
示例11: GotResource
private void GotResource(object sender, IQ iq, object state)
{
protocol.stream.Features feat = state as protocol.stream.Features;
if (iq == null)
{
FireOnError(new AuthenticationFailedException("Timeout authenticating"));
return;
}
if (iq.Type != IQType.Result)
{
Error err = iq.Error;
if (err == null)
FireOnError(new AuthenticationFailedException("Unknown error binding resource"));
else
FireOnError(new AuthenticationFailedException("Error binding resource: " + err.OuterXml));
return;
}
XmlElement bind = iq["bind", URI.BIND];
if (bind == null)
{
FireOnError(new AuthenticationFailedException("No binding returned. Server implementation error."));
return;
}
XmlElement jid = bind["jid"];
if (jid == null)
{
FireOnError(new AuthenticationFailedException("No jid returned from binding. Server implementation error."));
return;
}
this[Options.JID] = new JID(jid.InnerText);
if (feat["session", URI.SESSION] != null)
{
IQ iqs = new IQ(Document) {Type = IQType.Set};
iqs.AddChild(new protocol.stream.Session(Document));
Tracker.BeginIQ(iqs, GotSession, feat);
}
else
IsAuthenticated = true;
}
示例12: FireOnIQ
private void FireOnIQ(object sender, IQ iq)
{
// We know we're on the GUI thread.
if (OnIQ != null)
OnIQ(this, iq);
if (AutoIQErrors)
{
if (!iq.Handled &&
iq.HasAttribute("from") && // Belt. Suspenders. Don't respond to roster pushes.
((iq.Type == IQType.Get) || (iq.Type == IQType.Set)))
{
Write(iq.GetErrorResponse(Document, Error.FeatureNotImplemented));
}
}
}
示例13: NewIncomingSessionRequest
internal void NewIncomingSessionRequest(GoogleTalkIQ iq)
{
IncomingRequestMessage = iq;
RemoteJID = iq.From;
IQ iqresponse = new IQ();
iqresponse.ID = IncomingRequestMessage.ID;
iqresponse.From = XMPPClient.JID;
iqresponse.To = IncomingRequestMessage.From;
iqresponse.Type = IQType.result.ToString();
XMPPClient.SendXMPP(iqresponse);
GoogleTalkSessionManager.FireNewSession(this.SessionId, iq);
}
示例14: muc_OnRoomConfig
private IQ muc_OnRoomConfig(Room room, IQ parent)
{
muzzle.XDataForm form = new muzzle.XDataForm(parent);
if (form.ShowDialog() != DialogResult.OK)
return null;
return (IQ)form.GetResponse();
}
示例15: GotIQ
private void GotIQ(object sender, IQ iq)
{
if ((iq.Query == null) ||
(iq.Query.NamespaceURI != jabber.protocol.URI.ROSTER) ||
((iq.Type != IQType.result) && (iq.Type != IQType.set)))
return;
iq.Handled = true;
Roster r = (Roster) iq.Query;
if ((iq.Type == IQType.result) && (OnRosterBegin != null))
OnRosterBegin(this);
foreach (Item i in r.GetItems())
{
lock (this)
{
if (i.Subscription == Subscription.remove)
{
m_items.Remove(i.JID);
}
else
{
if (m_items.Contains(i.JID))
m_items.Remove(i.JID);
m_items[i.JID] = i;
}
}
if (OnRosterItem != null)
OnRosterItem(this, i);
}
if ((iq.Type == IQType.result) && (OnRosterEnd != null))
OnRosterEnd(this);
}