Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add syntax highlighting to README code sample #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 48 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,54 +14,54 @@ Status: beta (expected to work, but not tested in production yet).

See example/dummy-server.js for a runnable version of this code:

var fs = require('fs');
var Path = require('path');
var LRWebSocketServer = require('livereload-server');

// id, name, version identifies your app;
// protocols specifies the versions of subprotocols you support
var server = new LRWebSocketServer({ id: "com.example.acme", name: "Acme", version: "1.0", protocols: { monitoring: 7, saving: 1 } });

server.on('connected', function(connection) {
console.log("Client connected (%s)", connection.id);
});

server.on('disconnected', function(connection) {
console.log("Client disconnected (%s)", connection.id);
});

server.on('command', function(connection, message) {
console.log("Received command %s: %j", message.command, message);
});

server.on('error', function(err, connection) {
console.log("Error (%s): %s", connection.id, err.message);
});

server.on('livereload.js', function(request, response) {
console.log("Serving livereload.js.");
fs.readFile(Path.join(__dirname, 'res/livereload.js'), 'utf8', function(err, data) {
if (err) throw err;

response.writeHead(200, {'Content-Length': data.length, 'Content-Type': 'text/javascript'});
response.end(data);
});
});

server.on('httprequest', function(url, request, response) {
response.writeHead(404);
response.end()
});

server.listen(function(err) {
if (err) {
console.error("Listening failed: %s", err.message);
return;
}
console.log("Listening on port %d.", server.port);
});


```js
var fs = require('fs');
var Path = require('path');
var LRWebSocketServer = require('livereload-server');

// id, name, version identifies your app;
// protocols specifies the versions of subprotocols you support
var server = new LRWebSocketServer({ id: "com.example.acme", name: "Acme", version: "1.0", protocols: { monitoring: 7, saving: 1 } });

server.on('connected', function(connection) {
console.log("Client connected (%s)", connection.id);
});

server.on('disconnected', function(connection) {
console.log("Client disconnected (%s)", connection.id);
});

server.on('command', function(connection, message) {
console.log("Received command %s: %j", message.command, message);
});

server.on('error', function(err, connection) {
console.log("Error (%s): %s", connection.id, err.message);
});

server.on('livereload.js', function(request, response) {
console.log("Serving livereload.js.");
fs.readFile(Path.join(__dirname, 'res/livereload.js'), 'utf8', function(err, data) {
if (err) throw err;

response.writeHead(200, {'Content-Length': data.length, 'Content-Type': 'text/javascript'});
response.end(data);
});
});

server.on('httprequest', function(url, request, response) {
response.writeHead(404);
response.end()
});

server.listen(function(err) {
if (err) {
console.error("Listening failed: %s", err.message);
return;
}
console.log("Listening on port %d.", server.port);
});
```

## License

Expand Down