/// <summary> /// 离开聊天室 /// </summary> public void LeftChat(string userID, bool keepAlive) { if (this.RoomID == null && this.Room != null) { this.RoomID = this.Room.RoomID; } RequestReleaseParty leftMessage = null; try { leftMessage = RequestReleaseParty.Create(this.RoomID); } catch (Exception ex) { ChatLog.GetInstance().LogException(ex); } if (leftMessage == null) { return; } leftMessage.UserId = userID; ChatParty party = this.Room.GetUser(userID); if (party != null) { try { if (keepAlive) { leftMessage.MessageText = MessageText.Create(string.Format("[{0}] 已经离开。", party.DisplayName)); } else { leftMessage.MessageText = MessageText.Create("亲,网络不给力,您与攻城狮失联了!"); } } catch (Exception ex) { ChatLog.GetInstance().LogException(ex); } if (party.UserType == UserType.Agent) { leftMessage.AfterAction = Genesyslab.Platform.WebMedia.Protocols.BasicChat.Action.CloseIfNoAgents; if (keepAlive) { leftMessage.AfterAction = Genesyslab.Platform.WebMedia.Protocols.BasicChat.Action.KeepAlive; } } } this.SendMessage(userID, leftMessage); }
public void Execute(string sessionId, string userId , Genesyslab.Platform.WebMedia.Protocols.BasicChat.Action afterAction) { try { RequestReleaseParty reqReleaseParty = RequestReleaseParty.Create( sessionId, userId, afterAction, null); BaseAction action = new ChatPartyReleaseAction(Protocol); action.Request = reqReleaseParty; base.CloneSubscription(ref action); action.Execute(); } catch (Exception ex) { ChatLog.GetInstance().LogException(ex); } }