Files
ai-course/node_modules/websocket-extensions/lib/pipeline/index.js
KQL ce6aa207e9 fix: 修复图片路径以适配GitHub Pages base path
- 将所有图片路径从绝对路径改为使用 process.env.PUBLIC_URL
- 修复 HomePage.tsx 中所有图片引用
- 修复 CoursePage.tsx 中所有图片引用
- 确保图片在 GitHub Pages 上正确加载

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-04 09:24:45 +08:00

48 lines
1.4 KiB
JavaScript

'use strict';
var Cell = require('./cell'),
Pledge = require('./pledge');
var Pipeline = function(sessions) {
this._cells = sessions.map(function(session) { return new Cell(session) });
this._stopped = { incoming: false, outgoing: false };
};
Pipeline.prototype.processIncomingMessage = function(message, callback, context) {
if (this._stopped.incoming) return;
this._loop('incoming', this._cells.length - 1, -1, -1, message, callback, context);
};
Pipeline.prototype.processOutgoingMessage = function(message, callback, context) {
if (this._stopped.outgoing) return;
this._loop('outgoing', 0, this._cells.length, 1, message, callback, context);
};
Pipeline.prototype.close = function(callback, context) {
this._stopped = { incoming: true, outgoing: true };
var closed = this._cells.map(function(a) { return a.close() });
if (callback)
Pledge.all(closed).then(function() { callback.call(context) });
};
Pipeline.prototype._loop = function(direction, start, end, step, message, callback, context) {
var cells = this._cells,
n = cells.length,
self = this;
while (n--) cells[n].pending(direction);
var pipe = function(index, error, msg) {
if (index === end) return callback.call(context, error, msg);
cells[index][direction](error, msg, function(err, m) {
if (err) self._stopped[direction] = true;
pipe(index + step, err, m);
});
};
pipe(start, null, message);
};
module.exports = Pipeline;