ex

Fork of mbed-os-example-mbed5-blinky by mbed-os-examples

Committer:
TMBOY
Date:
Tue Jul 18 16:34:48 2017 +0800
Revision:
45:2aa9f933c8d2
?

Who changed what in which revision?

UserRevisionLine numberNew contents of line
TMBOY 45:2aa9f933c8d2 1 /*
TMBOY 45:2aa9f933c8d2 2 * Copyright (c) 2017 Baidu, Inc. All Rights Reserved.
TMBOY 45:2aa9f933c8d2 3 *
TMBOY 45:2aa9f933c8d2 4 * Licensed under the Apache License, Version 2.0 (the "License");
TMBOY 45:2aa9f933c8d2 5 * you may not use this file except in compliance with the License.
TMBOY 45:2aa9f933c8d2 6 * You may obtain a copy of the License at
TMBOY 45:2aa9f933c8d2 7 *
TMBOY 45:2aa9f933c8d2 8 * http://www.apache.org/licenses/LICENSE-2.0
TMBOY 45:2aa9f933c8d2 9 *
TMBOY 45:2aa9f933c8d2 10 * Unless required by applicable law or agreed to in writing, software
TMBOY 45:2aa9f933c8d2 11 * distributed under the License is distributed on an "AS IS" BASIS,
TMBOY 45:2aa9f933c8d2 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
TMBOY 45:2aa9f933c8d2 13 * See the License for the specific language governing permissions and
TMBOY 45:2aa9f933c8d2 14 * limitations under the License.
TMBOY 45:2aa9f933c8d2 15 */
TMBOY 45:2aa9f933c8d2 16 package com.baidu.duer.dcs.framework.dispatcher;
TMBOY 45:2aa9f933c8d2 17
TMBOY 45:2aa9f933c8d2 18 import com.baidu.duer.dcs.devicemodule.voiceoutput.ApiConstants;
TMBOY 45:2aa9f933c8d2 19 import com.baidu.duer.dcs.framework.DcsResponseDispatcher;
TMBOY 45:2aa9f933c8d2 20 import com.baidu.duer.dcs.framework.message.DcsResponseBody;
TMBOY 45:2aa9f933c8d2 21
TMBOY 45:2aa9f933c8d2 22 import java.util.concurrent.BlockingQueue;
TMBOY 45:2aa9f933c8d2 23
TMBOY 45:2aa9f933c8d2 24 /**
TMBOY 45:2aa9f933c8d2 25 * 服务器返回的指令header中有dialogRequestId调度线程
TMBOY 45:2aa9f933c8d2 26 * <p>
TMBOY 45:2aa9f933c8d2 27 * Created by guxiuzhong@baidu.com on 2017/6/12.
TMBOY 45:2aa9f933c8d2 28 */
TMBOY 45:2aa9f933c8d2 29 public class WithDialogIdBlockThread extends BaseBlockResponseThread {
TMBOY 45:2aa9f933c8d2 30
TMBOY 45:2aa9f933c8d2 31 public WithDialogIdBlockThread(BlockingQueue<DcsResponseBody> responseBodyDeque,
TMBOY 45:2aa9f933c8d2 32 DcsResponseDispatcher.IDcsResponseHandler responseHandler,
TMBOY 45:2aa9f933c8d2 33 String threadName) {
TMBOY 45:2aa9f933c8d2 34 super(responseBodyDeque, responseHandler, threadName);
TMBOY 45:2aa9f933c8d2 35 }
TMBOY 45:2aa9f933c8d2 36
TMBOY 45:2aa9f933c8d2 37 @Override
TMBOY 45:2aa9f933c8d2 38 boolean shouldBlock(DcsResponseBody responseBody) {
TMBOY 45:2aa9f933c8d2 39 // 如果是speak指令就立马阻塞
TMBOY 45:2aa9f933c8d2 40 String directiveName = responseBody.getDirective().getName();
TMBOY 45:2aa9f933c8d2 41 return directiveName != null && directiveName.length() > 0
TMBOY 45:2aa9f933c8d2 42 && directiveName.equals(ApiConstants.Directives.Speak.NAME);
TMBOY 45:2aa9f933c8d2 43 }
TMBOY 45:2aa9f933c8d2 44 }