我按照这个链接(https://docs.feathersjs.com/real-time/primus.html)通过feathersjs-primus创建了一个websocket服务器。以下是我正在使用的app.configure
代码:
app.configure(primus({
transformer: 'websocket'
}, function(primus) {
// Do something with primus
primus.use('todos::create', function(socket, done){
// Exposing a request property to services and hooks
socket.request.feathers.referrer = socket.request.referrer;
done();
});
}));
运行此代码时出现以下错误:
node_modules/primus/index.js:697
throw new PrimusError('The plugin is missing a client or server function', this);
^
我所做的一切都是遵循上述链接的指示。为什么我收到此错误消息?还有什么我想念的?
答案 0 :(得分:1)
通过将package.json文件中的feathers-primus版本升级到2.0.0修复了这个问题,如下所示:
private UriBuilder buildDateParams(UriBuilder builder, FilterDateParams filterDateParams) {
if (filterDateParams != null) {
if (filterDateParams.getDateCreated_gt() != null) {
builder.queryParam("dateCreated_gt", new Object[] { filterDateParams.getDateCreated_gt() });
}
if (filterDateParams.getDateCreated_gte() != null) {
builder.queryParam("dateCreated_gte", new Object[] { filterDateParams.getDateCreated_gte() });
}
if (filterDateParams.getDateCreated_lt() != null) {
builder.queryParam("dateCreated_lt", new Object[] { filterDateParams.getDateCreated_lt() });
}
if (filterDateParams.getDateCreated_lte() != null) {
builder.queryParam("dateCreated_lte", new Object[] { filterDateParams.getDateCreated_lte() });
}
if (filterDateParams.getLastUpdated_gt() != null) {
builder.queryParam("lastUpdated_gt", new Object[] { filterDateParams.getLastUpdated_gt() });
}
if (filterDateParams.getLastUpdated_gte() != null) {
builder.queryParam("lastUpdated_gte", new Object[] { filterDateParams.getLastUpdated_gte() });
}
if (filterDateParams.getLastUpdated_lt() != null) {
builder.queryParam("lastUpdated_lt", new Object[] { filterDateParams.getLastUpdated_lt() });
}
if (filterDateParams.getLastUpdated_lte() != null) {
builder.queryParam("lastUpdated_lte", new Object[] { filterDateParams.getLastUpdated_lte() });
}
if (filterDateParams.getStartDate_gt() != null) {
builder.queryParam("startDate_gt", new Object[] { filterDateParams.getStartDate_gt() });
}
if (filterDateParams.getStartDate_gte() != null) {
builder.queryParam("startDate_gte", new Object[] { filterDateParams.getStartDate_gte() });
}
if (filterDateParams.getStartDate_lt() != null) {
builder.queryParam("startDate_lt", new Object[] { filterDateParams.getStartDate_lt() });
}
if (filterDateParams.getStartDate_lte() != null) {
builder.queryParam("startDate_lte", new Object[] { filterDateParams.getStartDate_lte() });
}
if (filterDateParams.getEndDate_gt() != null) {
builder.queryParam("endDate_gt", new Object[] { filterDateParams.getEndDate_gt() });
}
if (filterDateParams.getEndDate_gte() != null) {
builder.queryParam("endDate_gte", new Object[] { filterDateParams.getEndDate_gte() });
}
if (filterDateParams.getEndDate_lt() != null) {
builder.queryParam("endDate_lt", new Object[] { filterDateParams.getEndDate_lt() });
}
if (filterDateParams.getEndDate_lte() != null) {
builder.queryParam("endDate_lte", new Object[] { filterDateParams.getEndDate_lte() });
}
}
return builder;
}