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

Method onConnection

managementAgent.js:82–114  ·  view source on GitHub ↗
(socket, request)

Source from the content-addressed store, hash-verified

80 }
81
82 onConnection(socket, request) {
83 function hearthbeat() {
84 this.isAlive = true;
85 }
86 logger.info('client connected to watch route', {
87 ip: request.connection.remoteAddress,
88 });
89
90 /* eslint-disable no-param-reassign */
91 socket.isAlive = true;
92 socket.on('pong', hearthbeat.bind(socket));
93
94 if (socket.readyState !== socket.OPEN) {
95 logger.error('client socket not in ready state', {
96 state: socket.readyState,
97 client: socket._socket._peername,
98 });
99 return;
100 }
101
102 const msg = {
103 messageType: managementAgentMessageType.NEW_OVERLAY,
104 payload: this.loadedOverlay,
105 };
106 socket.send(JSON.stringify(msg), error => {
107 if (error) {
108 logger.error('failed to send remoteOverlay to client', {
109 error,
110 client: socket._socket._peername,
111 });
112 }
113 });
114 }
115
116 onListening() {
117 logger.info('websocket server listening',

Callers

nothing calls this directly

Calls 3

infoMethod · 0.80
errorMethod · 0.80
sendMethod · 0.80

Tested by

no test coverage detected