internal bool UnregisterNotification(TS3Models.Notifications notification) { if (registeredNotifications.Contains(notification)) { registeredNotifications.Remove(notification); return(true); } return(false); }
internal bool RegisterNotification(TS3Models.Notifications notification) { if (!registeredNotifications.Contains(notification)) { registeredNotifications.Add(notification); return(true); } return(false); }
/// <summary> /// Unregister client notification /// </summary> public TS3Models.Result ClientNotifyUnregister(int schandlerid, TS3Models.Notifications notification) { if (IsConnected()) { ts3Connection.WriteLine(string.Format("clientnotifyunregister schandlerid={0} event={1}", schandlerid, notification)); TS3Models.Result result = TS3Helper.ParseResult(ReadAll(), false); if (result != null && result.ErrorId == 0) { Notifier.UnregisterNotification(notification); } return(result); } return(null); }
private void ParseNotification(TS3Models.Notifications notification, TS3Models.Result result) { switch (notification) { #region Client case TS3Models.Notifications.notifytextmessage: if (OnTextMessage != null) { OnTextMessage(new TS3Models.TextMessage() { Result = result, TargetMode = (TS3Models.TextMessageTargetMode)Convert.ToInt32(result.GetFirstResult("targetmode")), Msg = result.GetFirstResult("msg"), Target = Convert.ToInt32(result.GetFirstResult("target")), Invoker = new TS3Models.Client() { ClId = Convert.ToInt32(result.GetFirstResult("invokerid")), ClientNickname = result.GetFirstResult("invokername"), ClientUniqueIdentifier = result.GetFirstResult("invokeruid"), } }); } break; case TS3Models.Notifications.notifyclientpoke: if (OnClientPoke != null) { OnClientPoke(new TS3Models.ClientPoke() { Result = result, Msg = result.GetFirstResult("msg"), Invoker = new TS3Models.Client() { ClId = Convert.ToInt32(result.GetFirstResult("invokerid")), ClientNickname = result.GetFirstResult("invokername"), ClientUniqueIdentifier = result.GetFirstResult("invokeruid"), } }); } break; case TS3Models.Notifications.notifycliententerview: if (OnClientEnterView != null) { OnClientEnterView(new TS3Models.ClientEnterView() { Result = result, CfId = Convert.ToInt32(result.GetFirstResult("cfid")), CtId = Convert.ToInt32(result.GetFirstResult("ctid")), Reason = (TS3Models.ReasonIdentifier)Convert.ToInt32(result.GetFirstResult("reasonid")), Client = new TS3Models.Client().FillWithResult(result) }); } break; case TS3Models.Notifications.notifyclientleftview: if (OnClientLeftView != null) { OnClientLeftView(new TS3Models.ClientLeftView() { Result = result, CfId = Convert.ToInt32(result.GetFirstResult("cfid")), CtId = Convert.ToInt32(result.GetFirstResult("ctid")), Reason = (TS3Models.ReasonIdentifier)Convert.ToInt32(result.GetFirstResult("reasonid")), Invoker = new TS3Models.Client() { ClId = Convert.ToInt32(result.GetFirstResult("invokerid")), ClientNickname = result.GetFirstResult("invokername"), ClientUniqueIdentifier = result.GetFirstResult("invokeruid"), }, ReasonMsg = result.GetFirstResult("reasonmsg"), BanTime = Convert.ToInt32(result.GetFirstResult("bantime")), ClId = Convert.ToInt32(result.GetFirstResult("clid")) }); } break; case TS3Models.Notifications.notifyclientmoved: if (OnClientMoved != null) { List <TS3Models.Client> clients = new List <TS3Models.Client>(); foreach (Dictionary <string, string> list in result.ResultsList) { string id = result.GetResultByList(list, "clid"); if (!string.IsNullOrEmpty(id)) { clients.Add(new TS3Models.Client() { ClId = Convert.ToInt32(id) }); } } OnClientMoved(new TS3Models.ClientMoved() { Result = result, Channel = new TS3Models.Channel() { CId = Convert.ToInt32(result.GetFirstResult("ctid")) }, Reason = (TS3Models.ReasonIdentifier)Convert.ToInt32(result.GetFirstResult("reasonid")), Invoker = new TS3Models.Client() { ClId = Convert.ToInt32(result.GetFirstResult("invokerid")), ClientNickname = result.GetFirstResult("invokername"), ClientUniqueIdentifier = result.GetFirstResult("invokeruid"), }, Clients = clients }); } break; #endregion #region Channel case TS3Models.Notifications.notifychannelmoved: if (OnChannelMoved != null) { OnChannelMoved(new TS3Models.ChannelMoved() { Result = result, Reason = (TS3Models.ReasonIdentifier)Convert.ToInt32(result.GetFirstResult("reasonid")), Invoker = new TS3Models.Client() { ClId = Convert.ToInt32(result.GetFirstResult("invokerid")), ClientNickname = result.GetFirstResult("invokername"), ClientUniqueIdentifier = result.GetFirstResult("invokeruid"), }, Channel = new TS3Models.Channel().FillWithResult(result) }); } break; case TS3Models.Notifications.notifychanneledited: if (OnChannelEdited != null) { OnChannelEdited(new TS3Models.ChannelEdited() { Result = result, Reason = (TS3Models.ReasonIdentifier)Convert.ToInt32(result.GetFirstResult("reasonid")), Invoker = new TS3Models.Client() { ClId = Convert.ToInt32(result.GetFirstResult("invokerid")), ClientNickname = result.GetFirstResult("invokername"), ClientUniqueIdentifier = result.GetFirstResult("invokeruid"), }, Channel = new TS3Models.Channel().FillWithResult(result) }); } break; case TS3Models.Notifications.notifychannelcreated: if (OnChannelCreated != null) { OnChannelCreated(new TS3Models.ChannelCreated() { Result = result, Invoker = new TS3Models.Client() { ClId = Convert.ToInt32(result.GetFirstResult("invokerid")), ClientNickname = result.GetFirstResult("invokername"), ClientUniqueIdentifier = result.GetFirstResult("invokeruid"), }, Channel = new TS3Models.Channel().FillWithResult(result) }); } break; case TS3Models.Notifications.notifychanneldeleted: if (OnChannelDeleted != null) { OnChannelDeleted(new TS3Models.ChannelDeleted() { Result = result, Invoker = new TS3Models.Client() { ClId = Convert.ToInt32(result.GetFirstResult("invokerid")), ClientNickname = result.GetFirstResult("invokername"), ClientUniqueIdentifier = result.GetFirstResult("invokeruid"), }, Channel = new TS3Models.Channel().FillWithResult(result) }); } break; #endregion #region Server case TS3Models.Notifications.notifyserveredited: if (OnServerEdited != null) { OnServerEdited(new TS3Models.ServerEdited() { Result = result, Reason = (TS3Models.ReasonIdentifier)Convert.ToInt32(result.GetFirstResult("reasonid")), Invoker = new TS3Models.Client() { ClId = Convert.ToInt32(result.GetFirstResult("invokerid")), ClientNickname = result.GetFirstResult("invokername"), ClientUniqueIdentifier = result.GetFirstResult("invokeruid"), }, VirtualServer = new TS3Models.VirtualServer().FillWithResult(result) }); } break; case TS3Models.Notifications.notifyservergrouplist: if (OnServerGroupList != null) { List <TS3Models.ServerGroup> serverGroups = new List <TS3Models.ServerGroup>(); foreach (Dictionary <string, string> res in result.ResultsList) { serverGroups.Add(new TS3Models.ServerGroup().FillWithResult(result, res)); } OnServerGroupList(serverGroups); } break; #endregion } }