public void RequestMessageFromReflector()
 {
     if (mClientReflector != null)
     {
         MemoryStream nextMessage = mClientReflector.GetNextMessage();
         if (nextMessage != null)
         {
             Message myReceivedMessage = (Message)mBinaryFormatter.Deserialize(nextMessage);
             ProcessMessage(myReceivedMessage);
             RequestMessageFromReflector();
         }
     }
 }
示例#2
0
        private IEnumerator <IYieldInstruction> RequestMessageFromReflector()
        {
            while (true)
            {
                try
                {
                    MemoryStream nextMessage = mClientReflector.GetNextMessage();
                    while (nextMessage != null)
                    {
                        //UNCOMMENT THIS SO PRINT THE HEX VALUES OF THE MESSAGE WE JUST RECEIVED FROM THE REFLECTOR
                        //UnityEngine.Debug.Log("memorystream length: " + nextMessage.Length);
                        //byte[] byteArray = nextMessage.ToArray();
                        //UnityEngine.Debug.Log("message hex value: " + BitConverter.ToString( byteArray ));

                        Message myReceivedMessage = null;
                        try
                        {
                            myReceivedMessage = (Message)mBinaryFormatter.Deserialize(nextMessage);
                        }
                        catch (SerializationException e)
                        {
                            Console.WriteLine(e.ToString(), LogLevel.Error);
                            continue;
                        }
                        ProcessMessage(myReceivedMessage);

                        nextMessage = mClientReflector.GetNextMessage();
                    }
                }
                catch (System.Runtime.Serialization.SerializationException e)
                {
                    Hangout.Client.Console.LogError("SerializationException:" + e);
                }

                yield return(new YieldForSeconds(0.05f));
            }
        }