void RequestSongsFromServer() { ICD.CMD_MusicList msg = new ICD.CMD_MusicList(); msg.method = mSortMethod; msg.FillHeader(ICD.ICDDefines.CMD_MusicList); NetworkClient.Inst().SendMsgToServer(msg); NetworkClient.Inst().mOnRecv.AddListener(OnRecvMusicList); }
void OnRecvMusicList(ICD.stHeader _msg, string _info) { if (_msg.head.cmd != ICD.ICDDefines.CMD_MusicList) { return; } ICD.CMD_MusicList msg = (ICD.CMD_MusicList)_msg; for (int i = 0; i < msg.musics.Count; ++i) { int DBID = msg.musics[i].DBID; if (mSongIDs.ContainsKey(DBID)) { continue; } GameObject obj = Instantiate(prefabListItem, new Vector2(0, 0), Quaternion.identity, transform); ItemDisplay item = obj.GetComponent <ItemDisplay>(); item.SongInfo = msg.musics[i]; } NetworkClient.Inst().mOnRecv.RemoveListener(OnRecvMusicList); }