/// <summary> /// Initializes a new instance of the Presence class. /// </summary> /// <param name="to">The JID of the intended recipient for the stanza.</param> /// <param name="from">The JID of the sender.</param> /// <param name="type">The type of the presence stanza.</param> /// <param name="data">The content of the stanza.</param> /// <param name="id">The ID of the Presence stanza.</param> /// <param name="language">The language of the XML character data of /// the stanza.</param> public Presence(Jid to = null, Jid from = null, PresenceType type = PresenceType.Available, string id = null, CultureInfo language = null, params XmlElement[] data) : base(to, from, id, language, data) { Type = type; }
public override ISceneAgent AddNewClient(IClientAPI client, PresenceType type) { client.OnObjectName += RecordObjectNameCall; // FIXME return null; }
public PresenceBubble(long time, BubbleDirection direction, string address, bool party, Service service, PresenceType presence, PlatformType platform) : base(time, direction, service) { Presence = presence; Platform = platform; Address = address; Party = party; }
/// <summary> /// Sends a presence packet to the XMPP server. /// </summary> /// <param name="t">The type of presence.</param> /// <param name="status">Determines the status of the presence.</param> /// <param name="show">Shows the available, away, dnd and so on status.</param> /// <param name="priority">Prioritizes this connection. /// Higher number mean higher priority. 0 minumum, 127 max. /// -1 means this is a presence-only connection.</param> public void Presence(PresenceType t, string status, string show, int priority) { if (IsAuthenticated) { if ((priority < -128) || (priority > 127)) { throw new ArgumentException("Priority must be -128 to 127", "priority"); } Presence p = new Presence(Document); if (status != null) { p.Status = status; } if (t != PresenceType.available) { p.Type = t; } if (show != null) { p.Show = show; } p.Priority = priority.ToString(); if (OnBeforePresenceOut != null) { OnBeforePresenceOut(this, p); } Write(p); if (OnAfterPresenceOut != null) { OnAfterPresenceOut(this, p); } } else { throw new InvalidOperationException("Client must be authenticated before sending presence."); } }
public MucRoomMember(MucRoom room, Jid memberJid, Jid realJid, XmppStream stream, XmppHandlerContext context) { if (room == null) { throw new ArgumentNullException("room"); } if (memberJid == null) { throw new ArgumentNullException("memberJid"); } if (realJid == null) { throw new ArgumentNullException("realJid"); } if (context == null) { throw new ArgumentNullException("sender"); } this.room = room; this.stream = stream; this.context = context; this.sender = context.Sender; //Register disconect context.SessionManager.SessionUnavailable += SessionManager_SessionUnavailable; ParentService = room; RealJid = realJid; Jid = memberJid; Name = memberJid.Resource; presenceType = PresenceType.unavailable; //Create handler lock (Handlers) { Handlers.Add(new MucRoomMemberStanzaHandler(this)); Handlers.Add(new MucRoomMemberDiscoHandler(Jid, RealJid)); } DiscoInfo.AddIdentity(new DiscoIdentity("text", Name, "member")); DiscoInfo.AddFeature(new DiscoFeature(Core.protocol.Uri.DISCO_INFO)); DiscoInfo.AddFeature(new DiscoFeature(Core.protocol.Uri.DISCO_ITEMS)); }
private void GotPresence(object sender, Presence p) { PresenceType t = p.Type; if ((t != PresenceType.available) && (t != PresenceType.unavailable)) return; System.Diagnostics.Debug.Assert(p.From != null); if (p.From != null) { JID f = p.From; lock (this) { UserPresenceManager upm = (UserPresenceManager)m_items[f.Bare]; if (t == PresenceType.available) { if (upm == null) { upm = new UserPresenceManager(f.Bare); m_items[f.Bare] = upm; } upm.AddPresence(p, this); } else { if (upm != null) { upm.RemovePresence(p, this); if (upm.Count == 0) { m_items.Remove(f.Bare); } } } } } }
/// <summary> /// Event arguments for presence events. /// </summary> /// <param name="e">Copies attributes from this event arguments class.</param> protected PresenceEventArgs(PresenceEventArgs e) { this.statuses = e.statuses; this.presence = e.presence; this.content = e.content; this.errorElement = e.errorElement; this.errorType = e.errorType; this.stanzaError = e.stanzaError; this.errorText = e.errorText; this.client = e.client; this.component = e.component; this.type = e.type; this.availability = e.availability; this.from = e.from; this.fromBareJid = e.fromBareJid; this.to = e.to; this.id = e.id; this.status = e.status; this.errorCode = e.errorCode; this.priority = e.priority; this.ok = e.ok; }
/// <summary> /// Converts <see cref="PresenceType"/> to a string /// </summary> /// <param name="type">The presence to convert</param> /// <returns>The XMPP string equivalent</returns> public static string ConvertPresenceTypeToString(PresenceType type) { switch (type) { case PresenceType.Available: return("available"); case PresenceType.Error: return("error"); case PresenceType.Invisible: return("invis"); case PresenceType.Probe: return("probe"); case PresenceType.Subscribe: return("subscribe"); case PresenceType.Subscribed: return("subscribed"); case PresenceType.Unavailable: return("unavailabe"); case PresenceType.Unsubscribe: return("unsubscribe"); case PresenceType.Unsubscribed: return("unsubscribed"); case PresenceType.Visible: return("visible"); default: return(type.ToString("G").ToLower()); } }
public static byte GetState(ShowType show, PresenceType type) { switch (show) { case ShowType.NONE: switch (type) { case PresenceType.unavailable: return USER_OFFLINE; default: return USER_ONLINE; } case ShowType.chat: return USER_ONLINE; case ShowType.away: return USER_AWAY; case ShowType.dnd: case ShowType.xa: return USER_NOT_AVAILVABLE; default: return NO_STATE; } }
/////////////////////////////////////////////////////////////// // Set In-a-Call state public bool SetPresence(ObiUser usr, bool bTalking) { try { PresenceType pt = new PresenceType(); if (bTalking) { pt.CallState = UserCallState.Talking; } else { pt.CallState = UserCallState.Idle; } pt.ServiceState = UserServiceState.No_Change; pt.PresenceProfile = ""; m_PSI.SetUserPresence(m_PSI_Session, usr.UserId, pt); m_PL.Bcm_PresenceUpdated(usr); } catch (Exception e) { m_log.Log("Exception in BCM_Control::SetPresence: " + e); } return(false); }
public StatusEntry() { ModifyBg (StateType.Normal, Style.Background (StateType.Active)); BorderWidth = 0; customAvailableMessages = new SerializableDictionary<string,string> (); customBusyMessages = new SerializableDictionary<string,string> (); customAwayMessages = new SerializableDictionary<string,string> (); presence = null; potentialPresenceType = PresenceType.Offline; notebook = new Notebook (); notebook.ModifyBg (StateType.Normal, Style.Background (StateType.Active)); notebook.ShowTabs = false; notebook.ShowBorder = false; notebook.AppendPage (CreateViewWidget (), new Label ()); notebook.AppendPage (CreateEditWidget (), new Label()); notebook.Show (); Add (notebook); }
/// <summary> /// Gets a default translated string for status /// </summary> static public string GetStatusString(PresenceType type) { switch (type) { case PresenceType.Offline: return(Catalog.GetString("Offline")); case PresenceType.Available: return(Catalog.GetString("Available")); case PresenceType.Away: return(Catalog.GetString("Away")); case PresenceType.XA: return(Catalog.GetString("XA")); case PresenceType.Hidden: return(Catalog.GetString("Hidden")); case PresenceType.Busy: return(Catalog.GetString("Busy")); } return(String.Empty); }
public StatusEntry() { ModifyBg(StateType.Normal, Style.Background(StateType.Active)); BorderWidth = 0; customAvailableMessages = new SerializableDictionary <string, string> (); customBusyMessages = new SerializableDictionary <string, string> (); customAwayMessages = new SerializableDictionary <string, string> (); presence = null; potentialPresenceType = PresenceType.Offline; notebook = new Notebook(); notebook.ModifyBg(StateType.Normal, Style.Background(StateType.Active)); notebook.ShowTabs = false; notebook.ShowBorder = false; notebook.AppendPage(CreateViewWidget(), new Label()); notebook.AppendPage(CreateEditWidget(), new Label()); notebook.Show(); Add(notebook); }
public SubscriptionsEventArgs(Jid jid, PresenceType presenceType) { PresenceType = presenceType; Jid = jid; }
private void SwitchToEditMode(PresenceType type) { this.potentialPresenceType = type; SwitchToEditMode(); }
public StatusUpdatedEventArgs(LeagueStatus status, PresenceType presenceType, ShowType show) { Status = status; PresenceType = presenceType; Show = show; }
/// <summary> /// Initializes a new instance of the Presence class from the specified /// instance. /// </summary> /// <param name="presence">An instance of the Core.Presence class to /// initialize this instance with.</param> /// <exception cref="ArgumentNullException">The presence parameter is null.</exception> /// <exception cref="ArgumentException">The 'type' attribute of the /// specified presence stanza is invalid.</exception> public Presence(Core.Presence presence) { presence.ThrowIfNull("presence"); type = ParseType(presence.Data.GetAttribute("type")); element = presence.Data; }
private void ChangeOutboundPresence(State state, UserRosterItem itemSendingPresence, UserRosterItem itemRecivingPresence, PresenceType newType, out bool bRoute) { //Change state of sending presence! bRoute = false; if (newType == PresenceType.subscribed) { switch (state) { case State.None_PendingIn: bRoute = true; SetState(State.From, itemSendingPresence, itemRecivingPresence); break; case State.None_PendingInOut: bRoute = true; SetState(State.From_PendingOut, itemSendingPresence, itemRecivingPresence); break; case State.To_PendingIn: bRoute = true; SetState(State.Both, itemSendingPresence, itemRecivingPresence); break; } } if (newType == PresenceType.unsubscribed) { switch (state) { case State.None_PendingIn: bRoute = true; SetState(State.None, itemSendingPresence, itemRecivingPresence); break; case State.None_PendingInOut: bRoute = true; SetState(State.None_PendingOut, itemSendingPresence, itemRecivingPresence); break; case State.To_PendingIn: bRoute = true; SetState(State.To, itemSendingPresence, itemRecivingPresence); break; case State.From: bRoute = true; SetState(State.None, itemSendingPresence, itemRecivingPresence); break; case State.From_PendingOut: bRoute = true; SetState(State.None_PendingOut, itemSendingPresence, itemRecivingPresence); break; case State.Both: bRoute = true; SetState(State.To, itemSendingPresence, itemRecivingPresence); break; } } }
public static bool IsAvailable(PresenceType presence) { return presence == PresenceType.Online || presence == PresenceType.Active; }
/// <summary> /// Constructs a Presence Object with a specific message /// </summary> public Presence(PresenceType type, string message) { this.presenceType = type; this.message = message; this.time = 0; }
/// <summary> /// Constructs a Presence Object /// </summary> public Presence(PresenceType type) { this.presenceType = type; this.message = GetStatusString(type); this.time = 0; }
private static string GetPresenceType(PresenceType presenceType) { return(PresenceTypeMap[presenceType]); }
public Presence(string to, PresenceType type) : base(to, Element.ElementType.PRESENCE, (Element.ElementSubType) type) { }
public Presence(PresenceType type) : base(null, Element.ElementType.PRESENCE, (Element.ElementSubType) type) { }
public override ISceneAgent AddNewAgent(IClientAPI client, PresenceType type) { ScenePresence sp; bool vialogin; bool reallyNew = true; // Update the number of users attempting to login StatsReporter.UpdateUsersLoggingIn(true); // Validation occurs in LLUDPServer // // XXX: A race condition exists here where two simultaneous calls to AddNewAgent can interfere with // each other. In practice, this does not currently occur in the code. AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode); // We lock here on AgentCircuitData to prevent a race condition between the thread adding a new connection // and a simultaneous one that removes it (as can happen if the client is closed at a particular point // whilst connecting). // // It would be easier to lock across all NewUserConnection(), AddNewAgent() and // RemoveClient() calls for all agents, but this would allow a slow call (e.g. because of slow service // response in some module listening to AddNewAgent()) from holding up unrelated agent calls. // // In practice, the lock (this) in LLUDPServer.AddNewClient() currently lock across all // AddNewClient() operations (though not other ops). // In the future this can be relieved once locking per agent (not necessarily on AgentCircuitData) is improved. lock (aCircuit) { vialogin = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; CheckHeartbeat(); sp = GetScenePresence(client.AgentId); // XXX: Not sure how good it is to add a new client if a scene presence already exists. Possibly this // could occur if a viewer crashes and relogs before the old client is kicked out. But this could cause // other problems, and possibly the code calling AddNewAgent() should ensure that no client is already // connected. if (sp == null) { m_log.DebugFormat( "[SCENE]: Adding new child scene presence {0} {1} to scene {2} at pos {3}, tpflags: {4}", client.Name, client.AgentId, RegionInfo.RegionName, client.StartPos, ((TPFlags)aCircuit.teleportFlags).ToString()); m_clientManager.Add(client); SubscribeToClientEvents(client); sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type); sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags; /* done in completMovement InventoryFolderBase cof = InventoryService.GetFolderForType(client.AgentId, (AssetType)46); if (cof == null) sp.COF = UUID.Zero; else sp.COF = cof.ID; m_log.DebugFormat("[SCENE]: COF for {0} is {1}", client.AgentId, sp.COF); */ m_eventManager.TriggerOnNewPresence(sp); } else { // We must set this here so that TriggerOnNewClient and TriggerOnClientLogin can determine whether the // client is for a root or child agent. // XXX: This may be better set for a new client before that client is added to the client manager. // But need to know what happens in the case where a ScenePresence is already present (and if this // actually occurs). m_log.WarnFormat( "[SCENE]: Already found {0} scene presence for {1} in {2} when asked to add new scene presence", sp.IsChildAgent ? "child" : "root", sp.Name, RegionInfo.RegionName); reallyNew = false; } client.SceneAgent = sp; // This is currently also being done earlier in NewUserConnection for real users to see if this // resolves problems where HG agents are occasionally seen by others as "Unknown user" in chat and other // places. However, we still need to do it here for NPCs. CacheUserName(sp, aCircuit); if (reallyNew) EventManager.TriggerOnNewClient(client); if (vialogin) EventManager.TriggerOnClientLogin(client); } // User has logged into the scene so update the list of users logging // in StatsReporter.UpdateUsersLoggingIn(false); m_LastLogin = Util.EnvironmentTickCount(); return sp; }
private void cli_OnPresence(object sender, Presence pres) { PresenceType typ = pres.Type; switch (typ) { case PresenceType.available: case PresenceType.unavailable: case PresenceType.error: case PresenceType.probe: return; case PresenceType.subscribe: switch (m_autoAllow) { case AutoSubscriptionHanding.AllowAll: ReplyAllow(pres); return; case AutoSubscriptionHanding.DenyAll: ReplyDeny(pres); return; case AutoSubscriptionHanding.NONE: if (OnSubscription != null) { OnSubscription(this, this[pres.From], pres); } return; case AutoSubscriptionHanding.AllowIfSubscribed: Item ri = this[pres.From]; if (ri != null) { switch (ri.Subscription) { case Subscription.to: ReplyAllow(pres); return; case Subscription.from: case Subscription.both: // Almost an assert throw new InvalidOperationException("Server sent a presence subscribe for an already-subscribed contact"); case Subscription.none: if (ri.Ask == Ask.subscribe) { ReplyAllow(pres); return; } break; } } if (OnSubscription != null) { OnSubscription(this, ri, pres); } break; } break; case PresenceType.subscribed: // This is the new ack case. Presence sub_ack = new Presence(m_stream.Document); sub_ack.To = pres.From; sub_ack.Type = PresenceType.subscribe; Write(sub_ack); break; case PresenceType.unsubscribe: // ack. we'll likely get an unsubscribed soon, anyway. Presence un_ack = new Presence(m_stream.Document); un_ack.To = pres.From; un_ack.Type = PresenceType.unsubscribed; Write(un_ack); break; case PresenceType.unsubscribed: bool remove = true; if (OnUnsubscription != null) { OnUnsubscription(this, pres, ref remove); } if (remove) { Remove(pres.From); } break; } }
private void SwitchToEditMode(PresenceType type) { this.potentialPresenceType = type; SwitchToEditMode (); }
public static bool IsAvailable(PresenceType presence) { return(presence == PresenceType.Online || presence == PresenceType.Active); }
public ScenePresence( IClientAPI client, Scene world, AvatarAppearance appearance, PresenceType type) { AttachmentsSyncLock = new Object(); m_sendCourseLocationsMethod = SendCoarseLocationsDefault; Animator = new ScenePresenceAnimator(this); PresenceType = type; DrawDistance = world.DefaultDrawDistance; RegionHandle = world.RegionInfo.RegionHandle; ControllingClient = client; Firstname = ControllingClient.FirstName; Lastname = ControllingClient.LastName; m_name = String.Format("{0} {1}", Firstname, Lastname); m_scene = world; m_uuid = client.AgentId; LocalId = m_scene.AllocateLocalId(); UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid); if (account != null) m_userFlags = account.UserFlags; else m_userFlags = 0; if (account != null) UserLevel = account.UserLevel; IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); if (gm != null) Grouptitle = gm.GetGroupTitle(m_uuid); m_scriptEngines = m_scene.RequestModuleInterfaces<IScriptModule>(); AbsolutePosition = posLastSignificantMove = CameraPosition = m_lastCameraPosition = ControllingClient.StartPos; m_reprioritization_timer = new Timer(world.ReprioritizationInterval); m_reprioritization_timer.Elapsed += new ElapsedEventHandler(Reprioritize); m_reprioritization_timer.AutoReset = false; AdjustKnownSeeds(); // TODO: I think, this won't send anything, as we are still a child here... Animator.TrySetMovementAnimation("STAND"); // we created a new ScenePresence (a new child agent) in a fresh region. // Request info about all the (root) agents in this region // Note: This won't send data *to* other clients in that region (children don't send) // MIC: This gets called again in CompleteMovement // SendInitialFullUpdateToAllClients(); SendOtherAgentsAvatarDataToMe(); SendOtherAgentsAppearanceToMe(); RegisterToEvents(); SetDirectionVectors(); Appearance = appearance; }
private static string GetPresenceType(PresenceType presenceType) { return PresenceTypeMap[presenceType]; }
/// <summary> /// Add a new client and create a child agent for it. /// </summary> /// <param name="client"></param> /// <param name="type">The type of agent to add.</param> public override void AddNewClient(IClientAPI client, PresenceType type) { AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode); bool vialogin = false; if (aCircuit == null) // no good, didn't pass NewUserConnection successfully return; vialogin = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; CheckHeartbeat(); if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here { m_log.Debug("[SCENE]: Adding new agent " + client.Name + " to scene " + RegionInfo.RegionName); m_clientManager.Add(client); SubscribeToClientEvents(client); ScenePresence sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type); m_eventManager.TriggerOnNewPresence(sp); sp.TeleportFlags = (TeleportFlags)aCircuit.teleportFlags; // HERE!!! Do the initial attachments right here // first agent upon login is a root agent by design. // All other AddNewClient calls find aCircuit.child to be true if (aCircuit.child == false) { sp.IsChildAgent = false; Util.FireAndForget(delegate(object o) { AttachmentsModule.RezAttachments(sp); }); } } ScenePresence createdSp = GetScenePresence(client.AgentId); if (createdSp != null) { m_LastLogin = Util.EnvironmentTickCount(); // Cache the user's name CacheUserName(createdSp, aCircuit); EventManager.TriggerOnNewClient(client); if (vialogin) EventManager.TriggerOnClientLogin(client); } }
/// <summary> /// Sends a presence packet to the XMPP server. /// </summary> /// <param name="t">The type of presence.</param> /// <param name="status">Determines the status of the presence.</param> /// <param name="show">Shows the available, away, dnd and so on status.</param> /// <param name="priority">Prioritizes this connection. /// Higher number mean higher priority. 0 minumum, 127 max. /// -1 means this is a presence-only connection.</param> public void Presence(PresenceType t, string status, string show, int priority) { if (IsAuthenticated) { if ((priority < -128) || (priority > 127)) { throw new ArgumentException("Priority must be -128 to 127", "priority"); } Presence p = new Presence(Document); if (status != null) p.Status = status; if (t != PresenceType.available) { p.Type = t; } if (show != null) p.Show = show; p.Priority = priority.ToString(); if (OnBeforePresenceOut != null) OnBeforePresenceOut(this, p); Write(p); if (OnAfterPresenceOut != null) OnAfterPresenceOut(this, p); } else { throw new InvalidOperationException("Client must be authenticated before sending presence."); } }
public PresenceFilterAttribute(PresenceType allowed) { this.allowed = allowed; }
public void SetIdleState(IdleState idleState) { switch (idleState) { case IdleState.InUse: Type = PresenceType.available; Mode = PresenceMode.available; Priority = 2; break; case IdleState.Idle: Type = PresenceType.available; Mode = PresenceMode.away; Priority = 0; break; case IdleState.ExtendedIdle: Type = PresenceType.available; Mode = PresenceMode.xa; Priority = 0; break; } }
/// <summary> /// Initializes a new instance of the <see cref="Presence"/> class. /// </summary> /// <param name="type">The <see cref="PresenceType"/>.</param> public Presence(PresenceType type) : this() { Type = type; }
private void SwitchToViewMode() { potentialPresenceType = PresenceType.Offline; statusEntry.Text = string.Empty; notebook.Page = 0; }
public Presence(S22.Xmpp.Core.Presence presence) : base(null, null, null, null, new XmlElement[0]) { presence.ThrowIfNull <S22.Xmpp.Core.Presence>("presence"); this.type = this.ParseType(presence.Data.GetAttribute("type")); base.element = presence.Data; }
public Presence(Jid to = null, Jid from = null, PresenceType type = 0, string id = null, CultureInfo language = null, params XmlElement[] data) : base(to, from, id, language, data) { this.Type = type; }
protected internal ScenePresence CreateAndAddChildScenePresence( IClientAPI client, AvatarAppearance appearance, PresenceType type) { // ScenePresence always defaults to child agent ScenePresence presence = new ScenePresence(client, m_parentScene, appearance, type); Entities[presence.UUID] = presence; lock (m_presenceLock) { m_numChildAgents++; Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(m_scenePresenceMap); List<ScenePresence> newlist = new List<ScenePresence>(m_scenePresenceArray); if (!newmap.ContainsKey(presence.UUID)) { newmap.Add(presence.UUID, presence); newlist.Add(presence); } else { // Remember the old presence reference from the dictionary ScenePresence oldref = newmap[presence.UUID]; // Replace the presence reference in the dictionary with the new value newmap[presence.UUID] = presence; // Find the index in the list where the old ref was stored and update the reference newlist[newlist.IndexOf(oldref)] = presence; } // Swap out the dictionary and list with new references m_scenePresenceMap = newmap; m_scenePresenceArray = newlist; } return presence; }
private PresenceStanza(JId from, JId to, string id, PresenceType presenceType, PresenceAvailabilityStatus presenceAvailabilityStatus, string detailStatus) : base(from, to, id) { this.presenceType = presenceType; this.presenceAvailabilityStatus = presenceAvailabilityStatus; }
protected internal ScenePresence CreateAndAddChildScenePresence( IClientAPI client, AvatarAppearance appearance, PresenceType type) { ScenePresence newAvatar = null; // ScenePresence always defaults to child agent newAvatar = new ScenePresence(client, m_parentScene, appearance, type); AddScenePresence(newAvatar); return newAvatar; }
public PresenceConfiguration(int id, PresenceType presenceType) { ID = id; this.presenceType = presenceType; }
public ScenePresence( IClientAPI client, Scene world, AvatarAppearance appearance, PresenceType type) { m_scene = world; AttachmentsSyncLock = new Object(); AllowMovement = true; IsChildAgent = true; IsLoggingIn = false; m_sendCoarseLocationsMethod = SendCoarseLocationsDefault; Animator = new ScenePresenceAnimator(this); Overrides = new MovementAnimationOverrides(); PresenceType = type; DrawDistance = world.DefaultDrawDistance; RegionHandle = world.RegionInfo.RegionHandle; ControllingClient = client; Firstname = ControllingClient.FirstName; Lastname = ControllingClient.LastName; m_name = String.Format("{0} {1}", Firstname, Lastname); m_uuid = client.AgentId; LocalId = m_scene.AllocateLocalId(); LegacySitOffsets = m_scene.LegacySitOffsets; UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid); if (account != null) m_userFlags = account.UserFlags; else m_userFlags = 0; if (account != null) UserLevel = account.UserLevel; IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); if (gm != null) Grouptitle = gm.GetGroupTitle(m_uuid); m_scriptEngines = m_scene.RequestModuleInterfaces<IScriptModule>(); AbsolutePosition = posLastSignificantMove = CameraPosition = m_lastCameraPosition = ControllingClient.StartPos; m_reprioritization_timer = new Timer(world.ReprioritizationInterval); m_reprioritization_timer.Elapsed += new ElapsedEventHandler(Reprioritize); m_reprioritization_timer.AutoReset = false; AdjustKnownSeeds(); RegisterToEvents(); SetDirectionVectors(); Appearance = appearance; m_stateMachine = new ScenePresenceStateMachine(this); }
private PresenceEventArgs(XmppClient Client, XmppComponent Component, XmlElement Presence) { XmlElement E; int i; this.presence = Presence; this.client = Client; this.component = Component; this.from = XML.Attribute(Presence, "from"); this.to = XML.Attribute(Presence, "to"); this.id = XML.Attribute(Presence, "id"); this.ok = true; this.errorCode = 0; this.availability = Availability.Online; i = this.from.IndexOf('/'); if (i < 0) { this.fromBareJid = this.from; } else { this.fromBareJid = this.from.Substring(0, i); } switch (XML.Attribute(Presence, "type").ToLower()) { case "error": this.type = PresenceType.Error; break; case "probe": this.type = PresenceType.Probe; break; case "subscribe": this.type = PresenceType.Subscribe; break; case "subscribed": this.type = PresenceType.Subscribed; break; case "unavailable": this.type = PresenceType.Unavailable; this.availability = Availability.Offline; break; case "unsubscribe": this.type = PresenceType.Unsubscribe; break; case "unsubscribed": this.type = PresenceType.Unsubscribed; break; default: this.type = PresenceType.Available; break; } SortedDictionary <string, string> Statuses = new SortedDictionary <string, string>(); foreach (XmlNode N in Presence.ChildNodes) { E = N as XmlElement; if (E == null) { continue; } if (E.NamespaceURI == Presence.NamespaceURI) { switch (E.LocalName) { case "show": switch (E.InnerText.ToLower()) { case "away": this.availability = Availability.Away; break; case "chat": this.availability = Availability.Chat; break; case "dnd": this.availability = Availability.DoNotDisturb; break; case "xa": this.availability = Availability.ExtendedAway; break; default: this.availability = Availability.Online; break; } break; case "status": if (string.IsNullOrEmpty(this.status)) { this.status = N.InnerText; } string Language = XML.Attribute(E, "xml:lang"); Statuses[Language] = N.InnerText; break; case "priority": if (!sbyte.TryParse(N.InnerText, out this.priority)) { this.priority = 0; } break; case "error": this.errorElement = E; this.errorCode = XML.Attribute(E, "code", 0); this.ok = false; switch (XML.Attribute(E, "type")) { case "auth": this.errorType = ErrorType.Auth; break; case "cancel": this.errorType = ErrorType.Cancel; break; case "continue": this.errorType = ErrorType.Continue; break; case "modify": this.errorType = ErrorType.Modify; break; case "wait": this.errorType = ErrorType.Wait; break; default: this.errorType = ErrorType.Undefined; break; } this.stanzaError = XmppClient.GetStanzaExceptionObject(E); this.errorText = this.stanzaError.Message; break; } } else if (E.NamespaceURI == XmppClient.NamespaceEntityCapabilities && E.LocalName == "c") { this.entityCapabilityVersion = XML.Attribute(E, "ver"); this.entityCapabilityNode = XML.Attribute(E, "node"); this.entityCapabilityHashFunction = XML.Attribute(E, "hash"); this.hasEntityCapabilities = true; } else if (this.content == null) { this.content = E; } } this.statuses = new KeyValuePair <string, string> [Statuses.Count]; Statuses.CopyTo(this.statuses, 0); }
public TestCasePresence(string ecosystem, string project, string testCaseFullName, PresenceType presence) { this.ecosystem = ecosystem; this.project = project; this.testCaseFullName = testCaseFullName; this.presence = presence; }
private void ChangeInboundPresence(State state, UserRosterItem itemSendingPresence, UserRosterItem itemRecivingPresence, PresenceType newType, out bool bRoute, out bool bAutoReply) { bRoute = false; bAutoReply = false; //Inbound! change state of reciving item!!! if (newType == PresenceType.subscribe) { switch (state) { case State.None: SetState(State.None_PendingIn, itemSendingPresence, itemRecivingPresence); bRoute = true; break; case State.None_PendingOut: SetState(State.None_PendingInOut, itemSendingPresence, itemRecivingPresence); bRoute = true; break; case State.To: SetState(State.To_PendingIn, itemSendingPresence, itemRecivingPresence); bRoute = true; break; case State.From: case State.From_PendingOut: case State.Both: bAutoReply = true; break; } } if (newType == PresenceType.unsubscribe) { switch (state) { case State.None_PendingIn: bRoute = true; bAutoReply = true; SetState(State.None, itemSendingPresence, itemRecivingPresence); break; case State.None_PendingInOut: bRoute = true; bAutoReply = true; SetState(State.None_PendingOut, itemSendingPresence, itemRecivingPresence); break; case State.To_PendingIn: bRoute = true; bAutoReply = true; SetState(State.To, itemSendingPresence, itemRecivingPresence); break; case State.From: bRoute = true; bAutoReply = true; SetState(State.None, itemSendingPresence, itemRecivingPresence); break; case State.From_PendingOut: bRoute = true; bAutoReply = true; SetState(State.None_PendingOut, itemSendingPresence, itemRecivingPresence); break; case State.Both: bRoute = true; bAutoReply = true; SetState(State.To, itemSendingPresence, itemRecivingPresence); break; } } if (newType == PresenceType.subscribed) { switch (state) { case State.None_PendingOut: bRoute = true; SetState(State.To, itemSendingPresence, itemRecivingPresence); break; case State.None_PendingInOut: bRoute = true; SetState(State.To_PendingIn, itemSendingPresence, itemRecivingPresence); break; case State.From_PendingOut: bRoute = true; SetState(State.Both, itemSendingPresence, itemRecivingPresence); break; } } if (newType == PresenceType.unsubscribed) { switch (state) { case State.None_PendingOut: bRoute = true; SetState(State.None, itemSendingPresence, itemRecivingPresence); break; case State.None_PendingInOut: bRoute = true; SetState(State.None_PendingIn, itemSendingPresence, itemRecivingPresence); break; case State.To: bRoute = true; SetState(State.None, itemSendingPresence, itemRecivingPresence); break; case State.To_PendingIn: bRoute = true; SetState(State.None_PendingIn, itemSendingPresence, itemRecivingPresence); break; case State.From_PendingOut: bRoute = true; SetState(State.From, itemSendingPresence, itemRecivingPresence); break; case State.Both: bRoute = true; SetState(State.From, itemSendingPresence, itemRecivingPresence); break; } } }
public override ISceneAgent AddNewClient(IClientAPI client, PresenceType type) { // Validation occurs in LLUDPServer AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode); bool vialogin = false; // if (aCircuit == null) // no good, didn't pass NewUserConnection successfully // return; vialogin = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; CheckHeartbeat(); ScenePresence sp = GetScenePresence(client.AgentId); // XXX: Not sure how good it is to add a new client if a scene presence already exists. Possibly this // could occur if a viewer crashes and relogs before the old client is kicked out. But this could cause // other problems, and possible the code calling AddNewClient() should ensure that no client is already // connected. if (sp == null) { m_log.DebugFormat( "[SCENE]: Adding new child scene presence {0} to scene {1} at pos {2}", client.Name, RegionInfo.RegionName, client.StartPos); m_clientManager.Add(client); SubscribeToClientEvents(client); sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type); m_eventManager.TriggerOnNewPresence(sp); sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags; // The first agent upon login is a root agent by design. // For this agent we will have to rez the attachments. // All other AddNewClient calls find aCircuit.child to be true. if (aCircuit.child == false) { // We have to set SP to be a root agent here so that SP.MakeRootAgent() will later not try to // start the scripts again (since this is done in RezAttachments()). // XXX: This is convoluted. sp.IsChildAgent = false; if (AttachmentsModule != null) Util.FireAndForget(delegate(object o) { AttachmentsModule.RezAttachments(sp); }); } } else { m_log.WarnFormat( "[SCENE]: Already found {0} scene presence for {1} in {2} when asked to add new scene presence", sp.IsChildAgent ? "child" : "root", sp.Name, RegionInfo.RegionName); } m_LastLogin = Util.EnvironmentTickCount(); // Cache the user's name CacheUserName(sp, aCircuit); EventManager.TriggerOnNewClient(client); if (vialogin) EventManager.TriggerOnClientLogin(client); return sp; }
public Presence(PresenceType type, string from, string to) : base(_NAME, _XMLNS) { base.Type = GetPresenceType(type); From = from; To = to; }
public override void AddNewClient(IClientAPI client, PresenceType type) { client.OnObjectName += RecordObjectNameCall; }
public abstract ISceneAgent AddNewClient(IClientAPI client, PresenceType type);
private void cli_OnPresence(object sender, Presence pres) { PresenceType typ = pres.Type; switch (typ) { case PresenceType.available: case PresenceType.unavailable: case PresenceType.error: case PresenceType.probe: return; case PresenceType.subscribe: switch (m_autoAllow) { case AutoSubscriptionHanding.AllowAll: ReplyAllow(pres); return; case AutoSubscriptionHanding.DenyAll: ReplyDeny(pres); return; case AutoSubscriptionHanding.NONE: if (OnSubscription != null) { OnSubscription(this, this[pres.From], pres); } return; case AutoSubscriptionHanding.AllowIfSubscribed: Item ri = this[pres.From]; if (ri != null) { switch (ri.Subscription) { case Subscription.to: ReplyAllow(pres); return; case Subscription.from: case Subscription.both: // Almost an assert throw new InvalidOperationException("Server sent a presence subscribe for an already-subscribed contact"); case Subscription.none: if (ri.Ask == Ask.subscribe) { ReplyAllow(pres); return; } break; } } if (OnSubscription != null) { OnSubscription(this, ri, pres); } break; } break; case PresenceType.subscribed: // the contact has given us permission to see presence updates break; case PresenceType.unsubscribe: // the contact does not wish to see our presence updates anymore // that's fine, who cares? break; case PresenceType.unsubscribed: bool remove = true; if (OnUnsubscription != null) { OnUnsubscription(this, pres, ref remove); } if (remove) { Remove(pres.From); } // the contact has taken away our permission to see presence updates break; } }
public override ISceneAgent AddNewClient(IClientAPI client, PresenceType type) { ScenePresence sp; bool vialogin; // Validation occurs in LLUDPServer // // XXX: A race condition exists here where two simultaneous calls to AddNewClient can interfere with // each other. In practice, this does not currently occur in the code. AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode); // We lock here on AgentCircuitData to prevent a race condition between the thread adding a new connection // and a simultaneous one that removes it (as can happen if the client is closed at a particular point // whilst connecting). // // It would be easier to lock across all NewUserConnection(), AddNewClient() and // RemoveClient() calls for all agents, but this would allow a slow call (e.g. because of slow service // response in some module listening to AddNewClient()) from holding up unrelated agent calls. // // In practice, the lock (this) in LLUDPServer.AddNewClient() currently lock across all // AddNewClient() operations (though not other ops). // In the future this can be relieved once locking per agent (not necessarily on AgentCircuitData) is improved. lock (aCircuit) { vialogin = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; // CheckHeartbeat(); sp = GetScenePresence(client.AgentId); // XXX: Not sure how good it is to add a new client if a scene presence already exists. Possibly this // could occur if a viewer crashes and relogs before the old client is kicked out. But this could cause // other problems, and possible the code calling AddNewClient() should ensure that no client is already // connected. if (sp == null) { m_log.DebugFormat( "[SCENE]: Adding new child scene presence {0} {1} to scene {2} at pos {3}", client.Name, client.AgentId, RegionInfo.RegionName, client.StartPos); m_clientManager.Add(client); SubscribeToClientEvents(client); sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type); m_eventManager.TriggerOnNewPresence(sp); sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags; // The first agent upon login is a root agent by design. // For this agent we will have to rez the attachments. // All other AddNewClient calls find aCircuit.child to be true. if (aCircuit.child == false) { // We have to set SP to be a root agent here so that SP.MakeRootAgent() will later not try to // start the scripts again (since this is done in RezAttachments()). // XXX: This is convoluted. sp.IsChildAgent = false; if (AttachmentsModule != null) Util.FireAndForget(delegate(object o) { AttachmentsModule.RezAttachments(sp); }); } } else { m_log.WarnFormat( "[SCENE]: Already found {0} scene presence for {1} in {2} when asked to add new scene presence", sp.IsChildAgent ? "child" : "root", sp.Name, RegionInfo.RegionName); } // We must set this here so that TriggerOnNewClient and TriggerOnClientLogin can determine whether the // client is for a root or child agent. client.SceneAgent = sp; // Cache the user's name CacheUserName(sp, aCircuit); EventManager.TriggerOnNewClient(client); if (vialogin) EventManager.TriggerOnClientLogin(client); } m_LastLogin = Util.EnvironmentTickCount(); return sp; }
public ScenePresence( IClientAPI client, Scene world, AvatarAppearance appearance, PresenceType type) { m_scene = world; AttachmentsSyncLock = new Object(); AllowMovement = true; IsChildAgent = true; IsLoggingIn = false; m_sendCoarseLocationsMethod = SendCoarseLocationsDefault; Animator = new ScenePresenceAnimator(this); Overrides = new MovementAnimationOverrides(); PresenceType = type; DrawDistance = world.DefaultDrawDistance; RegionHandle = world.RegionInfo.RegionHandle; ControllingClient = client; Firstname = ControllingClient.FirstName; Lastname = ControllingClient.LastName; m_name = String.Format("{0} {1}", Firstname, Lastname); m_uuid = client.AgentId; LocalId = m_scene.AllocateLocalId(); LegacySitOffsets = m_scene.LegacySitOffsets; UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid); if (account != null) m_userFlags = account.UserFlags; else m_userFlags = 0; if (account != null) UserLevel = account.UserLevel; // IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); // if (gm != null) // Grouptitle = gm.GetGroupTitle(m_uuid); m_scriptEngines = m_scene.RequestModuleInterfaces<IScriptModule>(); AbsolutePosition = posLastMove = posLastSignificantMove = CameraPosition = m_reprioritizationLastPosition = ControllingClient.StartPos; m_reprioritizationLastDrawDistance = DrawDistance; // disable updates workjobs for now childUpdatesBusy = true; m_reprioritizationBusy = true; AdjustKnownSeeds(); RegisterToEvents(); SetDirectionVectors(); Appearance = appearance; m_stateMachine = new ScenePresenceStateMachine(this); HealRate = 0.5f; IConfig sconfig = m_scene.Config.Configs["EntityTransfer"]; if (sconfig != null) { string lpb = sconfig.GetString("LandingPointBehavior", "LandingPointBehavior_OS"); if (lpb == "LandingPointBehavior_SL") m_LandingPointBehavior = LandingPointBehavior.SL; } }