关于腾讯的Tencent://Message/协议

我们知道,很多网站的在线QQ客服是通过 Tencent://Message/协议实现的,类似的实现还有迅雷、快播...下载链接等。

那么这是什么原理呢?

经过一番google,博主发现:



微软官方说明:http://msdn.microsoft.com/library/default.asp?url=/workshop/networking/pluggable/overview/appendix_a.asp
Register protocol,此文中对于 Windows、Linux 和 OS X 操作系统如何注册协议都有说明。比如说 Windows,其实只需写入注册表,即可实现协议与执行程序的关联。例如腾讯的Tencent://Message协议注册表如下:


[HKEY_CLASSES_ROOT\TENCENT]
@=”TencentProtocol”
“URL Protocol”=”D:\\Program Files\\Tencent\\QQ\\Timwp.exe”


[HKEY_CLASSES_ROOT\TENCENT\DefaultIcon]
@=”D:\\Program Files\\Tencent\\QQ\\Timwp.exe,1″


[HKEY_CLASSES_ROOT\TENCENT\shell]


[HKEY_CLASSES_ROOT\TENCENT\shell\open]


[HKEY_CLASSES_ROOT\TENCENT\shell\open\command]
@=”\”D:\\Program Files\\Tencent\\QQ\\Timwp.exe\” \”%1\”"


此注册表所实现的就是当浏览器(或其它)碰到 tencent://… 时,自动调用 Timwp.exe,并把 tencent://… 地址作为第一个参数传递给 Timwp.exe。


更多参见:Registering an Application to a URL Protocol。 




附:原文
程序代码:


A protocol is a method that is used to send, receive, and handle information over a connection. Common protocols viewed from the browser include http, ftp, and mailto. In order for you to view information sent over a specific protocol, it must be registered. Once registered, the protocol can then be handled by the program you specify, such as your browser or a 3rd party viewer. This means that a hyperlink ( e.g. foo://fred ) can use the handler for protocol foo to open the file named fred. 


Contents [hide]
1 Registering an unsupported protocol 
1.1 Windows 
1.2 Linux 
1.3 OS X 
2 Redirecting a registered protocol 






[edit]Registering an unsupported protocol
Mozilla products utilize protocols defined internally, as well as those defined by the operating system. You can add the ability to use an unsupported protocol by registering it. The OS-specific method of doing this is described below. 


[edit]Windows
Create the registry .reg file, replacing foo with your unregistered protocol, and the path with whatever handler program you want to run. Then merge it into the Windows registry.




REGEDIT4


[HKEY_CLASSES_ROOT\foo]
@="URL:foo Protocol"
"URL Protocol"=""


[HKEY_CLASSES_ROOT\foo\shell]


[HKEY_CLASSES_ROOT\foo\shell\open]


[HKEY_CLASSES_ROOT\foo\shell\open\command]
@="\"C:\\Program Files\\Application\\program.exe\" \"%1\"" 
See Registering an Application to a URL Protocol for additional information. 


[edit]Linux
Registration is unnecessary. Simply associate whatever proto: with a program through Firefox: Example: Add the sip: protocol to launch kphone for VoIP calls in Firefox: 


- Type about:config into the address bar
- Right-click create new boolean value: network.protocol-handler.external.sip and set to true
- Right-click create new boolean value: network.protocol-handler.warn-external.sip and set to false
- Right-click create new string value: network.protocol-handler.app.sip 


来源:http://www.wuxuxiao.com/news/newsview.html?id=126
参考:http://blog.csdn.net/dropme/article/details/761203



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
您好,要将腾讯语音实时识别集成到 iOS DCloud 中,您需要完成以下步骤: 1.在 DCloud 中创建一个新的 H5+ 项目,并将其下载到您的本地计算机。 2.进入项目的根目录,然后使用命令行工具执行以下命令来安装 TencentRealTimeSpeechSDK: ```sh npm install tencent-realtime-speech-sdk --save ``` 3.将以下代码添加到您的 HBuilderX 项目中的 index.html 文件中: ```html <script src="https://cdn.jsdelivr.net/npm/@tencent/realtime-speech-ws-sdk-js@2.0.0/dist/RtWSSdk.js"></script> <script src="https://cdn.jsdelivr.net/npm/tencent-realtime-speech-sdk@1.1.1/dist/tencent-realtime-speech-sdk.min.js"></script> ``` 4.在 JavaScript 中编写您的代码,并在需要通知语音识别结果的地方添加以下代码: ```javascript var options = { secretId: 'yourSecretId', secretKey: 'yourSecretKey', appid: 'yourAppid', engine_model_type: '16k_0', voiceFormat: 'wav', timeout: 10000, needVad: false, url: 'ws://recognition.mydomain.com/ws/engine' }; var speechRecognition = new SpeechRecognition(options); speechRecognition.start(function (message) { console.log(message); }); speechRecognition.stop(); ``` 请注意,您需要将 `options` 替换为您自己的配置,其中 `yourSecretId`、`yourSecretKey` 和 `yourAppid` 分别是您在腾讯云中创建的应用程序的凭据。您需要将 `message` 替换为您的逻辑代码,以便在实时语音识别期间处理特定的事件。 5.保存 index.html 文件并重新编译您的 iOS DCloud 项目。 这样,您就可以通过使用 TencentRealTimeSpeechSDK 在您的 iOS DCloud 项目中集成腾讯语音实时识别。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值