Example #1
0
    public void OnSendMessageStatus(ulong iRequestID, YIMEngine.ErrorCode errorcode)
    {
        MessageCallbackObject callbackObj = null;
        bool finded = messageCallbackQueue.TryGetValue(iRequestID, out callbackObj);

        if (finded)
        {
            if (callbackObj != null && callbackObj.callback != null)
            {
                try
                {
                    switch (callbackObj.msgType)
                    {
                    case MessageBodyType.TXT:
                        Action <YouMe.StatusCode, TextMessage> call = (Action <YouMe.StatusCode, TextMessage>)callbackObj.callback;
                        var msg = (TextMessage)callbackObj.message;
                        msg.sendTime = TimeUtil.ConvertToTimestamp(System.DateTime.Now);
                        if (errorcode == YIMEngine.ErrorCode.Success)
                        {
                            msg.sendStatus = SendStatus.Sended;
                        }
                        else
                        {
                            msg.sendStatus = SendStatus.Fail;
                        }
                        msg.isReceiveFromServer = false;
                        call(Conv.ErrorCodeConvert(errorcode), msg);
                        break;

                    default:
                        break;
                    }
                }
                catch (Exception e)
                {
                    Log.e(e.ToString());
                }
            }
            messageCallbackQueue.Remove(iRequestID);
        }
    }
Example #2
0
    private void OnSendAudioMessageStatusChange(ulong iRequestID, YIMEngine.ErrorCode errorcode, string strText, string strAudioPath, int iDuration, bool isFinish)
    {
        MessageCallbackObject callbackObj = null;
        bool finded = messageCallbackQueue.TryGetValue(iRequestID, out callbackObj);

        if (finded)
        {
            if (callbackObj != null && callbackObj.callback != null)
            {
                Action <YouMe.StatusCode, AudioMessage> call = (Action <YouMe.StatusCode, AudioMessage>)callbackObj.callback;
                var msg = (AudioMessage)callbackObj.message;
                msg.recognizedText = strText;
                msg.audioFilePath  = strAudioPath;
                msg.audioDuration  = iDuration;
                if (!isFinish)
                {
                    msg.sendTime = TimeUtil.ConvertToTimestamp(System.DateTime.Now);
                }
                if (errorcode == YIMEngine.ErrorCode.Success)
                {
                    msg.sendStatus = isFinish ? SendStatus.Sended : SendStatus.Sending;
                    if (isFinish)
                    {
                        msg.downloadStatus = MessageDownloadStatus.DOWNLOADED;
                    }
                }
                else
                {
                    msg.sendStatus = SendStatus.Fail;
                }
                msg.isReceiveFromServer = false;
                call(Conv.ErrorCodeConvert(errorcode), msg);
            }
            messageCallbackQueue.Remove(iRequestID);
        }
    }
Example #3
0
 public void StartInitialization()
 {
     //TODO send request to get server time
     _initializationStatus = EnumInitializationStatus.inProgress;
     SetTimer(TimeUtil.ConvertToTimestamp(DateTime.Now));
 }