/// <summary> /// Sends the current presence information to the server /// </summary> public void SendCurrentPresence(LoginState loginState) { if (m_currentPresence == null) { m_currentPresence = new AvailableRequest(); } m_currentPresence.Status = loginState.ToString(); SendCurrentPresence(m_currentPresence); }
//private void IncomingRosterCallback(IAsyncResult ar) //{ // RosterResponse roster = m_sessionMgr.EndSend(ar) as RosterResponse; // OnIncomingRoster(roster); //} /// <summary> /// Event received from the SessionManager when a RosterResponse is received. /// When a RosterReponse is received we need to update the tree /// Since we're creating new GUI objects, all of that work must /// be done on the main thread. We'll go ahead and build the collection /// of groups in this background thread and then marshall back over. /// </summary> /// <param name="incomingRosterPacket"></param> //private void OnIncomingRoster(RosterResponse incomingRosterPacket) //{ // //work performed in here should be done on the main GUI thread // //since it will be updating the treeview // m_mainWindow.Invoke(new Session.PacketReceivedDelegate(IncomingRosterThreadSafe), new object[] { incomingRosterPacket }); //} /// <summary> /// Updates the TreeView based on the Groups of RosterItems /// </summary> /// <param name="p"></param> //private void IncomingRosterThreadSafe(Packet p) //{ // RosterResponse IncomingRosterPacket = p as RosterResponse; // try // { // m_mainWindow.Cursor = System.Windows.Forms.Cursors.WaitCursor; // foreach (RosterItem rsItem in IncomingRosterPacket.Items) // { // string groupName = rsItem.Group.ToString(); // TreeNode groupNode = new TreeNode(groupName); // bool bAddGroup = true; // foreach (TreeNode node in m_mainWindow.tvContacts.Nodes) // { // if (node.Text.Equals(groupName, StringComparison.OrdinalIgnoreCase)) // { // groupNode = node; // bAddGroup = false; // break; // } // } // groupNode.Nodes.Add(rsItem.Name); // if (bAddGroup) // { // m_mainWindow.tvContacts.Nodes.Add(groupNode); // } // } // } // finally // { // m_mainWindow.Cursor = System.Windows.Forms.Cursors.Default; // } //} public void SendCurrentPresence(AvailableRequest availableRequest) { Packet packet; m_currentPresence = availableRequest; if (m_currentPresence == null || m_currentPresence.Status == "Offline") { packet = new UnavailableRequest(); m_sessionMgr.BeginSend(packet); } else { packet = (Packet) m_currentPresence.Clone(); m_sessionMgr.BeginSend(packet); } }
public void SendAvailableRequest() { m_currentPresence = new AvailableRequest(); m_currentPresence.EntityCapabilitiesVersion = CapabilityVersion; m_currentPresence.EntityCapabilitiesNode = CapabilityNode; m_currentPresence.EntityCapabilitiesExtensions = CapabilityExtension; m_currentPresence.Status = LoginState.Online.ToString(); m_sessionMgr.Send(m_currentPresence); }
private void UpdateSessionPresence() { AvailableRequest ar = new AvailableRequest(); ar.Status = CurrentPresenceTextBox.Text; switch (PresenceTypeComboBox.Text.ToLower()) { case "do not disturb": ar.Show = AvailableRequest.ShowValuesEnum.DoNotDisturb; break; case "away": ar.Show = AvailableRequest.ShowValuesEnum.Away; break; case "chat": ar.Show = AvailableRequest.ShowValuesEnum.Chat; break; case "extended away": ar.Show = AvailableRequest.ShowValuesEnum.ExtendedAway; break; case "normal": ar.Show = AvailableRequest.ShowValuesEnum.Normal; break; default: ar.Show = AvailableRequest.ShowValuesEnum.Normal; break; } _SessionManager.CurrentPresence = ar; }
public void SendUpdatedPresence(AvailableRequest p) { if (_rooms.Count == 0) return; AvailableRequest myPresence = WConvert.ToAvailableRequest(p.Clone()); foreach(ChatRoomTabPage chat in _rooms.Values) { myPresence.To = chat.Occupant; _sm.SendAndForget(myPresence); } }
private void HandleGCPresence( AvailableRequest p ) { if (! _users.Contains(p.From.ToString().ToLower()) ) { _users.Add(p.From.ToString().ToLower(), new RoomOccupant(p.From, _sm)); BindList(); } string presencemessage = string.Format("The user {0} is now {1}", p.From.Resource, p.Show.ToString()); AddMessageHistory(this.Room, presencemessage); }