(socketId, value)
| 62 | |
| 63 | // action functions |
| 64 | var sendResponse = function(socketId, value) { |
| 65 | var contentType = "text/plain"; |
| 66 | var contentLength = encodeURI(value).split(/%..|./).length - 1;; |
| 67 | var header = stringToUint8Array( |
| 68 | "HTTP/1.0 200 OK\nAccess-Control-Allow-Origin: *\nContent-length: " + |
| 69 | contentLength + "\nContent-type:" + contentType + "\n\n"); |
| 70 | var content = stringToUint8Array(value) |
| 71 | var outputBuffer = new ArrayBuffer(header.byteLength + contentLength); |
| 72 | |
| 73 | var view = new Uint8Array(outputBuffer) |
| 74 | view.set(header, 0); |
| 75 | view.set(stringToUint8Array(value), header.byteLength); |
| 76 | socket.write(socketId, outputBuffer, function(writeInfo) { |
| 77 | socket.destroy(socketId); |
| 78 | }); |
| 79 | }; |
| 80 | |
| 81 | var readFromSocket = function(socketId) { |
| 82 |
no test coverage detected