• Tencent://Message/协议的实现原理


    腾讯官方通过 Tencent://Message/协议可以让QQ用户显示QQ/TM的在线状态发布在互联网上;并且点击 ,不用加好友也可以聊天:

     

    官方链接: http://is.qq.com/webpresence/code.shtml

    具体代码:

    <a href="tencent://message/?uin=215555521&Site=JooIT.com&Menu=yes">
    <img border="0" SRC='http://wpa.qq.com/pa?p=1:215555521:3' alt="点击这里给我发消息">
    </a>

    但它是如何实现的呢?下面文章以及微软官方说明详细解释了其工作原理:

     



    微软官方说明: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。 


     

    原文链接: hi.baidu.com/kmiaoer/blog/item/799fd388ec403691a5c2723b.html

    腾讯启动方式

    var userAgent = navigator.userAgent.toLowerCase();
    var ie=/msie/.test( userAgent ) && !/opera/.test( userAgent );
    var g = {
    closeWindow:function(){
    if ((ie&&window.history.length>0) || (!ie&&window.history.length>1)){
    window.history.back(1);
    return;
    }
    if (ie) {
    window.opener = null;
    window.open('','_top');
    window.top.close();
    }
    }
    ,report:function(id,sigt){
    var img = document.createElement("img");
    img.src = "http://wp.qq.com/cgi-bin/api_attr?id="+id+"&SigT="+sigt;
    }
    ,checkActiveX:function(){
    var kXmlHttp = null;
    try{
    if(typeof XMLHttpRequest != "undefined"){
    kXmlHttp = new XMLHttpRequest();
    return true;
    }
    }
    catch(e){}        var aVersionhs = ["MSXML2.XMLHttp.3.0","MSXML2.XMLHttp.6.0","MSXML2.XMLHttp","Microsoft.XMLHttp","MSXML2.XMLHttp.5.0","MSXML2.XMLHttp.4.0"];
    for(var i=0;i<aVersionhs.length;i++){
    try{
    kXmlHttp = new ActiveXObject(aVersionhs[i]);
    return true;
    }
    catch(e){}        
    }
    return false;
    }
    };
    window.onload=function(){
    var location = "tencent://message/?Menu=yes&uin=173251213&Site=&Service=201&sigT=afb8bca7ae5c962750b1ff8aa52d89d4a45faae2295dc6c297628ca3f1657abd7f3318ccf77de13bdd57fa0181a2223c&sigU=4dae486d846243a13ad46281d67cf0864a9bbcda250cf9e93168989602bee02d55bfcad34f2ad62c";
    var sigt = location.replace(/^\S+sigT=/g,"").replace(/&\S+$/g,"");
    if(!ie){
    g.report(2,sigt);
    window.location=location;
    window.setTimeout(function(){
    g.closeWindow()
    }
    ,200);
    }
    else{
    if (!g.checkActiveX()) {
    window.location=location;
    return;
    }
    try{
    var cpTimwp = new ActiveXObject("TimwpDll.TimwpCheck");
    if(cpTimwp){
    window.location=location;
    window.setTimeout(g.closeWindow,200);
    return;
    }
    }
    catch(e){
    if(ie){
    g.report(1,sigt);
    window.location="http://wp.qq.com/check_qq.html?urltencent=" + encodeURIComponent(location) +                   "&sigt=" + encodeURIComponent(sigt);
    }
    }
    }
    };
  • 相关阅读:
    Unable to load configuration.
    Hibernate映射文件如何配置触发器
    hibernate的集中持久化方法的区别
    Hibernate.lock()方法中各种锁的区别
    JNDI全面总结
    代理模式
    Java常见的几种内存溢出及解决方法
    Hibernate整合C3P0实现连接池
    Hibernate与Mybatis的概念区别
    sql之truncate 、delete与drop区别
  • 原文地址:https://www.cnblogs.com/hun_dan/p/2330922.html
Copyright © 2020-2023  润新知