在 Socket.IO 1.0 中配置超时和传输 [英] Configure TimeOut and Transports in Socket.IO 1.0

查看:25
本文介绍了在 Socket.IO 1.0 中配置超时和传输的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在旧版本的 Socket.IO (< 0.9) 中,我这样配置关闭超时"和传输":

In old versions of Socket.IO (< 0.9), I configured "close timeout" and "transports" this way:

io.set("transports", ["xhr-polling"]);
io.set("close timeout", 3);

但是现在,命令 io.set 已被弃用.我如何定义 close timeouttranssports?

But now, the command io.set has been deprecated. How do I define close timeout and transports?

当我使用旧版本时会出现此消息:

When I use the old version this message appears:

选项关闭超时无效.

推荐答案

请参阅此处的文档:http://socket.io/docs/migrating-from-0-9/#configuration-differences

基本上,您只需要在初始化服务器时进行设置:

Basically, you just have to set those when you initialize the server:

var socket = require('socket.io')({
  // options go here
});

这篇关于在 Socket.IO 1.0 中配置超时和传输的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆