Exemplo n.º 1
0
    public void Activate()
    {
        cli = Statics.mainClient;

        cli.OnMessage += OnMessage;
        if (!File.Exists(Application.persistentDataPath + "/" + conversationID))
        {
            File.Create(Application.persistentDataPath + "/" + conversationID);
            CA = new ChatArchive();
        }
        else
        {
            var    file = File.ReadAllBytes(Application.persistentDataPath + "/" + conversationID);
            string json = Encoding.ASCII.GetString(file);
            CA = JsonUtility.FromJson <ChatArchive>(json);
        }
        foreach (MessageArj marj in CA.messages)
        {
            GameObject go = GameObject.Instantiate(messageTemplate, messageParent);
            go.SetActive(true);
            messages.Add(go);

            MessageTemplate mt = go.GetComponent <MessageTemplate>();
            mt.cm = this;

            mt.isSender = marj.SentByMe;

            mt.SendMessageXMPP(marj.body);
        }
    }
Exemplo n.º 2
0
 public void ReadFile()
 {
     if (File.Exists(Path.Combine(Application.persistentDataPath, jsonFileName)))
     {
         string json = File.ReadAllText(Path.Combine(Application.persistentDataPath, jsonFileName));
         userArchive = JsonUtility.FromJson <ChatArchive>(json);
     }
 }