zoukankan      html  css  js  c++  java
  • mormot支持websocket

    mormot支持websocket

    根据定义,HTTP连接是无状态的和单向的,也就是说,客户机向服务器发送一个请求,该服务器通过一个应答回复。
    没有客户端的预先请求,就没有办法让服务器发送消息给客户机。

    WebSockets是能让普通的HTTP连接升级为双路通信有线通信协议。
    在安全握手之后,底层TCP/IP套接字能够通过一组轻量级协议直接访问应用程序定义的协议,而不需要HTTP开销。

    synbidirsock.pas单元实现底层服务器和客户端WebSocket通信。

    服务端:

    uses mORMotHttpServer

     HttpServer := TSQLHttpServer.Create('8888',[Server],'+',useBidirSocket);
    Under the hood, it will instantiate a TWebSocketServer HTTP server, as defined in mORMotHttpServer.pas, based on the sockets API, able to upgrade the HTTP protocol into WebSockets.
    Our High-performance http.sys server is not yet able to switch to WebSockets - and at API level, it would require at least Windows 8 or Windows 2012 Server.

    Then you enable WebSockets for the TWebSocketProtocolBinary protocol, with an encryption key:

       HttpServer.WebSocketsEnable(Server,'key');

    客户端:
    Client := TSQLHttpClientWebsockets.Create('127.0.0.1','8888',TSQLModel.Create([]));
      Client.WebSocketsUpgrade('key');
    除了常规的查询/应答命令定义客户端服务器的服务通过接口,还可以使用接口参数的服务定义回调方法。



  • 相关阅读:
    Building a flexiable renderer
    Indirect Illumination in mental ray
    我的心情
    Cellular Automata
    Subsurface Scattering in mental ray
    Shader Types in mental ray
    BSP Traversal
    我的渲染器终于达到了MR的速度
    How to handle displacement and motion blur
    说明
  • 原文地址:https://www.cnblogs.com/hnxxcxg/p/7714406.html
Copyright © 2011-2022 走看看