public static ServerEventID ReadID(BinaryReader binReader)
        {
            byte          b  = binReader.ReadByte();
            ServerEventID id = (ServerEventID)b;

            return(id);
        }
        private void ListenForEvents()
        {
            while (isRunning)
            {
                BinaryReader binReader = new BinaryReader(new MemoryStream(buffer));
                ReceiveData();
                ServerEventID id = DataParser.ReadID(binReader);

                switch (id)
                {
                case ServerEventID.ACCOUNT_LOGIN_FAIL:
                    Debug.Log("Account Login failed");
                    break;

                case ServerEventID.ACCOUNT_LOGIN_SUCCESS:
                    Debug.Log("Account Logged In");
                    break;

                case ServerEventID.AVATAR_LOGIN_FAIL:
                    Debug.Log("Avatar Login failed");
                    break;

                case ServerEventID.AVATAR_LOGIN_SUCCESS:
                    Debug.Log("Avatar Logged In");
                    break;

                case ServerEventID.AVATARS_AVAILABLE:
                    Debug.Log("Got Avatars");
                    break;

                default:
                    HandleUnknownMessage(id);
                    break;
                }
            }

            connectionState = ConnectionState.Connection_Lost;
            Debug.Log(connectionState);
        }
 void HandleUnknownMessage(ServerEventID id)
 {
     Debug.Log("Received Unknown Event ID " + id.ToString());
 }
 public static void WriteID(BinaryWriter binWriter, ServerEventID id)
 {
     binWriter.Write((byte)id);
 }