Beispiel #1
0
        public static ChatMessageBase Create(BaseMessageInfo message)
        {
            var messageType = message.GetMessageType();

            switch (messageType)
            {
            case MessageType.INCOMING_USER_MESSAGE:
                return(new IncomingUserMessage((IncomingUserMessageInfo)message));


            case MessageType.OUTGOING_USER_MESSAGE:
                return(new OutgoingUserMessage((OutgoingUserMessageInfo)message));

            default:
                return(new IncomingUserMessage((IncomingUserMessageInfo)message));
            }
        }
        //TODO flesh out all the messages
        public BaseMessageInfo Format()
        {
            BaseMessageInfo result = null;

            if (_baseMessage is UserMessage)
            {
                var inUserMsg = (UserMessage)_baseMessage;

                if (SendBirdClient.CurrentUser.UserId != inUserMsg.Sender.UserId)
                {
                    IncomingUserMessageInfo outUserMsg = new IncomingUserMessageInfo();
                    outUserMsg.Message   = inUserMsg.Message;
                    outUserMsg.CreatedAt = inUserMsg.CreatedAt;
                    result = outUserMsg;
                }
                //just for now
                else
                {
                    OutgoingUserMessageInfo outUserMsg = new OutgoingUserMessageInfo();
                    outUserMsg.Message   = inUserMsg.Message;
                    outUserMsg.CreatedAt = inUserMsg.CreatedAt;
                    result = outUserMsg;
                }
            }
            else
            {
                IncomingUserMessageInfo outUserMsg = new IncomingUserMessageInfo();
                outUserMsg.Message = "Other message type ** to impl **";
                result             = outUserMsg;
            }

            return(result);

            //Message
            // if ( _baseMessage is  )
            //for now we treat everything as
            // BaseMessageInfo r = new IncomingUserMessageInfo();
            //   return r;
        }
Beispiel #3
0
        //public string DefaultMessage
        //{
        //    get
        //    {
        //        if (_data != null)
        //        {
        //            return GetDefaultMessage();
        //        }
        //        else
        //        {
        //            return "";
        //        }

        //    }
        //}


        //   protected abstract string GetDefaultMessage();


        public ChatMessageBase(BaseMessageInfo message)
        {
            _data = message;
        }