(channelId, payload)
| 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) { |
no test coverage detected