Sfoglia il codice sorgente

Merge pull request #151 from overleaf/jpa-perf-parser

[perf] add a few short cuts to the packet decoding
Jakob Ackermann 6 anni fa
parent
commit
5b85e0154d
1 ha cambiato i file con 10 aggiunte e 0 eliminazioni
  1. 10 0
      services/real-time/socket.io.patch.js

+ 10 - 0
services/real-time/socket.io.patch.js

@@ -47,3 +47,13 @@ function patchedFrameHandler(opcode, str) {
   }
   return outputBuffer;
 }
+
+const parser = require('socket.io/lib/parser')
+const decodePacket = parser.decodePacket
+parser.decodePacket = function (data) {
+  if (typeof data !== 'string') return {}
+  const firstColon = data.indexOf(':')
+  if (firstColon === -1) return {}
+  if (data.indexOf(':', firstColon + 1) === -1) return {}
+  return decodePacket(data)
+}