public void SetField(string name, string value) { switch (name) { case "cgid": cgID = CommandDeserializer.DeserializeUInt64(value); break; case "name": cgName = CommandDeserializer.DeserializeString(value); break; case "type": type = CommandDeserializer.DeserializeEnum <PermissionGroupDatabaseType>(value); break; case "iconid": iconid = CommandDeserializer.DeserializeInt32(value); break; case "savedb": savedb = CommandDeserializer.DeserializeBool(value); break; case "sortid": sortid = CommandDeserializer.DeserializeUInt64(value); break; case "namemode": namemode = CommandDeserializer.DeserializeEnum <GroupNamingMode>(value); break; case "n_modifyp": n_modifyp = CommandDeserializer.DeserializeUInt64(value); break; case "n_member_addp": n_member_addp = CommandDeserializer.DeserializeUInt64(value); break; case "n_member_removep": n_member_removep = CommandDeserializer.DeserializeUInt64(value); break; } }
public LazyNotification?PushMessage(string message) { string notifyname; int splitindex = message.IndexOf(' '); if (splitindex < 0) { notifyname = message.TrimEnd(); } else { notifyname = message.Substring(0, splitindex); } var ntfyType = MessageHelper.GetNotificationType(notifyname); if (ntfyType == NotificationType.Unknown) { cmdLineBuffer = message; return(null); } var lineDataPart = splitindex < 0 ? "" : message.Substring(splitindex); // if it's not an error it is a notification if (ntfyType != NotificationType.Error) { var notification = CommandDeserializer.GenerateNotification(lineDataPart, ntfyType); var lazyNotification = new LazyNotification(notification, ntfyType); if (dependingBlocks[(int)ntfyType] != null) { foreach (var item in dependingBlocks[(int)ntfyType]) { if (!item.Closed) { item.SetNotification(lazyNotification); } } dependingBlocks[(int)ntfyType].Clear(); } return(lazyNotification); } var errorStatus = (CommandError)CommandDeserializer.GenerateSingleNotification(lineDataPart, NotificationType.Error); if (synchronQueue) { if (requestQueue.Count > 0) { var waitBlock = requestQueue.Dequeue(); waitBlock.SetAnswer(errorStatus, cmdLineBuffer); cmdLineBuffer = null; } else /* ??? */ } { }
public IEnumerable <T> WaitForMessage <T>() where T : IResponse, new() { answerWaiter.WaitOne(); if (commandError.Id != Ts3ErrorCode.ok) { throw new Ts3CommandException(commandError); } return(CommandDeserializer.GenerateResponse <T>(commandLine)); }
public void SetField(string name, string value) { switch (name) { case "cid": channelID = CommandDeserializer.DeserializeUInt64(value); break; case "pid": pid = CommandDeserializer.DeserializeUInt64(value); break; case "channel_order": channel_order = CommandDeserializer.DeserializeUInt64(value); break; case "channel_name": channel_name = CommandDeserializer.DeserializeString(value); break; case "channel_flag_are_subscribed": subscribed = CommandDeserializer.DeserializeBool(value); break; } }
public IEnumerable <T> WaitForMessage <T>() where T : IResponse, new() { if (isDisposed) { throw new ObjectDisposedException(nameof(WaitBlock)); } if (!answerWaiter.WaitOne(CommandTimeout)) { throw new Ts3CommandException(Util.TimeOutCommandError); } if (commandError.Id != Ts3ErrorCode.ok) { throw new Ts3CommandException(commandError); } return(CommandDeserializer.GenerateResponse <T>(commandLine)); }
public LazyNotification?PushMessage(string message) { string notifyname; int splitindex = message.IndexOf(' '); if (splitindex < 0) { notifyname = message.TrimEnd(); } else { notifyname = message.Substring(0, splitindex); } var ntfyType = MessageHelper.GetNotificationType(notifyname); if (ntfyType == NotificationType.Unknown) { cmdLineBuffer = message; return(null); } var lineDataPart = splitindex < 0 ? "" : message.Substring(splitindex); // if it's not an error it is a notification if (ntfyType != NotificationType.Error) { var notification = CommandDeserializer.GenerateNotification(lineDataPart, ntfyType); var lazyNotification = new LazyNotification(notification, ntfyType); var dependantList = dependingBlocks[(int)ntfyType]; if (dependantList != null) { lock (dependantBlockLock) { foreach (var item in dependantList) { if (!item.Closed) { item.SetNotification(lazyNotification); } if (item.DependsOn != null) { foreach (var otherDepType in item.DependsOn) { if (otherDepType == ntfyType) { continue; } dependingBlocks[(int)otherDepType]?.Remove(item); } } } dependantList.Clear(); } } return(lazyNotification); } var errorStatus = (CommandError)CommandDeserializer.GenerateSingleNotification(lineDataPart, NotificationType.Error); if (synchronQueue) { WaitBlock waitBlock; if (!requestQueue.IsEmpty && requestQueue.TryDequeue(out waitBlock)) { waitBlock.SetAnswer(errorStatus, cmdLineBuffer); cmdLineBuffer = null; } else /* ??? */ } { }