コード例 #1
0
    static void reciver()
    {
        if (sk != null)
        {
            byte[]        data    = new byte[256];
            StringBuilder builder = new StringBuilder();
            int           bytes   = 0;

            do
            {
                data  = new byte[sk.Available];
                bytes = sk.Receive(data, data.Length, 0);
                builder.Append(Encoding.UTF8.GetString(data, 0, bytes));
            }while (sk.Available > 0);
            new recive().ini(builder.ToString());
            String b = builder.ToString();
            if (old_m.IndexOf("auth") != -1)
            {
                auth a = JsonUtility.FromJson <auth>(b);
                cam.render_me(a);
            }

            if (old_m.IndexOf("setPosition") != -1)
            {
                user_info [] a = JsonUtility.FromJson <user_info []>(b);
                for (int w = 0; w < a.Length; w++)
                {
                    cam.render_or(a[w]);
                }
            }

            if (b.IndexOf("sendMessage") != -1)
            {
                mess a = JsonUtility.FromJson <mess>(b);
                if (a.value.status == 1)
                {
                    GameObject g = finBbyId(a.id);
                    if (g != null)
                    {
                        g.GetComponent <usr>().sendMess(a.value.text);
                    }
                }
                if (a.value.status == 2 || a.value.status == 3)
                {
                    GameObject g = finBbyId(a.id);
                    if (g != null)
                    {
                        g.GetComponent <usr>().sendhi();
                    }
                }
            }
        }
        else
        {
            reciver();
        }
    }