Ejemplo n.º 1
0
    protected virtual IEnumerator SetUpSocket()
    {
        while (BasicBehaviour.instance == null)
        {
            Debug.Log("Waiting for instance");
            yield return(new WaitForSeconds(0.5f));
        }

        behaviour = BasicBehaviour.instance;
        behaviour.GetWS().OnOpen += () =>
        {
            readyForId = true;
        };
        behaviour.GetWS().OnMessage += (byte[] msg) =>
        {
            ProcessMessage(Encoding.UTF8.GetString(msg));
        };
    }
Ejemplo n.º 2
0
    public void SendScore(string name, int score)
    {
        if (behaviour.GetWS().GetState() != HybridWebSocket.WebSocketState.Open)
        {
            return;
        }

        string msg = "Score:" + PlayerPrefs.GetString("Guid") + "%" + name + "%" + score.ToString();

        behaviour.Send(msg);
    }