public void OnChatStateChange(ChatState state) { // use OnConnected() and OnDisconnected() // this method might become more useful in the future, when more complex states are being used. this.StateText.text = state.ToString(); }
//--------------------------------------------------------Constructor:----------------------------------------------------------------\\ #region --Constructors-- /// <summary> /// Basic Constructor /// </summary> /// <history> /// 09/11/2017 Created [Fabian Sauter] /// </history> public ChatStateMessage(XmlNode node) : base(node.Attributes["from"]?.Value, node.Attributes["to"]?.Value, node.Attributes["id"]?.Value) { if (XMLUtils.getChildNode(node, "error") != null) { STATE = ChatState.UNKNOWN; } else if (XMLUtils.getChildNode(node, "active", Consts.XML_XMLNS, Consts.XML_XEP_0085_NAMESPACE) != null) { STATE = ChatState.ACTIVE; } else if (XMLUtils.getChildNode(node, "composing", Consts.XML_XMLNS, Consts.XML_XEP_0085_NAMESPACE) != null) { STATE = ChatState.COMPOSING; } else if (XMLUtils.getChildNode(node, "paused", Consts.XML_XMLNS, Consts.XML_XEP_0085_NAMESPACE) != null) { STATE = ChatState.PAUSED; } else if (XMLUtils.getChildNode(node, "inactive", Consts.XML_XMLNS, Consts.XML_XEP_0085_NAMESPACE) != null) { STATE = ChatState.INACTIVE; } else if (XMLUtils.getChildNode(node, "gone", Consts.XML_XMLNS, Consts.XML_XEP_0085_NAMESPACE) != null) { STATE = ChatState.GONE; } else { STATE = ChatState.UNKNOWN; } }
public void TimeStamping_NoFittingTimes_DoesNotReturnFullTeam() { var state = new ChatState(); var now = DateTime.UtcNow; var aStart = now; var aEnd = now.AddHours(1); var bStart = now.AddHours(1); var bEnd = now.AddHours(3); var cStart = now.AddHours(3); // ---A-- // BBB--- // -CCCCC var signings = new[] { new Signing("A", true, false, aStart, aEnd), new Signing("B", true, false, bStart, bEnd), new Signing("C", true, false, cStart), }; foreach (var signing in signings) { state = state.AddSigning(signing); } state.TwosFull().ShouldBe(false); state.GetSuggestion().Count().ShouldBe(0); }
public void TimeStamping() { var state = new ChatState(); var now = DateTime.UtcNow; var aStart = now.AddHours(3); var aEnd = now.AddHours(4); var bStart = now; var bEnd = now.AddHours(3); var cStart = now.AddHours(1); // ---A-- // BBB--- // -CCCCC var signings = new[] { new Signing("A", true, false, aStart, aEnd), new Signing("B", true, false, bStart, bEnd), new Signing("C", true, false, cStart), }; foreach (var signing in signings) { state = state.AddSigning(signing); } state.GetTwos().SequenceEqual( ImmutableList.Create(signings[1], signings[2])); }
public override async Task <ParseResult> ParseAsync(ChatState chatState, Chat_ParseField chatParseField, ChatMessage message) { var preFlowName = chatParseField.GetProperty("preFlowName"); var preStepId = chatParseField.GetProperty("preStepId"); var postFlowName = chatParseField.GetProperty("postFlowName"); var postStepId = chatParseField.GetProperty("postStepId"); if (String.IsNullOrEmpty(preFlowName) || String.IsNullOrEmpty(preStepId) || String.IsNullOrEmpty(postFlowName) || String.IsNullOrEmpty(postStepId)) { throw new ApplicationException("Parse: Missing rule data for IntentGateway Parser."); } message.Classifications = await ClassifyText(message.CorrectedUserInput, preFlowName, preStepId, postFlowName, postStepId, chatState.SessionData.IsSmsChannel); chatState.UpdateLastClassification(message.Classifications); if (!message.Classifications.IsSuccessful) { return(ParseResult.Failed); } // We don't want common chat intent's here. var intent = chatState.LastClassification.GetBestResult().Intent; if (intent != null && intent.StartsWith("commonchat-")) { return(ParseResult.Failed); } return(ParseResult.CreateSuccess(message.Classifications.GetBestResult().Result)); }
public void OnChatStateChange(ChatState state) { // use OnConnected() and OnDisconnected() // this method might become more useful in the future, when more complex states are being used. Debug.Log("OnChatStateChange!"); }
public override Task <ParseResult> ParseAsync(ChatState state, Chat_ParseField chatParseField, ChatMessage message) { var tokens = TextClassificationService.Tokenize(message.UserInput); // HTC One and iPhone match words quite easily var cleanedTokens = (from t in tokens where t != "phone" && t != "phones" && t != "phone's" && t != "the" && t != "tone" select t.ToLower()).ToArray(); (string matchedText, int matchedIndex, float ratio) = MatchService.FindMatch(cleanedTokens, 1, 4, deviceCatalog.MatchCharacters); var device = deviceCatalog.MakeModelList[matchedIndex]; var deviceMatch = new DeviceMatchResult { Id = device.Id, Make = device.Make, Model = device.Model, DisplayName = device.DisplayName, IsUncommon = device.IsUncommon, Ratio = ratio }; double minConfidence = ChatConfiguration.MinimumDeviceConfidence; if (device.IsUncommon) { minConfidence = ChatConfiguration.MinimumUncommonDeviceConfidence; } if (deviceMatch.Ratio > minConfidence) { return(Task.FromResult(ParseResult.CreateSuccess(deviceMatch))); } return(Task.FromResult(ParseResult.Failed)); }
void Start() { uiName = GameObject.FindGameObjectWithTag("uiName").GetComponent <Text>(); uiChat = GameObject.FindGameObjectWithTag("uiChat").GetComponent <Text>(); dialogueBox = GameObject.FindGameObjectWithTag("uiBox").GetComponent <Image>(); currentState = ChatState.Hidden; }
public override void UpdateState(ChatState state, ChatFlowStep flowStep, Chat_ParseField chatParseField, ParseResult result) { if (result.Success) { string[] names = result.Answer as string[]; var variables = GetChatVariables(state, flowStep, chatParseField.VarScope); // Set subvariables for first and last name if (names.Length > 0) { variables[$"{chatParseField.FieldName}_First"] = Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(names[0]); CheckIfAnswerHasPII(state, PIIType, names[0], PIIMask); } if (names.Length > 1) { variables[$"{chatParseField.FieldName}_Last"] = Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(names.Last()); CheckIfAnswerHasPII(state, PIIType, names[1], PIIMask); } // TODO: Use parse dependencies to join them properly. They will be marked as "compound". variables[chatParseField.FieldName] = String.Join(" ", names); } }
public override Task <ParseResult> ParseAsync(ChatState state, Chat_ParseField chatParseField, ChatMessage message) { string text = GetTextSource(chatParseField, message); // Shortcut for common case where flow tries to take all user input. // .* regex means all characters EXCEPT newlines. But the flow wants all including newlines // so running regex to collect all data doesn't make sense. So we just set the variable to everything. if (chatParseField.RuleData == ".*") { return(Task.FromResult(ParseResult.CreateSuccess(text))); } string regex = chatParseField?.GetProperty("Regex") ?? chatParseField.RuleData; try { var match = Regex.Match(text, regex, RegexOptions.IgnoreCase, ChatConfiguration.RegexTimeout); if (match.Success) { if (String.IsNullOrEmpty(chatParseField.Answer)) { return(Task.FromResult(ParseResult.CreateSuccess(match.Value))); } return(Task.FromResult(ParseResult.CreateSuccess(chatParseField.Answer))); } } catch (RegexMatchTimeoutException) { logger.ErrorFormat("Regex timed out. {0}", regex); } return(Task.FromResult(ParseResult.Failed)); }
public void OnChatStateChange(ChatState state) { if (debug) { Debug.Log("PunAndChatConnection: OnChatStateChange() was called by Chat. ChatState:" + state); } }
private void storeChatState(ChatState state) { switch (state) { case ChatState.ACTIVE: Chat.chatState = "Active"; break; case ChatState.COMPOSING: Chat.chatState = "Typing..."; break; case ChatState.PAUSED: Chat.chatState = "Paused"; break; case ChatState.INACTIVE: Chat.chatState = "Inactive"; break; case ChatState.GONE: Chat.chatState = "Gone"; break; default: Chat.chatState = ""; break; } chatState_tblck.Text = Chat.chatState; }
public override Task <ParseResult> ParseAsync(ChatState state, Chat_ParseField chatParseField, ChatMessage message) { var matches = Regex.Matches(message.UserInput, @"\d+") .Cast <Match>() .Select(m => m.Value) .ToArray(); if (matches.Length == 0) { return(Task.FromResult(ParseResult.Failed)); } var setting = chatParseField?.GetProperty("AllowedValues"); if (String.IsNullOrEmpty(setting)) { return(Task.FromResult(ParseResult.CreateSuccess(int.Parse(matches[0])))); } var allowedValues = setting.Split(',', ' '); var foundValue = allowedValues.Where(b => matches.Any(a => b.Contains(a))).FirstOrDefault(); if (foundValue == null) { return(Task.FromResult(ParseResult.Failed)); } return(Task.FromResult(ParseResult.CreateSuccess(int.Parse(foundValue)))); }
public void SendPlayerEmoji(Emoji emoji) { if (!CanSendPlayerEmoji) { return; } Emoji reactionEmoji; bool acceptedEmoji = Pizza.Flavors.Contains(emoji.Flavor); if (acceptedEmoji) { float newHotness = currentHotness + Pizza.Difficulty.HotnessBonus; currentHotness = Mathf.Min(1, newHotness); reactionEmoji = new Emoji(EmojiData.EmojisByCategory[EmojiCategory.GoodReaction].GetRandom()); } else { currentTime -= Pizza.Difficulty.TimePenalty; float newHotness = currentHotness - Pizza.Difficulty.HotnessPenalty; currentHotness = Mathf.Max(0, newHotness); reactionEmoji = new Emoji(EmojiData.EmojisByCategory[EmojiCategory.BadReaction].GetRandom()); } OnPizzaSendsReaction?.Invoke(reactionEmoji); state = ChatState.WaitingForPizzaEmoji; }
private void SendPizzaEmoji() { Emoji emoji = Pizza.GetRandomEmoji(); OnPizzaSendsEmoji?.Invoke(emoji); state = ChatState.WaitingForPlayerEmoji; }
public override async Task <ParseResult> ParseAsync(ChatState chatState, Chat_ParseField chatParseField, ChatMessage message) { int timezoneOffset = chatState.GetUserTimeZoneOffset(); if (message.LuisDateOutput == null) { message.LuisDateOutput = await luisService.Parse(message.UserInput, timezoneOffset); } var assumeFuture = false; if (bool.TryParse(chatParseField?.GetProperty("AssumeFuture"), out bool test)) { assumeFuture = test; } var results = ExtractDateResults(chatState, message.LuisDateOutput, assumeFuture); if ((results == null) || (results.Length == 0)) { logger.InfoFormat("Parse: luis date parser got nothing. - {0}", (message.LuisDateOutput != null) ? JsonConvert.SerializeObject(message.LuisDateOutput) : "null"); return(ParseResult.Failed); } if (version == 1) { return(ProcessAsV1Date(message, timezoneOffset, results)); } return(ParseResult.CreateSuccess(results)); }
/// <summary> /// Метод получения текущего состояния чата по ChatId /// </summary> /// <param name="chatId"></param> /// <returns></returns> public static State GetCurrentUserState(long chatId) { if (InitStates.BotStates?.Count == 0) { return(null); } using (BotDbContext db = new BotDbContext(HelperDataBase.DB_OPTIONS)) { //Выбираем состояние чата. ChatState chatState = (from state in db.ChatState where state.ChatId == chatId select state).FirstOrDefault(); string stateString = chatState.State; //Если состояние чата равно null if (string.IsNullOrEmpty(stateString?.Trim(' ')) == true) { //То записать в пустую ячейку состояния имя первого состояния. //ToDo Пока берем просто первый элемент из состояний, но нужно самому определять первый элемент. stateString = InitStates.BotStates.FirstOrDefault().Name; //ToDo изменить состояние(установить первое состояние, отправить приветствие, отправить клавиатуру через метод ChangeCurrentStateAndMakeHop //Изменить состояние в базе данных и сохранить изменения ChangeCurrentChatState(chatId, HopType.RootLevelHope, stateString); //chatState.State = stateString; //db.SaveChanges(); } //Найти в общем пуле состояний состояние с таким же именем. StateController stateCtrl = new StateController(stateString); return(InitStates.GetStateByName(stateCtrl.GetCurrentStateName())); } }
private void onOwnTimeout(ThreadPoolTimer timer) { if (timer is null || disposed) { return; } ChatState oldState = state; if (state == ChatState.COMPOSING) { // Send composing while we are typing every 30 seconds: double secSinceLastKeyDown = (DateTime.Now - lasKeyDown).TotalSeconds; if (secSinceLastKeyDown < 28) { SendUpdatedState(ChatState.COMPOSING); StartOwnTimer(TimeSpan.FromSeconds(30 - secSinceLastKeyDown)); } SetState(ChatState.PAUSED); } else if (CHAT.chatState == ChatState.ACTIVE || CHAT.chatState == ChatState.PAUSED) { SetState(ChatState.INACTIVE); } if (oldState != CHAT.chatState) { Logger.Debug($"Automated update of the own chat state from {oldState} to {CHAT.chatState} for chat '{CHAT.bareJid}'."); } }
public override async Task <ParseResult> ParseAsync(ChatState state, Chat_ParseField chatParseField, ChatMessage message) { string agentName = state.GlobalAnswers.GetFieldAnswer <string>(ChatStandardField.AgentName); (var names, var tokens) = await GetNamesAndTokens(message.UserInput, agentName); if (tokens == null) { logger.Error("Network: Failed to call text parser service."); return(ParseResult.Failed); } // If we didnt detect any names, and the user entered only 2 or 3 words (possible names), // and no look behind (to cut down on false positives), we retry with "My name is " prepended // since the NLP is better at picking up names in a sentence. if ((names.Count == 0) && (tokens.Count <= 3) && (!chatParseField.CheckPreviousMessages)) { (names, tokens) = await GetNamesAndTokens("My name is " + message.UserInput, agentName); } names.AddRange(GetUndetectedNames(message.UserInput)); // Add our test name if detected if (message.UserInput.ToUpper().Contains(TestName.ToUpper())) { names.AddRange(TestName.Split(' ')); } if (names.Count > 0) { return(ParseResult.CreateSuccess(names.Distinct().ToArray())); } return(ParseResult.Failed); }
protected virtual void CheckIfAnswerHasPII(ChatState state, PIIType piiType, string answer, string mask) { if ((piiType != PIIType.None) && !String.IsNullOrEmpty(answer)) { state.AddPIIText(piiType, answer, mask); } }
private static async Task EmptyStateMessageHandlerAsync(string message, ChatState chatState) { switch (message) { case var m when m.ToLower().StartsWith("/infa"): await ChatStateOperations.UpdateChatStateAsync(chatState, State.InfaState); await Bot.SendTextMessageAsync(chatState.ChatId, "Какую инфу ты хочешь измерить?"); break; case var m when m.ToLower().StartsWith("/when"): await ChatStateOperations.UpdateChatStateAsync(chatState, State.WhenState); await Bot.SendTextMessageAsync(chatState.ChatId, "Когда ...?"); break; case var m1 when m1.ToLower().StartsWith("/start"): case var m2 when m2.ToLower().StartsWith("/help"): await Bot.SendTextMessageAsync(chatState.ChatId, "Какой вопрос тебя интересует?\n/Infa - инфаметр\n/When - датаметр"); break; default: await Bot.SendRandomAnswer(chatState.ChatId); break; } }
public void OnChatStateChange(ChatState state) { // use OnConnected() and OnDisconnected() // this method might become more useful in the future, when more complex states are being used. Debug.Log(state.ToString()); ReportToChannel("Server: " + state.ToString()); }
public ChatWindow() { InitializeComponent(); chatState = new ChatState(); eventQueue = new UIActionQueue(Dispatcher); }
protected virtual bool Initialize(string channel) { if (m_ChatInitialized) { return(false); } ErrorCode ret = m_Chat.Initialize(channel); if (Error.Failed(ret)) { string err = Error.GetString(ret); ReportError(string.Format("Error initializing chat: {0}", err)); FireDisconnected(); return(false); } else { m_Chat.ChatCallbacks = this; m_ChatInitialized = true; m_ChatState = ChatState.Initialized; return(true); } }
public void OnChatStateChange(ChatState state) { // use OnConnected() and OnDisconnected() // this method might become more useful in the future, when more complex states are being used. Debug.Log("Local Client State:\t" + state.ToString()); }
private string FilterUserInfo(ChatState chatState, string text, bool mask, bool allPII) { if (String.IsNullOrWhiteSpace(text)) { return(text); } var replaceText = new StringBuilder(text); if (allPII) { // Clean all phone numbers RegexReplace(replaceText, PhoneNumberParser.PhoneNumberRegex, mask ? "<PHONE>" : String.Empty); // Clean all email address RegexReplace(replaceText, EmailParser.PartialEmailRegex, mask ? "<EMAIL>" : String.Empty); } if (chatState?.PIIAnswers.Count > 0) { foreach ((var piiType, var piiText, var piiMask) in chatState.PIIAnswers) { if (allPII || (piiType == PIIType.High)) { StringReplace(replaceText, piiText, mask ? "<" + piiMask + ">" : String.Empty); } } } return(replaceText.ToString()); }
/// <summary> /// Callback method. Called whenever your connection status changes /// </summary> /// <param name="state">ChatState type, the current connection state</param> public virtual void OnChatStateChange(ChatState state) { if (debugging == true) { Debug.Log("Chat state changed: " + state); } }
public async Task ReceiveAsync(Message message, CancellationToken cancellationToken) { var chatState = new ChatState { State = ChatStateEvent.Composing }; await _sender.SendMessageAsync(chatState, message.From, cancellationToken); }
static int IntToEnum(IntPtr L) { int arg0 = (int)LuaDLL.lua_tonumber(L, 1); ChatState o = (ChatState)arg0; ToLua.Push(L, o); return(1); }
void UpdateLeave() { m_transport.Disconnect(); m_message.Clear(); m_state = ChatState.HOST_TYPE_SELECT; }
private void OnAcceptCallback(IAsyncResult ar) { syncEvent.Set(); Socket socket = (Socket) ar.AsyncState; Socket handler = socket.EndAccept(ar); ChatState state = new ChatState(); state.Socket = handler; handler.BeginReceive(state.Buffer, 0, ChatState.BufferSize, 0, new AsyncCallback(OnRecieveCallback), state); }
public static bool Maximize(bool force = false) { if (CurrentState == ChatState.Maximized && !force) return false; System.Drawing.Rectangle rect = CoreManager.Current.Actions.UIElementRegion(Decal.Adapter.Wrappers.UIElementType.Chat); PostMessageTools.SendMouseClick(rect.X + 459, rect.Y + 11); CurrentState = ChatState.Maximized; return true; }
public bool ChangeUserStatus(ChatState status, int userId) { bool flag = false; using (StatusRepository statusRepo = new StatusRepository(new ChatDBDataContext())) { tbl_ChatUserStatus statusRec = statusRepo.Get(userId.ToString()); statusRec.Status = (int)status; statusRepo.Save(); if (statusRepo.Get(userId.ToString()).Status.Equals((int)status)) flag = true; } return flag; }
public void RegisterStatus(ChatState status, int loginId) { using (StatusRepository statusRepo = new StatusRepository(new ChatDBDataContext())) { statusRepo.Create(new tbl_ChatUserStatus() { Status = (int)status, UserID = loginId }); statusRepo.Save(); } }
internal virtual void SetChatState(ChatState state) { if (state == m_ChatState) { return; } m_ChatState = state; try { if (ChatStateChanged != null) { this.ChatStateChanged(state); } } catch (Exception x) { ReportError(x.ToString()); } }
void ErrorGUI() { float sx = 800.0f; float sy = 600.0f; float px = sx * 0.5f - 150.0f; float py = sy * 0.5f; if (GUI.Button(new Rect(px, py, 300, 80), "접속에 실패했습니다.\n\n버튼을 누르세요.")) { m_state = ChatState.HOST_TYPE_SELECT; } }
void ChattingGUI() { Rect commentRect = new Rect(220, 450, 300, 30); m_sendComment = GUI.TextField(commentRect, m_sendComment, 15); bool isSent = GUI.Button(new Rect (530, 450, 100, 30), "말하기"); if (Event.current.isKey && Event.current.keyCode == KeyCode.Return) { if (m_sendComment == m_prevComment) { isSent = true; m_prevComment = ""; } else { m_prevComment = m_sendComment; } } if (isSent == true) { string message = "[" + DateTime.Now.ToString("HH:mm:ss") + "] " + m_sendComment; byte[] buffer = System.Text.Encoding.UTF8.GetBytes(message); m_transport.Send(buffer, buffer.Length); AddMessage(ref m_message[(m_isServer == true)? 0 : 1], message); m_sendComment = ""; } if (GUI.Button (new Rect (700, 560, 80, 30), "나가기")) { m_state = ChatState.LEAVE; } // 두부장수(서버 측)이 메시지 표시. if (m_transport.IsServer() || m_transport.IsServer() == false && m_transport.IsConnected()) { DispBalloon(ref m_message[0], new Vector2(200.0f, 200.0f), new Vector2(340.0f, 360.0f), Color.cyan, true); GUI.DrawTexture(new Rect(50.0f, 370.0f, 145.0f, 200.0f), this.texture_tofu); } if (m_transport.IsServer() == false || m_transport.IsServer() && m_transport.IsConnected()) { // 콩장수의(클라이언트 측) 메시지 표시. DispBalloon(ref m_message[1], new Vector2(600.0f, 200.0f), new Vector2(340.0f, 360.0f), Color.green, false); GUI.DrawTexture(new Rect(600.0f, 370.0f, 145.0f, 200.0f), this.texture_daizu); } }
void SelectHostTypeGUI() { float sx = 800.0f; float sy = 600.0f; float px = sx * 0.5f - 100.0f; float py = sy * 0.75f; if (GUI.Button(new Rect(px, py, 200, 30), "채팅방 만들기")) { m_transport.StartServer(m_port, 1); m_state = ChatState.CHATTING; m_isServer = true; } Rect labelRect = new Rect(px, py + 80, 200, 30); GUIStyle style = new GUIStyle(); style.fontStyle = FontStyle.Bold; style.normal.textColor = Color.white; GUI.Label(labelRect, "상대방 IP 주소", style); labelRect.y -= 2; style.fontStyle = FontStyle.Normal; style.normal.textColor = Color.black; GUI.Label(labelRect, "상대방 IP 주소", style); Rect textRect = new Rect(px, py + 100, 200, 30); m_hostAddress = GUI.TextField(textRect, m_hostAddress); if (GUI.Button(new Rect(px, py + 40, 200, 30), "채팅방 들어가기")) { bool ret = m_transport.Connect(m_hostAddress, m_port); if (ret) { m_state = ChatState.CHATTING; } else { m_state = ChatState.ERROR; } } }
protected virtual bool Initialize(string channel) { if (m_ChatInitialized) { return false; } ErrorCode ret = m_Chat.Initialize(channel); if (Error.Failed(ret)) { string err = Error.GetString(ret); ReportError(string.Format("Error initializing chat: {0}", err)); FireDisconnected(); return false; } else { m_Chat.ChatCallbacks = this; m_ChatInitialized = true; m_ChatState = ChatState.Initialized; return true; } }
public void OnChatStateChange(ChatState state) { Debug.Log("OnChatStateChange"); Debug.Log(state); }
/// <summary> /// Initializes a new instance of the ChatStateChangedEventArgs class. /// </summary> /// <param name="jid">The JID of the XMPP entity that published the /// chat-state.</param> /// <param name="state">The chat-state of the XMPP entity with the specified /// JID.</param> /// <exception cref="ArgumentNullException">The jid parameter is /// null.</exception> public ChatStateChangedEventArgs(Jid jid, ChatState state) { jid.ThrowIfNull("jid"); Jid = jid; ChatState = state; }
public void OnChatStateChange(ChatState state) { }
public void OnChatStateChange(ChatState state) { Debug.Log("ChatState - " + state); }
void IChatCallbacks.ChatChannelMembershipCallback(TTV_ChatEvent evt, ChatChannelInfo channelInfo) { switch (evt) { case TTV_ChatEvent.TTV_CHAT_JOINED_CHANNEL: { m_ChatState = ChatState.Connected; FireConnected(); break; } case TTV_ChatEvent.TTV_CHAT_LEFT_CHANNEL: { m_ChatState = ChatState.Disconnected; break; } default: { break; } } }
void IChatCallbacks.ChatStatusCallback(ErrorCode result) { if (Error.Succeeded(result)) { return; } m_ChatState = ChatState.Disconnected; }
protected virtual bool Shutdown() { if (m_ChatInitialized) { ErrorCode ret = m_Chat.Shutdown(); if (Error.Failed(ret)) { string err = Error.GetString(ret); ReportError(string.Format("Error shutting down chat: {0}", err)); return false; } } m_ChatState = ChatState.Uninitialized; m_ChatInitialized = false; CleanupEmoticonData(); m_Chat.ChatCallbacks = null; return true; }
public void OnChatStateChange(ChatState state) { UnityEngine.Debug.Log(state.ToString()); }
void UpdateLeave() { if (m_isServer == true) { m_transport.StopServer(); } else { m_transport.Disconnect(); } // 메시지 삭제. for (int i = 0; i < 2; ++i) { m_message[i].Clear(); } m_state = ChatState.HOST_TYPE_SELECT; }
public void OnChatStateChange(ChatState state) { // use OnConnected() and OnDisconnected() // this method might become more useful in the future, when more complex states are being used. }
/// <summary> /// Periodically updates the internal state of the controller. /// </summary> public virtual void Update() { // for stress testing to make sure memory is being passed around properly //GC.Collect(); if (!m_ChatInitialized) { return; } ErrorCode ret = m_Chat.FlushEvents(); if (Error.Failed(ret)) { string err = Error.GetString(ret); ReportError(string.Format("Error flushing chat events: {0}", err)); } switch (m_ChatState) { case ChatState.Uninitialized: { break; } case ChatState.Initialized: { // connect to the channel if (m_Anonymous) { ret = m_Chat.ConnectAnonymous(); } else { ret = m_Chat.Connect(m_ChannelName, m_AuthToken.Data); } if (Error.Failed(ret)) { string err = Error.GetString(ret); ReportError(string.Format("Error connecting: {0}", err)); Shutdown(); FireDisconnected(); } else { m_ChatState = ChatState.Connecting; DownloadEmoticonData(); } break; } case ChatState.Connecting: { break; } case ChatState.Connected: { break; } case ChatState.Disconnected: { Disconnect(); break; } } }