本文整理汇总了C#中IQ类的典型用法代码示例。如果您正苦于以下问题:C# IQ类的具体用法?C# IQ怎么用?C# IQ使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IQ类属于命名空间,在下文中一共展示了IQ类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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());
}
开发者ID:newyorknight,项目名称:jabber.net,代码行数:11,代码来源:IQTest.cs
示例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));
}
}
开发者ID:emilio-simoes,项目名称:JabberNet-2010,代码行数:16,代码来源:PingManager.cs
示例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);
}
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:11,代码来源:DiscoManager.cs
示例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.");
});
}
}
开发者ID:jrudolph,项目名称:synapse,代码行数:12,代码来源:AddFriendWindow.cs
示例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;
}
}
开发者ID:sq5gvm,项目名称:JabberNet-2010,代码行数:21,代码来源:ProtocolException.cs
示例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);
}
开发者ID:eightrivers,项目名称:babelim,代码行数:17,代码来源:XmppContactEntityCapabilities.cs
示例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);
}
}
}
开发者ID:jrudolph,项目名称:synapse,代码行数:20,代码来源:PersonalEventing.cs
示例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);
}
开发者ID:csfmeridian,项目名称:jabber-net,代码行数:10,代码来源:JabberClient.cs
示例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);
}
}
开发者ID:csfmeridian,项目名称:jabber-net,代码行数:81,代码来源:JabberClient.cs
示例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;
}
开发者ID:csfmeridian,项目名称:jabber-net,代码行数:26,代码来源:JabberClient.cs
示例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;
}
开发者ID:csfmeridian,项目名称:jabber-net,代码行数:42,代码来源:JabberClient.cs
示例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));
}
}
}
开发者ID:csfmeridian,项目名称:jabber-net,代码行数:16,代码来源:JabberClient.cs
示例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);
}
开发者ID:Hitchhikrr,项目名称:Voip,代码行数:15,代码来源:GoogleTalkLogic.cs
示例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();
}
开发者ID:eNoise,项目名称:cyclops-chat,代码行数:8,代码来源:MainForm.cs
示例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);
}
开发者ID:rankida,项目名称:HangoutPhone,代码行数:34,代码来源:RosterManager.cs
示例16: NewIQ
public override bool NewIQ(IQ iq)
{
if ((OutgoingRequestMessage != null) && (iq.ID == OutgoingRequestMessage.ID))
{
/// Got an ack, analyze it an tell the client what is going on
IQResponseAction response = new IQResponseAction();
if (iq.Type != IQType.result.ToString())
{
response.AcceptIQ = false;
response.Error = iq.Error;
}
GoogleTalkSessionManager.FireNewSessionAckReceived(SessionId, response);
return true;
}
if ((AcceptSessionMessage != null) && (iq.ID == AcceptSessionMessage.ID))
{
/// Client accept our session
IQResponseAction response = new IQResponseAction();
if (iq.Type != IQType.result.ToString())
{
response.AcceptIQ = false;
response.Error = iq.Error;
}
GoogleTalkSessionManager.FireSessionAcceptedAck(SessionId, response);
return true;
}
if ((TerminateSessionRequest != null) && (iq.ID == TerminateSessionRequest.ID))
{
/// Got an ack, analyze it an tell the client what is going on
///
GoogleTalkSessionManager.FireSessionTerminated(SessionId);
IsCompleted = true;
return true;
}
return false;
}
开发者ID:Hitchhikrr,项目名称:Voip,代码行数:40,代码来源:GoogleTalkLogic.cs
示例17: NewJingleIQ
public void NewJingleIQ(GoogleTalkIQ gtiq)
{
/// New message coming in, see if it is session accept or session terminate
///
if (gtiq.Type == IQType.error.ToString())
{
GoogleTalkSessionManager.FireSessionTerminated(this.SessionId);
return;
}
if (gtiq.Type == IQType.set.ToString())
{
if (gtiq.Type == GoogleSession.Accept)
{
IQ iqresponse = new IQ();
iqresponse.ID = gtiq.ID;
iqresponse.From = XMPPClient.JID;
iqresponse.To = gtiq.From;
iqresponse.Type = IQType.result.ToString();
XMPPClient.SendXMPP(iqresponse);
GoogleTalkSessionManager.FireSessionAcceptedReceived(this.SessionId, gtiq);
}
else if (gtiq.Type == GoogleSession.Terminate)
{
/// Tell the user we've been terminated. Ack and finish this logic
///
IQ iqresponse = new IQ();
iqresponse.ID = gtiq.ID;
iqresponse.From = XMPPClient.JID;
iqresponse.To = gtiq.From;
iqresponse.Type = IQType.result.ToString();
XMPPClient.SendXMPP(iqresponse);
GoogleTalkSessionManager.FireSessionTerminated(this.SessionId);
this.IsCompleted = true;
}
else if (gtiq.Type == GoogleSession.TransportInfo)
{
IQ iqresponse = new IQ();
iqresponse.ID = gtiq.ID;
iqresponse.From = XMPPClient.JID;
iqresponse.To = gtiq.From;
iqresponse.Type = IQType.result.ToString();
XMPPClient.SendXMPP(iqresponse);
GoogleTalkSessionManager.FireSessionTransportInfoReceived(this.SessionId, gtiq);
}
else
{
IQ iqresponse = new IQ();
iqresponse.ID = gtiq.ID;
iqresponse.From = XMPPClient.JID;
iqresponse.To = gtiq.From;
iqresponse.Type = IQType.error.ToString();
iqresponse.Error = new Error("<Unknown action />");
XMPPClient.SendXMPP(iqresponse);
}
}
}
开发者ID:Hitchhikrr,项目名称:Voip,代码行数:63,代码来源:GoogleTalkLogic.cs
示例18: jc_OnIQ
private void jc_OnIQ(object sender, IQ iq)
{
if (iq.Type != IQType.get)
return;
XmlElement query = iq.Query;
if (query == null)
return;
// <iq id="jcl_8" to="me" from="you" type="get"><query xmlns="jabber:iq:version"/></iq>
if (query is jabber.protocol.iq.Version)
{
iq = iq.GetResponse(jc.Document);
jabber.protocol.iq.Version ver = iq.Query as jabber.protocol.iq.Version;
if (ver != null)
{
ver.OS = Environment.OSVersion.ToString();
ver.EntityName = Application.ProductName;
ver.Ver = Application.ProductVersion;
}
jc.Write(iq);
return;
}
if (query is Time)
{
iq = iq.GetResponse(jc.Document);
Time tim = iq.Query as Time;
if (tim != null) tim.SetCurrentTime();
jc.Write(iq);
return;
}
if (query is Last)
{
iq = iq.GetResponse(jc.Document);
Last last = iq.Query as Last;
if (last != null) last.Seconds = (int)IdleTime.GetIdleTime();
jc.Write(iq);
return;
}
}
开发者ID:eNoise,项目名称:cyclops-chat,代码行数:42,代码来源:MainForm.cs
示例19: CreateDiscoInfoResponse
private IQ CreateDiscoInfoResponse(string id)
{
IQ returnIq = new IQ(doc);
returnIq.SetAttribute("id", id);
returnIq.SetAttribute("from", jid);
returnIq.SetAttribute("type", "result");
DiscoInfo info = new DiscoInfo(doc);
info.AddIdentity("server", "im", "jabber2 4.2.16.6", null);
info.AddFeature(URI.DISCO_ITEMS);
info.AddFeature(URI.DISCO_INFO);
returnIq.Query = info;
return returnIq;
}
开发者ID:rankida,项目名称:HangoutPhone,代码行数:16,代码来源:DiscoManagerTest.cs
示例20: jc_OnRegistered
private void jc_OnRegistered(object sender, IQ iq)
{
if (iq.Type == IQType.result)
jc.Login();
else
pnlCon.Text = "Registration error";
}
开发者ID:eNoise,项目名称:cyclops-chat,代码行数:7,代码来源:MainForm.cs
注:本文中的IQ类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论