public JSONObject(JSONObject copy) { if (copy != null) { tag = copy.tag; encoding = copy.encoding; type = copy.type; } }
// public void SelectiveBroadcast(string message, string tag, List<Chat> exclude = null) // { // if (string.IsNullOrEmpty(message)) // return; // // if (exclude == null) // exclude = new List<Chat>(); // // List<Chat> receivers = new List<Chat>(); // lock (managerLock) // { // Log("Enter selective broadcast lock", MyExtensions.Logging.LogLevel.Locks); // receivers = activeChatters.Except(exclude).ToList(); // receivers = receivers.Where(x => AllAcceptedTagsForUser(x.UID).Contains(tag)).ToList(); // Log("Exit selective broadcast lock", MyExtensions.Logging.LogLevel.Locks); // } // // Log("Just before broadast", MyExtensions.Logging.LogLevel.SuperDebug); // foreach (Chat chatter in receivers) // chatter.MySend(message); // Log("Just after broadcast", MyExtensions.Logging.LogLevel.SuperDebug); // } public void Broadcast(LanguageTagParameters parameters, JSONObject container, List<Chat> exclude = null) { if (exclude == null) exclude = new List<Chat>(); // List<Chat> receivers = new List<Chat>(); // lock (managerLock) // { // Log("Enter broadcast tag lock", MyExtensions.Logging.LogLevel.Locks); // receivers = activeChatters.Except(exclude).ToList(); // Log("Exit broadcast tag lock", MyExtensions.Logging.LogLevel.Locks); // } Log("Just before tag broadast", MyExtensions.Logging.LogLevel.SuperDebug); foreach (Chat chatter in ConnectedUsers().Select(x => (Chat)x).Except(exclude)) { parameters.UpdateUser(chatter.ThisUser); //Update the message to reflect user preferences chatter.MySend(parameters, container); //Send a tag message by filling the container with the tag parameters } Log("Just after tag broadcast", MyExtensions.Logging.LogLevel.SuperDebug); }
public void MySend(LanguageTagParameters parameters, JSONObject container) { string message = manager.ConvertTag(parameters); //string subtype = parameters.Tag.ToString().ToLower(); if (container is WarningJSONObject) { container = NewWarningFromTag(parameters); /* (WarningJSONObject)container; warning.message = message; warning.subtype = subtype;*/ } else if (container is SystemMessageJSONObject) { container = NewSystemMessageFromTag(parameters); /*((SystemMessageJSONObject)container).message = message; ((SystemMessageJSONObject)container).subtype = subtype;*/ } else { Log("Didn't get a proper container for a language tag. Using system message as default", LogLevel.Warning); ((SystemMessageJSONObject)container).message = message; } MySend(container.ToString()); }
public void MySend(LanguageTagParameters parameters, JSONObject container) { string message = manager.ConvertTag(parameters); if (container is WarningJSONObject) { ((WarningJSONObject)container).message = message; } else if (container is SystemMessageJSONObject) { ((SystemMessageJSONObject)container).message = message; } else { Log("Didn't get a proper container for a language tag. Using system message as default", LogLevel.Warning); ((SystemMessageJSONObject)container).message = message; } MySend(container.ToString()); }
public void Broadcast(LanguageTagParameters parameters, JSONObject container, List<Chat> exclude = null) { if (exclude == null) exclude = new List<Chat>(); Log("Just before tag broadast", MyExtensions.Logging.LogLevel.SuperDebug); foreach (Chat chatter in ConnectedUsers().Select(x => (Chat)x).Except(exclude)) { parameters.UpdateUser(chatter.ThisUser); //Update the message to reflect user preferences //Send a tag message by filling the container with the tag parameters if(!parameters.RawSendingUser.ShadowBanned || parameters.RawSendingUser.UID == chatter.ThisUser.UID) chatter.MySend(parameters, container); } Log("Just after tag broadcast", MyExtensions.Logging.LogLevel.SuperDebug); }