void OnChannelMessageDeleted(string channelId, FizzChannelMessage action) { if (_channel != null && _channel.Id.Equals(channelId)) { RemoveAction(GetChatCellModelFromAction(action)); } }
public RectTransform GetCustomMessageCellViewNode(FizzChannelMessage message) { if (message.Data != null) { if (message.Data.ContainsKey("type") && message.Data["type"].Equals("fizz_predefine_phrase")) { string id = message.Data["phrase_id"]; FizzHypercasualPhraseDataItem phraseData = dataProvider.GetPhrase(id); if (phraseData != null) { FizzCustomPhraseView phraseView = Instantiate(PhrasePrefab); phraseView.gameObject.SetActive(true); phraseView.SetPhrase(phraseData.GetLocalizedContent(Application.systemLanguage)); // Theme color change phraseView.GetComponent <ThemeLabelColor>().SetColor((message.From.Equals(FizzService.Instance.UserId)? ThemeColor.Base_2 : ThemeColor.Base_1)); return(phraseView.GetComponent <RectTransform> ()); } } else if (message.Data.ContainsKey("type") && message.Data["type"].Equals("fizz_predefine_sticker")) { string id = message.Data["sticker_id"]; FizzHypercasualStickerDataItem stickerData = dataProvider.GetSticker(id); if (stickerData != null) { FizzCustomStickerView sticker = Instantiate(StickerPrefab); sticker.gameObject.SetActive(true); sticker.SetSticker(stickerData.Content); return(sticker.GetComponent <RectTransform> ()); } } } return(null); }
private void CheckForDateHeader(FizzChannelMessage action) { bool shouldAddHeaderModel = false; if (_lastAction == null) { shouldAddHeaderModel = true; _lastAction = action; } else { DateTime last = Utils.GetDateTimeToUnixTime(_lastAction.Created); last = last.Date; DateTime current = Utils.GetDateTimeToUnixTime(action.Created); TimeSpan ts = current.Subtract(last); if (ts.Days > 0) { shouldAddHeaderModel = true; } _lastAction = action; } if (shouldAddHeaderModel) { FizzMessageCellModel model = GetChatCellModelFromAction(action); model.Type = FizzChatCellType.DateCell; _chatCellModelList.Add(model); } }
private void SendChatMessage(string messageStr) { if (_data == null) { return; } long now = FizzUtils.Now(); Dictionary <string, string> data = new Dictionary <string, string>(); data.Add(FizzUIMessage.KEY_CLIENT_ID, now + ""); FizzChannelMessage message = new FizzChannelMessage( now, FizzService.Instance.UserId, FizzService.Instance.UserName, _data.Id, messageStr, data, null, now); UIChatCellModel model = GetChatCellModelFromAction(message); AddNewAction(model, false, true); FizzService.Instance.PublishMessage(message.To, message.Nick, message.Body, message.Data, FizzService.Instance.IsTranslationEnabled, true, ex => { if (ex == null) { model.Action.PublishState = UIChannelMessageState.Sent; AddNewAction(model); } }); }
public void UpdateMessage(FizzChannelMessage message) { if (_messageList.ContainsKey(message.Id)) { _messageList[message.Id] = message; cached = false; } }
public void RemoveMessage(FizzChannelMessage message) { if (_messageList.ContainsKey(message.Id)) { _messageList.Remove(message.Id); cached = false; } }
void OnChannelMessageDeleted(string channelId, FizzChannelMessage action) { if (_data != null && _data.Id.Equals(channelId)) { UIChatCellModel model = GetChatCellModelFromAction(action); RemoveAction(model); } }
private FizzMessageCellModel GetChatCellModelFromAction(FizzChannelMessage action) { var model = new FizzMessageCellModel(action.Id, action.From, action.Nick, action.To, action.Body, action.Data, action.Translations, action.Created) { Type = FizzChatCellType.ChatCell }; return(model); }
void OnChannelMessage(string channelId, FizzChannelMessage action) { if (_data != null && _data.Id.Equals(channelId)) { UIChatCellModel model = GetChatCellModelFromAction(action); model.Action.PublishState = UIChannelMessageState.Published; AddNewAction(model); } }
void OnChannelMessage(string channelId, FizzChannelMessage action) { if (_channel != null && _channel.Id.Equals(channelId)) { FizzMessageCellModel model = GetChatCellModelFromAction(action); model.DeliveryState = FizzChatCellDeliveryState.Published; AddAction(model); } }
public void AddMessage(FizzChannelMessage message, bool notify = true) { if (_messageList.ContainsKey(message.Id)) { return; } _messageList.Add(message.Id, message); cached = false; }
private UIChatCellModel GetChatCellModelFromAction(FizzChannelMessage action) { var model = new UIChatCellModel { Action = new FizzUIMessage(action.Id, action.From, action.Nick, action.To, action.Body, action.Data, action.Translations, action.Created), Type = UIChatCellModel.UIChatCellModelType.ChatAction }; return(model); }
void Listener_OnMessageUpdated(FizzChannelMessage msg) { if (channelLoopup.ContainsKey(msg.To)) { channelLoopup[msg.To].UpdateMessage(msg); } if (OnChannelMessageUpdate != null) { OnChannelMessageUpdate.Invoke(msg.To, msg); } }
void Listener_OnMessagePublished(FizzChannelMessage msg) { if (channelLoopup.ContainsKey(msg.To)) { channelLoopup[msg.To].AddMessage(msg); } if (OnChannelMessagePublish != null) { OnChannelMessagePublish.Invoke(msg.To, msg); } }
private void OnMessagePublished(FizzChannelMessage message) { if (_receivedMessage.Contains(message.Id)) { // duplicate message; return; } _receivedMessage.Add(message.Id); string json = new MessageData(message, Locale.Code).SaveToString(); _logView.AddChatLog(json); }
public MessageData(FizzChannelMessage message, string locale) { id = message.Id; from = message.From; nick = message.Nick; to = message.To; body = message.Body; if (message.Translations != null && message.Translations.ContainsKey(locale)) { body = message.Translations[locale]; } }
public void SetData(FizzChannelMessage message) { if (message != null && message.Data != null) { string title = string.Empty; if (message.Data.TryGetValue("title", out title)) { titleLabel.text = title + " Invitation"; } message.Data.TryGetValue("group-id", out _groupId); actionsNode.gameObject.SetActive(true); } }
public void SetData(string userId, FizzChannelMessage message) { _message = message; if (message != null && message.Data != null) { string status = string.Empty; if (message.Data.TryGetValue(CustomCellSample.KEY_DATA_STATUS, out status)) { statusLabel.text = status; } actionsNode.gameObject.SetActive(_message.From.Equals(userId)); } }
void Listener_OnMessageUpdated(FizzChannelMessage msg) { FizzChannelModel channel = GetChannel(msg.To); if (channel != null) { channel.UpdateMessage(msg); if (OnChannelMessageUpdate != null) { OnChannelMessageUpdate.Invoke(msg.To, msg); } } }
void Listener_OnMessagePublished(FizzChannelMessage msg) { FizzChannelModel channel = GetChannel(msg.To); if (channel != null) { channel.AddMessage(msg); if (OnChannelMessagePublish != null) { OnChannelMessagePublish.Invoke(msg.To, msg); } } }
private void LoadMessages() { _chatCellModelList.Clear(); _actionsLookUpDict.Clear(); IList <FizzChannelMessage> actionsList = _data.Messages; for (int index = 0; index < actionsList.Count; index++) { FizzChannelMessage action = actionsList[index]; UIChatCellModel model = GetChatCellModelFromAction(action); model.Action.PublishState = UIChannelMessageState.Published; CheckForDateHeader(model.Action); _chatCellModelList.Add(model); AddActionInLookup(model); } }
RectTransform IFizzCustomMessageCellViewDataSource.GetCustomMessageCellViewNode(FizzChannelMessage message) { try { if (message != null && message.Data != null && (message.Data.ContainsKey(KEY_DATA_TYPE) && message.Data[KEY_DATA_TYPE] == "status")) { StatusNode node = Instantiate(Resources.Load <StatusNode>("StatusNode")); node.SetData(FizzService.Instance.UserId, message); return(node.GetComponent <RectTransform>()); } } catch { FizzLogger.E("Unable to add custom node in message cell."); } return(null); }
RectTransform IFizzCustomMessageCellViewDataSource.GetCustomMessageCellViewNode(FizzChannelMessage message) { try { // Custom data key string KEY_DATA_TYPE = "custom-type"; if (message != null && message.Data != null && (message.Data.ContainsKey(KEY_DATA_TYPE) && message.Data[KEY_DATA_TYPE] == "invite")) { GroupInviteNode node = Instantiate(Resources.Load <GroupInviteNode>("GroupInviteNode")); node.SetData(message); return(node.GetComponent <RectTransform>()); } } catch { FizzLogger.E("Unable to add custom node in message cell."); } return(null); }