Ejemplo n.º 1
0
    private void readSocket()
    {
        //Console.WriteLine(" - Try to read!");
        if (!socket_ready)
        {
            return;
        }

        if (net_stream.DataAvailable && net_stream.CanRead)
        {
            //Debug.Log("Read Socket");
            try {
                // decrypt ?
                BSONObject obj = null;
                obj = SimpleBSON.Load(ByteStreamParser.parseStream(net_stream));



                IClientCmd clientCmd = cmdMgr.decodeBSON(obj);
                if (clientCmd != null)
                {
                    this.observer.addClientCmd(clientCmd);
                }
                else
                {
                    Debug.LogError("ClientCmd not parsed !");
                }
            } catch (Exception e) {
                Debug.LogError("Exception:" + e);
            }
        }
    }