Esempio n. 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);
    }
Esempio n. 2
0
    public void OnBtnDownload()
    {
        if (!NetworkClient.Inst().IsConnected())
        {
            MessageBox.Show("Network Error:", "Network Disconnected.", null);
            return;
        }

        ICD.CMD_SongFile msg = new ICD.CMD_SongFile();
        msg.song = SongInfo;
        msg.FillHeader(ICD.ICDDefines.CMD_Download);
        NetworkClient.Inst().SendMsgToServer(msg);
        StartCoroutine(ShowProgressBar());
        NetworkClient.Inst().mOnRecv.AddListener(OnRecvDownload);
    }
Esempio n. 3
0
    public void OnBtnUpload()
    {
        if (!NetworkClient.Inst().IsConnected())
        {
            MessageBox.Show("Network Error:", "Network Disconnected.", null);
            return;
        }

        ICD.CMD_SongFile msg = new ICD.CMD_SongFile();
        msg.song = SongInfo;
        byte[] stream = File.ReadAllBytes(SongInfo.FilePath + SongInfo.FileNameNoExt + ".mp3");
        msg.stream.AddRange(stream);
        msg.FillHeader(ICD.ICDDefines.CMD_Upload);
        NetworkClient.Inst().SendMsgToServer(msg);
        NetworkClient.Inst().mOnRecv.AddListener(OnRecvUpload);
    }
Esempio n. 4
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);
    }