コード例 #1
0
 void OnChannelMessageDeleted(string channelId, FizzChannelMessage action)
 {
     if (_channel != null && _channel.Id.Equals(channelId))
     {
         RemoveAction(GetChatCellModelFromAction(action));
     }
 }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
ファイル: UIChatView.cs プロジェクト: FizzCorp/unity3d-sample
        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);
                }
            });
        }
コード例 #5
0
 public void UpdateMessage(FizzChannelMessage message)
 {
     if (_messageList.ContainsKey(message.Id))
     {
         _messageList[message.Id] = message;
         cached = false;
     }
 }
コード例 #6
0
 public void RemoveMessage(FizzChannelMessage message)
 {
     if (_messageList.ContainsKey(message.Id))
     {
         _messageList.Remove(message.Id);
         cached = false;
     }
 }
コード例 #7
0
ファイル: UIChatView.cs プロジェクト: FizzCorp/unity3d-sample
 void OnChannelMessageDeleted(string channelId, FizzChannelMessage action)
 {
     if (_data != null && _data.Id.Equals(channelId))
     {
         UIChatCellModel model = GetChatCellModelFromAction(action);
         RemoveAction(model);
     }
 }
コード例 #8
0
        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);
        }
コード例 #9
0
ファイル: UIChatView.cs プロジェクト: FizzCorp/unity3d-sample
 void OnChannelMessage(string channelId, FizzChannelMessage action)
 {
     if (_data != null && _data.Id.Equals(channelId))
     {
         UIChatCellModel model = GetChatCellModelFromAction(action);
         model.Action.PublishState = UIChannelMessageState.Published;
         AddNewAction(model);
     }
 }
コード例 #10
0
 void OnChannelMessage(string channelId, FizzChannelMessage action)
 {
     if (_channel != null && _channel.Id.Equals(channelId))
     {
         FizzMessageCellModel model = GetChatCellModelFromAction(action);
         model.DeliveryState = FizzChatCellDeliveryState.Published;
         AddAction(model);
     }
 }
コード例 #11
0
        public void AddMessage(FizzChannelMessage message, bool notify = true)
        {
            if (_messageList.ContainsKey(message.Id))
            {
                return;
            }

            _messageList.Add(message.Id, message);
            cached = false;
        }
コード例 #12
0
ファイル: UIChatView.cs プロジェクト: FizzCorp/unity3d-sample
        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);
        }
コード例 #13
0
        void Listener_OnMessageUpdated(FizzChannelMessage msg)
        {
            if (channelLoopup.ContainsKey(msg.To))
            {
                channelLoopup[msg.To].UpdateMessage(msg);
            }

            if (OnChannelMessageUpdate != null)
            {
                OnChannelMessageUpdate.Invoke(msg.To, msg);
            }
        }
コード例 #14
0
        void Listener_OnMessagePublished(FizzChannelMessage msg)
        {
            if (channelLoopup.ContainsKey(msg.To))
            {
                channelLoopup[msg.To].AddMessage(msg);
            }

            if (OnChannelMessagePublish != null)
            {
                OnChannelMessagePublish.Invoke(msg.To, msg);
            }
        }
コード例 #15
0
    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);
    }
コード例 #16
0
        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];
            }
        }
コード例 #17
0
        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);
            }
        }
コード例 #18
0
ファイル: StatusNode.cs プロジェクト: FizzCorp/Fizz-Unity-UI
        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));
            }
        }
コード例 #19
0
        void Listener_OnMessageUpdated(FizzChannelMessage msg)
        {
            FizzChannelModel channel = GetChannel(msg.To);

            if (channel != null)
            {
                channel.UpdateMessage(msg);

                if (OnChannelMessageUpdate != null)
                {
                    OnChannelMessageUpdate.Invoke(msg.To, msg);
                }
            }
        }
コード例 #20
0
        void Listener_OnMessagePublished(FizzChannelMessage msg)
        {
            FizzChannelModel channel = GetChannel(msg.To);

            if (channel != null)
            {
                channel.AddMessage(msg);

                if (OnChannelMessagePublish != null)
                {
                    OnChannelMessagePublish.Invoke(msg.To, msg);
                }
            }
        }
コード例 #21
0
ファイル: UIChatView.cs プロジェクト: FizzCorp/unity3d-sample
        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);
            }
        }
コード例 #22
0
        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);
        }
コード例 #23
0
        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);
        }