Example #1
0
    private void OnRecvUpload(ICD.stHeader _msg, string _info)
    {
        if (_msg.GetType() != typeof(CMD_SongFile))
        {
            return;
        }
        if (_msg.head.cmd != ICD.ICDDefines.CMD_Upload)
        {
            return;
        }

        ICD.CMD_SongFile msg = (ICD.CMD_SongFile)_msg;
        try
        {
            SongInfo = msg.song;
            byte[] buf = Utils.Serialize(msg.song);
            File.WriteAllBytes(Application.persistentDataPath + "/" + msg.song.FileNameNoExt + ".bytes", buf);
        }
        catch (Exception ex)
        {
            MessageBox.Show(Application.persistentDataPath, msg.song.FileNameNoExt, null);
            MessageBox.Show("DBID: " + msg.song.DBID, ex.ToString(), null);
        }

        NetworkClient.Inst().mOnRecv.RemoveListener(OnRecvUpload);
    }
Example #2
0
    private void OnRecvDownload(ICD.stHeader _msg, string _info)
    {
        if (_msg.GetType() != typeof(CMD_SongFile))
        {
            return;
        }
        if (_msg.head.cmd != ICD.ICDDefines.CMD_Download)
        {
            return;
        }

        ICD.CMD_SongFile msg = (ICD.CMD_SongFile)_msg;
        msg.song.FilePath = Application.persistentDataPath + "/";
        File.WriteAllBytes(Application.persistentDataPath + "/" + msg.song.FileNameNoExt + ".mp3", msg.stream.ToArray());
        byte[] buf = Utils.Serialize(msg.song);
        File.WriteAllBytes(Application.persistentDataPath + "/" + msg.song.FileNameNoExt + ".bytes", buf);
        SongInfo = msg.song;

        NetworkClient.Inst().mOnRecv.RemoveListener(OnRecvDownload);
    }