本文整理汇总了C#中agsXMPP.protocol.client.IQ.GenerateId方法的典型用法代码示例。如果您正苦于以下问题:C# IQ.GenerateId方法的具体用法?C# IQ.GenerateId怎么用?C# IQ.GenerateId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类agsXMPP.protocol.client.IQ
的用法示例。
在下文中一共展示了IQ.GenerateId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetConfig
/// <summary>
/// Send message to HarmonyHub to request Configuration.
/// Result is parsed by OnIq based on ClientCommandType
/// </summary>
public void GetConfig()
{
EnsureConnection();
var iqToSend = new IQ { Type = IqType.get, Namespace = "", From = "1", To = "guest" };
iqToSend.AddChild(HarmonyDocuments.ConfigDocument());
iqToSend.GenerateId();
var iqGrabber = new IqGrabber(Xmpp);
var iq = iqGrabber.SendIq(iqToSend, 10000);
if (iq != null)
{
var match = IdentityRegex.Match(iq.InnerXml);
if (match.Success)
{
RawConfig = match.Groups[1].ToString();
Config = null;
try
{
Config = new JavaScriptSerializer().Deserialize<HarmonyConfigResult>(RawConfig);
}
catch { }
}
}
}
示例2: SwapAuthToken
/// <summary>
/// Send message to HarmonyHub with UserAuthToken, wait for SessionToken
/// </summary>
/// <param name="userAuthToken"></param>
/// <returns></returns>
public string SwapAuthToken(string userAuthToken)
{
var iqToSend = new IQ { Type = IqType.get, Namespace = "", From = "1", To = "guest" };
iqToSend.AddChild(HarmonyDocuments.LogitechPairDocument(userAuthToken));
iqToSend.GenerateId();
var iqGrabber = new IqGrabber(Xmpp);
iqGrabber.SendIq(iqToSend, 10);
WaitForData(5);
return _sessionToken;
}
示例3: SwapAuthToken
/// <summary>
/// Send message to HarmonyHub with UserAuthToken, wait for SessionToken
/// </summary>
/// <param name="userAuthToken"></param>
/// <returns></returns>
public string SwapAuthToken(string userAuthToken)
{
EnsureConnection();
var iqToSend = new IQ { Type = IqType.get, Namespace = "", From = "1", To = "guest" };
iqToSend.AddChild(HarmonyDocuments.LogitechPairDocument(userAuthToken));
iqToSend.GenerateId();
var iqGrabber = new IqGrabber(Xmpp);
var iq = iqGrabber.SendIq(iqToSend, 5000);
if (iq != null)
{
var match = IdentityRegex.Match(iq.InnerXml);
if (match.Success)
{
return match.Groups[1].ToString();
}
}
return null;
}
示例4: GenerateIq
/// <summary>
/// Generate an IQ for the supplied Document
/// </summary>
/// <param name="document">Document</param>
/// <returns>IQ</returns>
private static IQ GenerateIq(Document document)
{
// Create the IQ to send
var iqToSend = new IQ
{
Type = IqType.get,
Namespace = "",
From = "1",
To = "guest"
};
// Add the real content for the Harmony
iqToSend.AddChild(document);
// Generate an unique ID, this is used to correlate the reply to the request
iqToSend.GenerateId();
return iqToSend;
}
示例5: StartActivity
/// <summary>
/// Send message to HarmonyHub to start a given activity
/// Result is parsed by OnIq based on ClientCommandType
/// </summary>
/// <param name="activityId"></param>
public void StartActivity(string activityId)
{
EnsureConnection();
var iqToSend = new IQ { Type = IqType.get, Namespace = "", From = "1", To = "guest" };
iqToSend.AddChild(HarmonyDocuments.StartActivityDocument(activityId));
iqToSend.GenerateId();
Xmpp.Send(iqToSend);
}
示例6: Sequence
/// <summary>
/// Send message to HarmonyHub to request to run a sequence
/// Result is parsed by OnIq based on ClientCommandType
/// </summary>
/// <param name="deviceId"></param>
/// <param name="command"></param>
public void Sequence(int sequenceId)
{
EnsureConnection();
var iqToSend = new IQ { Type = IqType.get, Namespace = "", From = "1", To = "guest" };
iqToSend.AddChild(HarmonyDocuments.SequenceDocument(sequenceId));
iqToSend.GenerateId();
Xmpp.Send(iqToSend);
}
示例7: PressButton
/// <summary>
/// Send message to HarmonyHub to request to press a button
/// Result is parsed by OnIq based on ClientCommandType
/// </summary>
/// <param name="deviceId"></param>
/// <param name="command"></param>
public void PressButton(string deviceId, string command)
{
EnsureConnection();
var iqToSend = new IQ { Type = IqType.get, Namespace = "", From = "1", To = "guest" };
iqToSend.AddChild(HarmonyDocuments.IRCommandDocument(deviceId, command));
iqToSend.GenerateId();
Xmpp.Send(iqToSend);
}
示例8: GetCurrentActivity
/// <summary>
/// Send message to HarmonyHub to request current activity
/// Result is parsed by OnIq based on ClientCommandType
/// </summary>
public void GetCurrentActivity()
{
EnsureConnection();
var iqToSend = new IQ { Type = IqType.get, Namespace = "", From = "1", To = "guest" };
iqToSend.AddChild(HarmonyDocuments.GetCurrentActivityDocument());
iqToSend.GenerateId();
var iqGrabber = new IqGrabber(Xmpp);
var iq = iqGrabber.SendIq(iqToSend, 5000);
if (iq != null)
{
var match = IdentityRegex.Match(iq.InnerXml);
if (match.Success)
{
CurrentActivity = match.Groups[1].ToString().Split('=')[1];
}
}
}
示例9: GetConfig
/// <summary>
/// Send message to HarmonyHub to request Configuration.
/// Result is parsed by OnIq based on ClientCommandType
/// </summary>
public void GetConfig()
{
_clientCommand = ClientCommandType.GetConfig;
var iqToSend = new IQ { Type = IqType.get, Namespace = "", From = "1", To = "guest" };
iqToSend.AddChild(HarmonyDocuments.ConfigDocument());
iqToSend.GenerateId();
var iqGrabber = new IqGrabber(Xmpp);
iqGrabber.SendIq(iqToSend, 10);
WaitForData(5);
}
示例10: StartActivity
/// <summary>
/// Send message to HarmonyHub to start a given activity
/// Result is parsed by OnIq based on ClientCommandType
/// </summary>
/// <param name="activityId"></param>
public void StartActivity(string activityId)
{
_clientCommand = ClientCommandType.StartActivity;
var iqToSend = new IQ { Type = IqType.get, Namespace = "", From = "1", To = "guest" };
iqToSend.AddChild(HarmonyDocuments.StartActivityDocument(activityId));
iqToSend.GenerateId();
var iqGrabber = new IqGrabber(Xmpp);
iqGrabber.SendIq(iqToSend, 10);
WaitForData(5);
}
示例11: PressButton
/// <summary>
/// Send message to HarmonyHub to request to press a button
/// Result is parsed by OnIq based on ClientCommandType
/// </summary>
/// <param name="deviceId"></param>
/// <param name="command"></param>
public void PressButton(string deviceId, string command)
{
_clientCommand = ClientCommandType.PressButton;
var iqToSend = new IQ { Type = IqType.get, Namespace = "", From = "1", To = "guest" };
iqToSend.AddChild(HarmonyDocuments.IRCommandDocument(deviceId, command));
iqToSend.GenerateId();
var iqGrabber = new IqGrabber(Xmpp);
iqGrabber.SendIq(iqToSend, 5);
WaitForData(5);
}
示例12: OnRegistrationFieldsResult
private void OnRegistrationFieldsResult(object sender, IQ iq, object data)
{
if (iq.Type != IqType.error)
{
if (iq.Query is Register)
{
RegisterEventArgs args = new RegisterEventArgs(iq.Query as Register);
if (OnRegisterInformation != null)
OnRegisterInformation(this, args);
DoChangeXmppConnectionState(XmppConnectionState.Registering);
IQ regIq = new IQ(IqType.set);
regIq.GenerateId();
regIq.To = new Jid(base.Server);
//RegisterIq regIq = new RegisterIq(IqType.set, new Jid(base.Server));
if (args.Auto)
{
Register reg = new Register(this.m_Username, this.m_Password);
regIq.Query = reg;
}
else
{
regIq.Query = args.Register;
}
IqGrabber.SendIq(regIq, new IqCB(OnRegisterResult), data);
}
}
else
{
if (OnRegisterError != null)
OnRegisterError(this, iq);
}
}
示例13: OnGetAuthInfo
private void OnGetAuthInfo(object sender, IQ iq, object data)
{
// We get smth like this and should add password (digest) and ressource
// Recv:<iq type="result" id="MX_7"><query xmlns="jabber:iq:auth"><username>gnauck</username><password/><digest/><resource/></query></iq>
// Send:<iq type='set' id='mx_login'>
// <query xmlns='jabber:iq:auth'><username>gnauck</username><digest>27c05d464e3f908db3b2ca1729674bfddb28daf2</digest><resource>Office</resource></query>
// </iq>
// Recv:<iq id="mx_login" type="result"/>
iq.GenerateId();
iq.SwitchDirection();
iq.Type = IqType.set;
Auth auth = (Auth) iq.Query;
auth.Resource = this.m_Resource;
auth.SetAuth(this.m_Username, this.m_Password, this.StreamId);
IqGrabber.SendIq(iq, new IqCB(OnAuthenticate), null);
}
示例14: cmdSearch_Click
private void cmdSearch_Click(object sender, EventArgs e)
{
/*
Example 8. Entity Submits Search Form
<iq type='set'
from='[email protected]/balcony'
to='characters.shakespeare.lit'
id='search4'
xml:lang='en'>
<query xmlns='jabber:iq:search'>
<x xmlns='jabber:x:data' type='submit'>
<field type='hidden' var='FORM_TYPE'>
<value>jabber:iq:search</value>
</field>
<field var='gender'>
<value>male</value>
</field>
</x>
</query>
</iq>
*/
IQ siq = null;
if (!_IsOldSearch)
{
// Validate the Form before we submit it
if (xDataControl.Validate())
{
siq = new SearchIq();
//siq.To = xDataControl.From;
//siq.Type = IqType.set;
((SearchIq)siq).Query.Data = xDataControl.CreateResponse();
}
}
else
{
siq = new IQ();
siq.GenerateId();
siq.Query = xDataControl.CreateSearchResponse();
}
siq.To = xDataControl.From;
siq.Type = IqType.set;
// dicard the pending requests if there is one
if (_IdSearchRequest != null)
m_XmppCon.IqGrabber.Remove(_IdSearchRequest);
// and cache the id of the new pending request
_IdSearchRequest = siq.Id;
// finally send the query
m_XmppCon.IqGrabber.SendIq(siq, new IqCB(OnSearchResult), null);
}
示例15: cmdSearch_Click
/// <summary>
/// Efectuar consulta
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void cmdSearch_Click(object sender, EventArgs e)
{
/*
Ejemlo Entity Submits Search Form
<iq type='set'
from='[email protected]/balcony'
to='characters.shakespeare.lit'
id='search4'
xml:lang='en'>
<query xmlns='jabber:iq:search'>
<x xmlns='jabber:x:data' type='submit'>
<field type='hidden' var='FORM_TYPE'>
<value>jabber:iq:search</value>
</field>
<field var='gender'>
<value>male</value>
</field>
</x>
</query>
</iq>
*/
IQ searchIQ = null;
if (!_IsOldSearch)
{
// validar entrada de datos
if (xDataControl.Validate())
{
searchIQ = new SearchIq();
//siq.To = xDataControl.From;
//siq.Type = IqType.set;
((SearchIq)searchIQ).Query.Data = xDataControl.CreateResponse();
}
}
else
{
searchIQ = new IQ();
searchIQ.GenerateId();
searchIQ.Query = xDataControl.CreateSearchResponse();
}
searchIQ.To = xDataControl.From;
searchIQ.Type = IqType.set;
// Elimino alguna antigua si existe
if (_IdSearchRequest != null)
Util.XmppServices.XmppCon.IqGrabber.Remove(_IdSearchRequest);
// Guardo la actual consulta
_IdSearchRequest = searchIQ.Id;
// Envio el Iq
Util.XmppServices.XmppCon.IqGrabber.SendIq(searchIQ, new IqCB(OnSearchResult), null);
}