本文整理汇总了C#中agsXMPP.protocol.client.Presence类的典型用法代码示例。如果您正苦于以下问题:C# Presence类的具体用法?C# Presence怎么用?C# Presence使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Presence类属于agsXMPP.protocol.client命名空间,在下文中一共展示了Presence类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Client
public Client()
{
Xmpp = new XmppClientConnection("skylabsonline.com");
Xmpp.OnRegistered += XmppOnOnRegistered;
Xmpp.OnRegisterError += XmppOnOnRegisterError;
Xmpp.OnXmppConnectionStateChanged += XmppOnOnXmppConnectionStateChanged;
Xmpp.OnLogin += XmppOnOnLogin;
Xmpp.OnAuthError += XmppOnOnAuthError;
Xmpp.OnRosterItem += XmppOnOnRosterItem;
Xmpp.OnRosterEnd += XmppOnOnRosterEnd;
Xmpp.OnRosterStart += XmppOnOnRosterStart;
Xmpp.OnMessage += XmppOnOnMessage;
Xmpp.OnPresence += XmppOnOnPresence;
Xmpp.OnAgentItem += XmppOnOnAgentItem;
Xmpp.OnIq += XmppOnOnIq;
Xmpp.OnReadXml += XmppOnOnReadXml;
Notifications = new List<Notification>();
Friends = new List<NewUser>();
//GroupChats = new List<NewUser>();
myPresence = new Presence();
Chatting = new Chat(this,Xmpp);
CurrentHostedGamePort = -1;
_games = new List<HostedGameData>();
agsXMPP.Factory.ElementFactory.AddElementType("gameitem", "octgn:gameitem", typeof(HostedGameData));
}
示例2: GetRosterImageIndex
public static int GetRosterImageIndex(Presence pres)
{
if (pres.Type == PresenceType.unavailable)
{
return 0;
}
else if (pres.Type == PresenceType.error)
{
// Don't do anythng here?
}
else
{
switch (pres.Show)
{
case ShowType.NONE:
return 1;
case ShowType.away:
return 2;
case ShowType.chat:
return 4;
case ShowType.xa:
return 3;
case ShowType.dnd:
return 5;
}
}
return 0;
}
示例3: Contact
public Contact(Presence presence)
{
_rosterItem = new RosterItem();
_rosterItem.Jid = presence.From;
BuildSearchText();
}
示例4: GetPointsOfShowType
private static int GetPointsOfShowType(Presence presence)
{
if (presence == null)
{
return 0;
}
if (presence.Type == PresenceType.available)
{
switch (presence.Show)
{
case ShowType.dnd:
{
return 3;
}
case ShowType.xa:
{
return 4;
}
case ShowType.away:
{
return 5;
}
default:
{
return 6;
}
}
}
else
{
return 0;
}
}
示例5: update
//TODO: also check showType
public void update(Presence presence)
{
string sJid = presence.From.Bare;
string sText = presence.Status;
bool isOnline = false;
//handle PresenceType
if ((presence.Type == PresenceType.available) || (presence.Type == PresenceType.invisible)) {
isOnline = true;
} else if (presence.Type == PresenceType.subscribe) {
//TODO: handle subscribe request
} else if (presence.Type == PresenceType.subscribed) {
//TODO: handle answered subscribe message
} else if (presence.Type == PresenceType.unavailable) {
isOnline = false;
}
//update presenceList
for (int i = 0; i < m_PresenceList.Count; i++) {
if (m_PresenceList [i].sJid == sJid) {
m_PresenceList.RemoveAt (i);
break;
}
}
//add ContactPresence if it does not exist
ContactPresence newPresence = new ContactPresence ();
newPresence.sJid = sJid;
newPresence.bIsOnline = isOnline;
newPresence.sText = sText;
this.m_PresenceList.Add (newPresence);
}
示例6: XmppConnectOnOnPresence
public void XmppConnectOnOnPresence(object sender, Presence pres)
{
try
{
if (pres.GetAttribute("name") == "Facebook User")
{
return;
}
Core.Presences.Add(pres);
try
{
var chatItem = new ChatPlayerItem
{
Group = pres.GetAttribute("group"),
IsOnline = true,
Jid = new Jid(pres.GetAttribute("jid")),
Messages = new List<string>(),
Username = pres.GetAttribute("name")
};
Core.AllPlayers.Add(pres.GetAttribute("name"), chatItem);
}
catch
{
var item = Core.AllPlayers[pres.GetAttribute("name")];
Core.AllPlayers.Remove(pres.GetAttribute("name"));
item.IsOnline = true;
Core.AllPlayers.Add(pres.GetAttribute("name"), item);
}
}
catch
{
//MessageBox.Show(ex.ToString());
}
}
示例7: Unsubcribe
/// <summary>
/// Unsubscribe from a contact
/// </summary>
/// <param name="to">Bare Jid of the rosteritem we want to unsubscribe</param>
public void Unsubcribe(Jid to)
{
// <presence to='[email protected]' type='subscribe'/>
Presence pres = new Presence();
pres.Type = PresenceType.unsubscribe;
pres.To = to;
m_connection.Send(pres);
}
示例8: EventPresenceChanged
public EventPresenceChanged(Contact contact, Presence oldPresence, Presence newPresence)
: base(String.Empty, EventSeverity.Info)
{
_contact = contact;
_oldPresence = oldPresence;
_newPresence = newPresence;
Expiration = DateTime.Now.AddSeconds(Settings.Default.UI_Notify_Presence_Exp);
}
示例9: RefuseSubscriptionRequest
//Example: Refusing a presence subscription request:
//<presence to='[email protected]' type='unsubscribed'/>
/// <summary>
/// Refuse subscription request
/// </summary>
/// <param name="to">Bare Jid to approve</param>
public void RefuseSubscriptionRequest(Jid to)
{
// <presence to='[email protected]' type='subscribe'/>
Presence pres = new Presence();
pres.Type = PresenceType.unsubscribed;
pres.To = to;
m_connection.Send(pres);
}
示例10: Subcribe
/// <summary>
/// Subscribe to a contact
/// </summary>
/// <param name="to">Bare Jid of the rosteritem we want to subscribe</param>
/// <param name="message">a message which normally contains the reason why we want to subscibe to this contact</param>
public void Subcribe(Jid to, string message)
{
Presence pres = new Presence();
pres.Type = PresenceType.subscribe;
pres.To = to;
pres.Status = message;
m_connection.Send(pres);
}
示例11: AskAuthorization
public AskAuthorization(Presence presence)
: base(_keyBase, presence.From.Bare)
{
InitializeComponent();
Contact contact = new Contact(presence);
DataContext = contact;
_contact.Content = contact;
}
示例12: OnPresence
private void OnPresence(object sender, Presence pres)
{
foreach (var presenceHandler in _handlers)
{
if (presenceHandler.IsApplicable(pres))
{
presenceHandler.UpdateState(pres);
}
}
}
示例13: frmGroupChat_FormClosed
/// <summary>
/// Envio una precencia de aviso de abandono de sala
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void frmGroupChat_FormClosed(object sender, FormClosedEventArgs e)
{
if (_RoomJid != null)
{
Presence pres = new Presence();
pres.To = _RoomJid;
pres.Type = PresenceType.unavailable;
Util.XmppServices.XmppCon.Send(pres);
}
}
示例14: xmpp_OnPresence
private void xmpp_OnPresence(object sender, Presence pres)
{
if (pres.Type == PresenceType.subscribe)
{
xmpp.PresenceManager.ApproveSubscriptionRequest(pres.From);
}
else if (pres.Type == PresenceType.available)
{
//Xmpp.Send(new Message(pres.From, "Versículo de hoje: \"Porque Deus amou ao mundo de tal maneira que deu o seu Filho unigênito, para que todo o que nele crê não pereça, mas tenha a vida eterna.\" João 3:16"));
}
}
示例15: OnPresence
public void OnPresence(Client client, Presence presence)
{
var clientContext = SessionModel.GetClientContext(client);
if (clientContext.Jid.Equals(presence.From, new CaseInsensitiveComparer()))
{
return;
}
var fromJid = presence.From.ToString().ToLower();
var capsKey = new CapsSource(client, fromJid);
ProcessedPresence(capsKey, presence);
}