Exemplo n.º 1
0
 public void GetVersion(Component receiver, string methodName, bool isListenOnce, VersionRequestParameter parameter)
 {
     this.CommunicateWithServer(receiver, methodName, isListenOnce, parameter.GetHashtableFromParameter(), ClientCommandConsts.GET_VERSION_COMMAND,
                                ServerCommandConsts.VERSION_RESPONSE);
 }
Exemplo n.º 2
0
    IEnumerator Initialize()
    {
        CommunicationUtility.Instance.DisconnectToServer();
        CommunicationUtility.Instance.ConnectToServer();

        while (!CommunicationUtility.Instance.IsConnectedToServer)
        {
            yield return(null);
        }
        VersionRequestParameter request = new VersionRequestParameter();

        request.PlatformType = CommonHelper.PlatformType;
        CommunicationUtility.Instance.GetVersion(this, "ReceivedVersion", true, request);
        while (!this.IsGetServerVersion)
        {
            yield return(null);
        }
        if (CommonHelper.PlatformType == ConfigUtilities.Enums.PlatformType.iOS)
        {
            if (iOSCenter.Instance.AccountID < 0)
            {
                this.m_UIWindowUserLogin.ShowWindow();
            }
            while (iOSCenter.Instance.AccountID < 0)
            {
                yield return(null);
            }
        }
        AudioController.PlayMusic("Loading");
        this.m_ProgressBar.SetActive(true);
        CommunicationUtility.Instance.GetConfigTableMD5(this, "ReceivedConfigTableMD5", true);
        while (!this.IsGetServerMD5)
        {
            yield return(null);
        }
        this.LoadConfigTable();
        byte[] localMD5 = null;
        if (this.m_wwwConfigTable != null)
        {
            while (!this.m_wwwConfigTable.isDone)
            {
                yield return(null);
            }
            MemoryStream ms = new MemoryStream(this.m_wwwConfigTable.bytes);
            localMD5 = MD5.Create().ComputeHash(ms);
            ms.Close();
        }
        if (localMD5 == null || !localMD5.IsEqualByteArray(this.m_ServerConfigTableMD5))
        {
            string configUrl = string.Format(DataResource.CONFIG_TABLE_URL, ClientVersion.Instance.Version);
            this.m_wwwConfigTable = new WWW(configUrl);
            yield return(this.m_wwwConfigTable);
        }

        FileStream   fileStream = new FileStream(Application.persistentDataPath + "/" + CONFIG_PATH, FileMode.Create);
        BinaryWriter writer     = new BinaryWriter(fileStream);

        writer.Write(this.m_wwwConfigTable.bytes);
        writer.Close();

        MemoryStream compressedStream   = new MemoryStream(this.m_wwwConfigTable.bytes);
        MemoryStream uncompressedStream = new MemoryStream();

        CompressionUtility.DecompressStream(compressedStream, uncompressedStream);

        BinaryFormatter bft = new BinaryFormatter();

        DataResource.Resource = (DataSet)bft.Deserialize(uncompressedStream);

        /*
         * print(DataResource.Resource.Tables.Count);
         * print(DataResource.Resource.Tables[0].Rows.Count);
         * print(DataResource.Resource.Tables[1].Rows.Count);
         * print(DataResource.Resource.Tables[2].Rows.Count);
         */

        compressedStream.Close();
        uncompressedStream.Close();

        if (CommonHelper.PlatformType == ConfigUtilities.Enums.PlatformType.iOS &&
            Application.platform == RuntimePlatform.IPhonePlayer)
        {
            ((iOSShopUtility)(iOSShopUtility.Instance)).RequestProduct();
        }

        this.m_UserIntializer.StartInitialize();
    }