MCPcopy
hub / github.com/scality/cloudserver / receiveChannelData

Function receiveChannelData

lib/management/push.js:148–186  ·  view source on GitHub ↗
(channelId, payload)

Source from the content-addressed store, hash-verified

146 }
147
148 function receiveChannelData(channelId, payload) {
149 let socket = socketsByChannelId[channelId];
150 if (!socket) {
151 socket = net.createConnection(cloudServerPort, cloudServerHost);
152
153 socket.on('data', data => {
154 ws.send(ChannelMessageV0.
155 encodeChannelDataMessage(channelId, data), err =>
156 _logError(err, 'failed to send channel data message',
157 'receiveChannelData'));
158 });
159
160 socket.on('connect', () => {
161 });
162
163 socket.on('drain', () => {
164 });
165
166 socket.on('error', error => {
167 logger.error('failed to connect to S3', {
168 code: error.code,
169 host: error.address,
170 port: error.port,
171 });
172 });
173
174 socket.on('end', () => {
175 socket.destroy();
176 socketsByChannelId[channelId] = null;
177 ws.send(ChannelMessageV0.encodeChannelCloseMessage(channelId),
178 err => _logError(err,
179 'failed to send channel close message',
180 'receiveChannelData'));
181 });
182
183 socketsByChannelId[channelId] = socket;
184 }
185 socket.write(payload);
186 }
187
188 function browserAccessChangeHandler() {
189 if (!_config.browserAccessEnabled) {

Callers 1

startWSManagementClientFunction · 0.85

Calls 6

_logErrorFunction · 0.85
sendMethod · 0.80
errorMethod · 0.80
writeMethod · 0.80

Tested by

no test coverage detected