//发送聊天文字 public void SendChatData(string str) { if (BWFManager.isReady && BWFManager.Contains(str)) { str = BWFManager.ReplaceAll(str); } if (str.Length > ChatDataLenght) { GameSceneUIHandler.ShowLog("文字长度过长,请重新输入!"); } else if (str.Length == 0) { GameSceneUIHandler.ShowLog("输入信息不能为空!"); } else { var temp = Encoding.GetEncoding(936).GetBytes(str); //byte[] data = new byte[40]; //Array.Clear(data, 0, 40); var kernel = (GameScene)CServerItem.get().GetClientKernelSink(); if (kernel == null) { return; } //Buffer.BlockCopy(temp, 0, data, 0, temp.Length); kernel.SendChatData(temp); } chat = ""; }
////获取文本框中的文字 //public void GetChatData(string str) //{ // m_chatText = ""; // m_chatText = str; //} //发送聊天文字 public void SendChatData(string chatText) { if (BWFManager.isReady && BWFManager.Contains(chatText)) { chatText = BWFManager.ReplaceAll(chatText); } if (chatText.Length > LobbyChatDataLenght) { GameSceneUIHandler.ShowLog("文字长度过长,请重新输入!"); } else if (chatText.Length == 0) { GameSceneUIHandler.ShowLog("输入信息不能为空!"); } else { //var kernel = (GameScene)CServerItem.get().GetClientKernelSink(); //if (kernel == null) { return; } //Buffer.BlockCopy(temp, 0, data, 0, temp.Length); //kernel.SendChatData(data); CGPLobbyMission kGPLobbyMission = CGPLobbyMission.GetInstance(); if (kGPLobbyMission != null) { if (!kGPLobbyMission.isLobbyChatSystemSetted()) { kGPLobbyMission.setLobbyChatSystem(this); } kGPLobbyMission.SendChatData(chatText); } } //m_chatText = ""; }
public void Replace() { tested = true; Text.text = BWFManager.ReplaceAll(Text.text, BadwordManager | DomManager | CapsManager | PuncManager, Sources.ToArray()); badWords.Clear(); }
private void showTestDrive() { if (Util.Helper.isEditorMode) { if (BWFManager.isReady) { scrollPosTD = EditorGUILayout.BeginScrollView(scrollPosTD, false, false); { GUILayout.Label("Test-Drive", EditorStyles.boldLabel); inputText = EditorGUILayout.TextField(new GUIContent("Input Text", "Text to check."), inputText); EditorHelper.ReadOnlyTextField("Output Text", outputText); } EditorGUILayout.EndScrollView(); EditorHelper.SeparatorUI(); GUILayout.BeginHorizontal(); { if (GUILayout.Button(new GUIContent(" Contains", EditorHelper.Icon_Contains, "Contains any bad words?"))) { BWFManager.Load(); outputText = BWFManager.Contains(inputText).ToString(); } if (GUILayout.Button(new GUIContent(" Get", EditorHelper.Icon_Get, "Get all bad words."))) { BWFManager.Load(); outputText = string.Join(", ", BWFManager.GetAll(inputText).ToArray()); } if (GUILayout.Button(new GUIContent(" Replace", EditorHelper.Icon_Replace, "Check and replace all bad words."))) { BWFManager.Load(); outputText = BWFManager.ReplaceAll(inputText); } if (GUILayout.Button(new GUIContent(" Mark", EditorHelper.Icon_Mark, "Mark all bad words."))) { BWFManager.Load(); outputText = BWFManager.Mark(inputText, BWFManager.GetAll(inputText)); } } GUILayout.EndHorizontal(); } else { EditorHelper.BWFUnavailable(); } } else { EditorGUILayout.HelpBox("Disabled in Play-mode!", MessageType.Info); } }
public void SendMessageToChat() { string messageToSend = BWFManager.ReplaceAll(messageArea.text); if (messageToSend != "") { new SendTeamChatMessageRequest() .SetMessage(messageToSend) //Player data Team ID .SetTeamId(GameSparksPlayerData.playerTeam) //Player data Team Type .SetTeamType(teamType) .Send(SendMessageToChatCallback); } }
protected override void speedTest(Model.ManagerMask mask) { stopWatch.Reset(); stopWatch.Start(); for (int ii = 0; ii < Iterations; ii++) { BWFManager.ReplaceAll(createRandomString(TextStartLength + (TextGrowPerIteration * ii)), mask, TestSources); } stopWatch.Stop(); //Debug.Log(totalTime + ";" + totalTime/Iterations); Debug.Log("## " + mask + ": " + stopWatch.ElapsedMilliseconds + ";" + ((float)stopWatch.ElapsedMilliseconds / Iterations) + " ##"); }
protected override void sanityTest(Model.ManagerMask mask) { //null test // Debug.Log("MASK: " + mask); // // Debug.Log("REPLACE normal: '" + MultiManager.ReplaceAll(null, ManagerMask.All) + "'"); if (BWFManager.ReplaceAll(null, mask).Equals(string.Empty)) { if (Util.Config.DEBUG) { Debug.Log("Nullable test passed"); } } else { Debug.LogError("Nullable test failed"); failCounter++; } //empty test if (BWFManager.ReplaceAll(string.Empty, mask).Equals(string.Empty)) { if (Util.Config.DEBUG) { Debug.Log("Empty test passed"); } } else { Debug.LogError("Empty test failed"); failCounter++; } if ((mask & Model.ManagerMask.Domain) == Model.ManagerMask.Domain || (mask & Model.ManagerMask.BadWord) == Model.ManagerMask.BadWord || (mask & Model.ManagerMask.All) == Model.ManagerMask.All) { //wrong 'source' test if (BWFManager.ReplaceAll(scunthorpe, mask, "test").Equals(scunthorpe)) { if (Util.Config.DEBUG) { Debug.Log("Wrong 'source' test passed"); } } else { Debug.LogError("Wrong 'source' test failed"); failCounter++; } //null for 'source' test if (BWFManager.ReplaceAll(scunthorpe, mask, null).Equals(scunthorpe)) { if (Util.Config.DEBUG) { Debug.Log("Null for 'source' test passed"); } } else { Debug.LogError("Null for 'source' test failed"); failCounter++; } //Zero-length array for 'source' test if (BWFManager.ReplaceAll(scunthorpe, mask, new string[0]).Equals(scunthorpe)) { if (Util.Config.DEBUG) { Debug.Log("Zero-length array for 'source' test passed"); } } else { Debug.LogError("Zero-length array for 'source' test failed"); failCounter++; } } if ((mask & Model.ManagerMask.BadWord) == Model.ManagerMask.BadWord || (mask & Model.ManagerMask.All) == Model.ManagerMask.All) { //normal bad word match test if (BWFManager.ReplaceAll(badword, mask).Equals(new string(ReplaceChar, badword.Length))) { if (Util.Config.DEBUG) { Debug.Log("Normal bad word replace test passed"); } } else { Debug.LogError("Normal bad word replace test failed"); failCounter++; } //normal bad word non-match test if (BWFManager.ReplaceAll(scunthorpe, mask).Equals(scunthorpe)) { if (Util.Config.DEBUG) { Debug.Log("Normal bad word non-replace test passed"); } } else { Debug.LogError("Normal bad word non-replace word test failed"); failCounter++; } //bad word resource match test if (BWFManager.ReplaceAll(badword, mask, "english").Equals(new string(ReplaceChar, badword.Length))) { if (Util.Config.DEBUG) { Debug.Log("Bad word resource replace test passed"); } } else { Debug.LogError("Bad word resource replace failed"); failCounter++; } //bad word resource non-match test if (BWFManager.ReplaceAll(noBadword, mask, "english").Equals(noBadword)) { if (Util.Config.DEBUG) { Debug.Log("Bad word resource non-replace test passed"); } } else { Debug.LogError("Bad word resource non-replace word test failed"); failCounter++; } //arabic match test if (BWFManager.ReplaceAll(arabicBadword, mask).Equals(new string(ReplaceChar, arabicBadword.Length))) { if (Util.Config.DEBUG) { Debug.Log("Arabic bad word replace test passed"); } } else { Debug.LogError("Arabic bad word replace failed"); failCounter++; } //global match test if (BWFManager.ReplaceAll(globalBadword, mask).Equals(new string(ReplaceChar, globalBadword.Length))) { if (Util.Config.DEBUG) { Debug.Log("Global bad word replace test passed"); } } else { Debug.LogError("Global bad word replace failed"); failCounter++; } //name match test if (BWFManager.ReplaceAll(nameBadword, mask).Equals(new string(ReplaceChar, nameBadword.Length))) { if (Util.Config.DEBUG) { Debug.Log("Name replace test passed"); } } else { Debug.LogError("Name replace failed"); failCounter++; } //emoji match test if (BWFManager.ReplaceAll(emoji, mask).Equals(new string(ReplaceChar, emoji.Length))) { if (Util.Config.DEBUG) { Debug.Log("Emoji replace test passed"); } } else { Debug.LogError("Emoji replace failed"); failCounter++; } } if ((mask & Model.ManagerMask.Domain) == Model.ManagerMask.Domain || (mask & Model.ManagerMask.All) == Model.ManagerMask.All) { //domain match test if (BWFManager.ReplaceAll(domain, mask).Equals(new string(ReplaceChar, domain.Length))) { if (Util.Config.DEBUG) { Debug.Log("Domain replace test passed"); } } else { Debug.LogError("Domain replace failed"); failCounter++; } //email match test if (BWFManager.ReplaceAll(email, mask).Equals(new string(ReplaceChar, email.Length))) { if (Util.Config.DEBUG) { Debug.Log("Email replace test passed"); } } else { Debug.LogError("Email replace failed"); failCounter++; } //domain non-match test if (BWFManager.ReplaceAll(noDomain, mask).Equals(noDomain)) { if (Util.Config.DEBUG) { Debug.Log("Domain non-replace test passed"); } } else { Debug.LogError("Domain non-replace word test failed"); failCounter++; } } if ((mask & Model.ManagerMask.Capitalization) == Model.ManagerMask.Capitalization) { //capital match test string caps = new string('A', Crosstales.BWF.Manager.CapitalizationManager.CharacterNumber + 1); string noCaps = new string('A', Crosstales.BWF.Manager.CapitalizationManager.CharacterNumber); if (BWFManager.ReplaceAll(caps, mask).Equals(caps.ToLowerInvariant())) { if (Util.Config.DEBUG) { Debug.Log("Capital replace test passed"); } } else { Debug.LogError("Capital replace failed"); failCounter++; } //capital non-match test if (BWFManager.ReplaceAll(noCaps, mask).Equals(noCaps)) { if (Util.Config.DEBUG) { Debug.Log("Capital non-replace test passed"); } } else { Debug.LogError("Capital non-replace word test failed"); failCounter++; } } if ((mask & Model.ManagerMask.Punctuation) == Model.ManagerMask.Punctuation) { //punctuation match test string punc = new string('!', Crosstales.BWF.Manager.PunctuationManager.CharacterNumber + 1); string noPunc = new string('!', Crosstales.BWF.Manager.PunctuationManager.CharacterNumber); if (BWFManager.ReplaceAll(punc, mask).Equals(noPunc)) { if (Util.Config.DEBUG) { Debug.Log("Punctuation replace test passed"); } } else { Debug.LogError("Punctuation replace failed"); failCounter++; } //punctuation non-match test if (BWFManager.ReplaceAll(noPunc, mask).Equals(noPunc)) { if (Util.Config.DEBUG) { Debug.Log("Punctuation non-replace test passed"); } } else { Debug.LogError("Punctuation non-replace word test failed"); failCounter++; } } }
public override void OnInspectorGUI() { if (script.isActiveAndEnabled) { GUILayout.Label("Stats", EditorStyles.boldLabel); GUILayout.Label("Ready:\t" + (BWFManager.isReady ? "Yes" : "No")); EditorHelper.SeparatorUI(); GUILayout.Label("Test-Drive", EditorStyles.boldLabel); if (Util.Helper.isEditorMode) { inputText = EditorGUILayout.TextField(new GUIContent("Input Text", "Text to check."), inputText); EditorHelper.ReadOnlyTextField("Output Text", outputText); GUILayout.Space(8); GUILayout.BeginHorizontal(); if (GUILayout.Button(new GUIContent(" Contains", EditorHelper.Icon_Contains, "Contains any bad words?"))) { //Manager.BadWordManager.Load(); outputText = BWFManager.Contains(inputText).ToString(); GAApi.Event(typeof(BWFManagerEditor).Name, "Contains"); } if (GUILayout.Button(new GUIContent(" Get", EditorHelper.Icon_Get, "Get all bad words."))) { //Manager.BadWordManager.Load(); outputText = string.Join(", ", BWFManager.GetAll(inputText).ToArray()); GAApi.Event(typeof(BWFManagerEditor).Name, "Get"); } if (GUILayout.Button(new GUIContent(" Replace", EditorHelper.Icon_Replace, "Check and replace all bad words."))) { //Manager.BadWordManager.Load(); outputText = BWFManager.ReplaceAll(inputText); GAApi.Event(typeof(BWFManagerEditor).Name, "Replace"); } if (GUILayout.Button(new GUIContent(" Mark", EditorHelper.Icon_Mark, "Mark all bad words."))) { //Manager.BadWordManager.Load(); outputText = BWFManager.Mark(inputText, BWFManager.GetAll(inputText)); GAApi.Event(typeof(BWFManagerEditor).Name, "Mark"); } GUILayout.EndHorizontal(); } else { EditorGUILayout.HelpBox("Disabled in Play-mode!", MessageType.Info); } } else { EditorGUILayout.HelpBox("Script is disabled!", MessageType.Info); } }