Exemplo n.º 1
0
    protected override void OnMessage(MessageEventArgs e)
    {
        Viewer.AddLine("< RECIEVED >");
        Viewer.AddLine("Recieved: " + e.Data);

        var res = e.Data + ";" + System.DateTime.Now;

        if (e.Data.Split()[0] == "EFFDATA")
        {
            var effdata = JsonUtility.FromJson <EffectData>(e.Data.Split()[1]);
            if (GreatLimit > Environment.TickCount)
            {
                effdata.LocalScale *= 100.0f;
            }

            var json = JsonUtility.ToJson(effdata);
            res = "EFFDATA\n" + json;

            RecvQ.Enqueue(effdata);
        }
        if (e.Data == "REQ TEST EFF")
        {
            Viewer.AddLine("Return test effect.");
            var data = new EffectData();

            data.EffectName = "Laser01";
            data.Position   = new Vector3(0.0f, 0.0f, 70.0f);
            data.Rotation   = Quaternion.Euler(0, -90, 0);
            if (GreatLimit > Environment.TickCount)
            {
                data.LocalScale = new Vector3(100.0f, 100.0f, 100.0f);
            }
            else
            {
                data.LocalScale = new Vector3(1.0f, 1.0f, 1.0f);
            }

            RecvQ.Enqueue(data);

            var json = JsonUtility.ToJson(data);

            res = "EFFDATA\n" + json;
        }
        else if (e.Data == "LIKE")
        {
            Viewer.AddLine("Received LIKE. Make Effect Great Again.");

            GreatLimit = Environment.TickCount + 30 * 1000; // 30s for DEBUG

            var data = new EffectData();

            data.EffectName = "Laser01";
            data.Position   = new Vector3(-3.0f, -2.0f, -1.0f);
            data.Rotation   = Quaternion.Euler(0, -90, 0);
            if (GreatLimit > Environment.TickCount)
            {
                data.LocalScale = new Vector3(100.0f, 100.0f, 100.0f);
            }
            else
            {
                data.LocalScale = new Vector3(1.0f, 1.0f, 1.0f);
            }

            RecvQ.Enqueue(data);
            var json = JsonUtility.ToJson(data);

            res = "EFFDATA\n" + json;
        }

        Sessions.Broadcast(res);
        Viewer.AddLine("< BROADCASTED >");
    }