当前位置: 首页>>代码示例>>C#>>正文


C# IQ.SwitchDirection方法代码示例

本文整理汇总了C#中ASC.Xmpp.Core.protocol.client.IQ.SwitchDirection方法的典型用法代码示例。如果您正苦于以下问题:C# IQ.SwitchDirection方法的具体用法?C# IQ.SwitchDirection怎么用?C# IQ.SwitchDirection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ASC.Xmpp.Core.protocol.client.IQ的用法示例。


在下文中一共展示了IQ.SwitchDirection方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例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:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:27,代码来源:PrivateHandler.cs

示例3: 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:ridhouan,项目名称:teamlab.v6.5,代码行数:47,代码来源:RegisterHandler.cs

示例4: 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

示例5: SetPrivate

		private IQ SetPrivate(XmppStream stream, IQ iq, XmppHandlerContext context)
		{
			var @private = (Private)iq.Query;
			
            if ([email protected]) return XmppStanzaError.ToNotAcceptable(iq);

			foreach (var childNode in @private.ChildNodes)
			{
				if (childNode is Element)
				{
                    context.StorageManager.PrivateStorage.SetPrivate(iq.From, (Element)childNode);
				}
			}
            iq.Query = null;
			iq.SwitchDirection();
			iq.Type = IqType.result;
			return iq;
		}
开发者ID:vipwan,项目名称:CommunityServer,代码行数:18,代码来源:PrivateHandler.cs

示例6: GetRegister

		private IQ GetRegister(XmppStream stream, IQ iq, XmppHandlerContext context)
		{
			var register = (Register)iq.Query;
			register.Username = string.Empty;
			register.Password = string.Empty;
			iq.Type = IqType.result;

			if (iq.From.HasUser && context.UserManager.IsUserExists(iq.From))
			{
				register.Username = iq.From.User;
				register.AddChild(new Element("registered"));
				iq.SwitchDirection();
				iq.From = null;
			}
			else
			{
				iq.From = iq.To = null;
			}
			return iq;
		}
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:20,代码来源:RegisterHandler.cs

示例7: HandleIQ

        public override IQ HandleIQ(XmppStream stream, IQ iq, XmppHandlerContext context)
        {
            //Admins iq

                //New member
                MucRoomMember member = Room.GetRealMember(iq.From);
                if (member!=null)
                {
                    if (iq.Query!=null)
                    {
                        if (iq.Query is Admin && (member.Affiliation==Affiliation.admin || member.Affiliation==Affiliation.owner))
                        {
                            Room.AdminCommand(iq, member);
                        }
                        else if (iq.Query is Owner && (member.Affiliation == Affiliation.owner))
                        {
                            Room.OwnerCommand(iq, member);
                        }
                        else
                        {
                            XmppStanzaError.ToForbidden(iq);
                        }
                    }
                    else
                    {
                        XmppStanzaError.ToBadRequest(iq);
                    }
            }
            else
            {
                XmppStanzaError.ToForbidden(iq);
            }
            if (!iq.Switched)
            {
                iq.SwitchDirection();
            }
            iq.From = Room.Jid;
            return iq;
        }
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:39,代码来源:MucRoomStanzaHandler.cs

示例8: HandleIQ

		public override IQ HandleIQ(XmppStream stream, IQ iq, XmppHandlerContext context)
		{
			if (iq.Type != IqType.get || !iq.HasTo) return XmppStanzaError.ToNotAcceptable(iq);

			var currSession = context.SessionManager.GetSession(iq.From);
			if (currSession == null || !currSession.Available) return XmppStanzaError.ToForbidden(iq);

            double seconds = 0;//available
			
            if (iq.To.IsServer)
			{
				seconds = (DateTime.UtcNow - startedTime).TotalSeconds;
			}
			else
			{
				var session = context.SessionManager.GetSession(iq.To);
				if (session == null || !session.Available)
				{
					var lastActivity = context.StorageManager.OfflineStorage.GetLastActivity(iq.To);
					if (lastActivity != null)
					{
						seconds = (DateTime.UtcNow - lastActivity.LogoutDateTime).TotalSeconds;
						iq.Query.Value = lastActivity.Status;
					}
					else
					{
						return XmppStanzaError.ToRecipientUnavailable(iq);
					}
				}
			}

			((Last)(iq.Query)).Seconds = (int)seconds;
			iq.Type = IqType.result;
			iq.SwitchDirection();
			return iq;
		}
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:36,代码来源:LastHandler.cs

示例9: OwnerCommand

		public void OwnerCommand(IQ iq, MucRoomMember member)
		{
			Owner owner = iq.Query as Owner;

			// look for destroy
			if (owner != null)
			{
				Destroy destroy = owner.SelectSingleElement(typeof(Destroy)) as Destroy;
				if (destroy != null)
				{
					DestroyRoom(destroy);
					return;
				}

				if (!owner.HasChildElements)
				{
					// Return config
					owner.AddChild(RoomSettings.GetDataForm(member.Jid));
				}

				Data dataSubmit = (Data)owner.SelectSingleElement(typeof(Data));

				// form config
				if (dataSubmit != null && dataSubmit.Type == XDataFormType.submit)
				{
					RoomSettings.SubmitForm(dataSubmit);
					SettingsSave();
					iq.Query.RemoveAllChildNodes();
				}
			}

			iq.Type = IqType.result;
			iq.SwitchDirection();
		}
开发者ID:ridhouan,项目名称:teamlab.v6.5,代码行数:34,代码来源:MucRoom.cs

示例10: ToResult

		private IQ ToResult(IQ iq)
		{
			if (!iq.Switched) iq.SwitchDirection();
			iq.Type = IqType.result;
			return iq;
		}
开发者ID:vipwan,项目名称:CommunityServer,代码行数:6,代码来源:DiscoHandler.cs

示例11: GetHistory

        private IQ GetHistory(XmppStream stream, IQ iq, XmppHandlerContext context)
        {
            if (!iq.HasTo) return XmppStanzaError.ToServiceUnavailable(iq);

            FlushMessageBuffer();

            var history = (History)iq.Query;
            history.RemoveAllChildNodes();
            foreach (var m in archiveStore.GetMessages(iq.From, iq.To, history.From, history.To, history.Count))
            {
                history.AddChild(HistoryItem.FromMessage(m));
            }

            iq.Type = IqType.result;
            iq.SwitchDirection();
            return iq;
        }
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:17,代码来源:MessageArchiveHandler.cs

示例12: SetPrivateLog

        private IQ SetPrivateLog(XmppStream stream, IQ iq, XmppHandlerContext context)
        {
            var privateLog = (PrivateLog)iq.Query;
            foreach (var item in privateLog.SelectElements<PrivateLogItem>())
            {
                archiveStore.SetMessageLogging(iq.From, item.Jid, item.Log);
                var to = new Jid(item.Jid.Bare);
                var session = context.SessionManager.GetSession(to);
                if (session != null)
                {
                    var info = new IQ(IqType.set);
                    info.Id = UniqueId.CreateNewId();
                    info.From = iq.From;
                    info.To = session.Jid;
                    info.Query = new PrivateLog();
                    info.Query.AddChild(new PrivateLogItem() { Jid = iq.From, Log = item.Log });
                    context.Sender.SendTo(session, info);
                }
            }
            privateLog.RemoveAllChildNodes();

            iq.SwitchDirection();
            iq.Type = IqType.result;
            return iq;
        }
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:25,代码来源:MessageArchiveHandler.cs

示例13: 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:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:13,代码来源:MessageArchiveHandler.cs


注:本文中的ASC.Xmpp.Core.protocol.client.IQ.SwitchDirection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。