有一个聊天应用程序可以将消息传输到我的服务器,我这样做是因为我想将所有消息记录保存在我自己的服务器上。基本上聊天应用程序将消息发送到特定网址,我使用Django保存它们,我已经完成了,我使用了一个名为using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class time : MonoBehaviour {
public float gazeTime = 2f;
private float timer;
private bool gazedAt;
// Use this for initialization
void Start () {
}
void update(){
if (gazedAt)
{
timer += Time.deltaTime;
if (timer >= gazeTime)
{
Application.LoadLevel (scenetochangeto);
timer = 0f;
}
}
}
public void ss(string scenetochangeto)
{
gameObject.SetActive (true);
}
public void pointerenter()
{
//Debug.Log("pointer enter");
gazedAt = true;
}
public void pointerexit()
{
//Debug.Log("pointer exit");
gazedAt = false;
}
public void pointerdown()
{
Debug.Log("pointer down");
}
}
的函数来保存它们(只需将消息写入文本文件)。 / p>
现在我想在服务器上编写一个程序,它可以在消息到达服务器时向我发送电子邮件,我也已经完成了,我使用了一个名为save_message(request)
的函数来执行此操作。< / p>
然而,问题是,我想定期发送电子邮件 。
例如:
我认为每次服务器收到消息时,都需要调用send_email()
,而且我认为save_message(request)
调用应该在send_email()
的正文中,我不会这样做。知道如何在特定时间跳过此调用。有可能吗?
提前谢谢!
答案 0 :(得分:1)
使用django-crontab
并在setting.py中指定您想要在多长时间后运行的功能