Exemplo n.º 1
0
    public void SendMessage(string inRecipient, string inMessageBody, E_Mailbox inMailbox = E_Mailbox.Global)
    {
        // ...................................
        // check preconditions...
        if (string.IsNullOrEmpty(inRecipient) == true)
        {
            Debug.LogError("Invalid recipient " + inRecipient);
            return;
        }

        if (string.IsNullOrEmpty(inMessageBody) == true)
        {
            Debug.LogError("Invalid message " + inMessageBody);
            return;
        }

        if (CloudUser.instance.isUserAuthenticated == false)
        {
            Debug.LogError("sender is not authenticated, this message can't be send");
            return;
        }

        // ...................................
        // create message object...
        BaseMessage msg = new BaseMessage();

        msg.m_Mailbox = inMailbox;
        msg.m_Sender  = CloudUser.instance.primaryKey;
        msg.m_Message = inMessageBody;

        // and send it.
        SendMessage(inRecipient, msg);
    }
Exemplo n.º 2
0
 public NewsMessage(string inRawString, E_Mailbox inMailbox, JsonData inJsonData = null)
     : base(inRawString, inMailbox, inJsonData)
 {
     m_Subject  = (string)inJsonData["m_Subject"];
     m_HeadLine = (string)inJsonData["m_HeadLine"];
     //m_ExpirationTime = JsonMapper.ToObject<DateTime>( inJsonData["m_ExpirationTime"].ToString() );
     m_ExpirationTime = DateTime.Parse(inJsonData["m_ExpirationTime"].ToString());
 }
Exemplo n.º 3
0
    static BaseMessage ConstructMessage(string inRawMessage, E_Mailbox inInboxType)
    {
        JsonData msgData = null;

        // try to process input string and check if it is in JSON format...
        try
        {
            msgData = JsonMapper.ToObject(inRawMessage);
            if (inInboxType == E_Mailbox.Unknown)
            {
                if (msgData.HasValue("m_Mailbox") == true)
                {
                    inInboxType = (E_Mailbox)(int)msgData["m_Mailbox"];
                }
            }
        }
        catch
        {
            Debug.LogWarning("Message is not a JSON object");
        }

        //Check for old legacy messages. This code is here only for back compatibility...
        if (msgData == null || msgData.HasValue("msgType") == false)
        {
            Debug.Log("Old Message:\n" + inRawMessage);
            return(new BaseMessage(inRawMessage, inInboxType, null));
        }

        // Construct and init message by msg type...
        switch (msgData["msgType"].ToString())
        {
        case "BaseMessage":
            return(new BaseMessage(inRawMessage, inInboxType, msgData));

        case "FriendRequest":
            return(new FriendRequest(inRawMessage, inInboxType, msgData));

        case "FriendRequestReject":
            return(new FriendRequestReject(inRawMessage, inInboxType, msgData));

        case "FriendMessage":
            return(new FriendMessage(inRawMessage, inInboxType, msgData));

        case "NewsMessage":
            return(new NewsMessage(inRawMessage, inInboxType, msgData));

        case "ResetResearch":
            return(new ResetResearch(inRawMessage, inInboxType, msgData));

        case "SystemMessage":
            return(new SystemMessage(inRawMessage, inInboxType, msgData));

        default:
            throw new MFUnknownMesageTypeException();
        }
    }
Exemplo n.º 4
0
 public FriendMessage(string inRawString, E_Mailbox inMailbox, JsonData inJsonData = null)
     : base(inRawString, inMailbox, inJsonData)
 {
     try
     {
         m_NickName = (string)inJsonData["m_NickName"];
     }
     catch
     {
     }
 }
Exemplo n.º 5
0
        public FriendRequest(string inRawString, E_Mailbox inMailbox, JsonData inJsonData = null)
            : base(inRawString, inMailbox, inJsonData)
        {
            try
            {
                m_Username = (string)inJsonData["m_Username"];
            }
            catch
            {
                m_Username = m_Sender;
            }

            try
            {
                m_NickName = (string)inJsonData["m_NickName"];
            }
            catch
            {
                m_NickName = m_Sender;
            }

            m_ConfirmCommand = (string)inJsonData[CloudServices.RESPONSE_PROP_ID_SERVER_CMD];
        }
Exemplo n.º 6
0
        public BaseMessage(string inRawString, E_Mailbox inMailbox, JsonData inJsonData = null)
        {
            m_Mailbox    = inMailbox;
            m_RAWMessage = inRawString;

            if (inJsonData != null)
            {
                if (inJsonData.HasValue("m_Sender"))
                {
                    m_Sender = (string)inJsonData["m_Sender"];
                }

                if (inJsonData.HasValue("m_Message"))
                {
                    m_Message = (string)inJsonData["m_Message"];
                }
                //m_SendTime      = JsonMapper.ToObject<DateTime>( inJsonData["m_SendTime"].ToString() );

                if (inJsonData.HasValue("m_SendTime"))
                {
                    m_SendTime = DateTime.Parse(inJsonData["m_SendTime"].ToString());
                }
            }
        }
Exemplo n.º 7
0
 public ResetResearch(string inRawString, E_Mailbox inMailbox, JsonData inJsonData = null)
     : base(inRawString, inMailbox, inJsonData)
 {
 }
Exemplo n.º 8
0
 public SystemMessage(string inRawString, E_Mailbox inMailbox, JsonData inJsonData = null)
     : base(inRawString, inMailbox, inJsonData)
 {
 }
Exemplo n.º 9
0
 public SystemCommand(string inRawString, E_Mailbox inMailbox, JsonData inJsonData = null)
     : base(inRawString, inMailbox, inJsonData)
 {
     m_TargetSystem = (string)inJsonData["m_TargetSystem"];
 }