egg-socket.io 自定义path应该怎么写

Created on 28 Dec 2018  ·  2Comments  ·  Source: eggjs/egg

image

如上图配置之后,没有成功
客户端情况
image
image

question

Most helpful comment

According to the official document, there are two ways to set the server path:

  • passing the path parameter through the constructor(default to /socket.io) which means the init config in egg-socket.io:
exports.io = {
  init: {
    path: 'geoc',
  },
  namespace: {
    '/': {
      connectionMiddleware: [],
      packetMiddleware: [],
    },
  },
};
  • Another method is to manually invoke the path interface to change to path property:
app.io.path('geoc')

All 2 comments

According to the official document, there are two ways to set the server path:

  • passing the path parameter through the constructor(default to /socket.io) which means the init config in egg-socket.io:
exports.io = {
  init: {
    path: 'geoc',
  },
  namespace: {
    '/': {
      connectionMiddleware: [],
      packetMiddleware: [],
    },
  },
};
  • Another method is to manually invoke the path interface to change to path property:
app.io.path('geoc')

@ngot 感谢!已经成功。查阅同学请注意:path:"/geoc",“/”不能少。

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Quekie picture Quekie  ·  3Comments

bupafengyu picture bupafengyu  ·  3Comments

yuu2lee4 picture yuu2lee4  ·  3Comments

zhaofinger picture zhaofinger  ·  3Comments

Leungkingman picture Leungkingman  ·  3Comments