Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

changed README and added a "how to use weasel"

  • Loading branch information...
commit d7dd8a984b8dcfd9763524ab848ad0582cacd6aa 1 parent 16d9e30
Florian Strauss authored
Showing with 60 additions and 4 deletions.
  1. +60 −4 README.md
View
64 README.md
@@ -1,13 +1,13 @@
Weasel - a command based websocket application framework on node.js
============================================
-Weasel provides a command based websocket application framework for rapid
-development.
+Weasel provides a command based websocket application framework for real-time applications
+like chats, games and other high performance server/client problems.
- supports for a variety of transports (websockets, flashsockets, XHR Polling) with the help from socket.io-node.
- simple command based communication between server and client.
- - ´javascript´ on server and client side
- - integrated document based database ´mongodb´ (soon!)
+ - javascript on server and client side
+ - integrated document based database mongodb
Requirements
------------
@@ -37,6 +37,62 @@ How to run the demo
and point your browser to http://localhost:8080. In addition to 8080,
if the transport `flashsocket` is enabled, a server will be initialized to listen to requests on the port 843.
+How to use weasel
+-------------------
+
+/server.js
+
+ var weasel = require('../lib/weasel.server');
+
+ var Example = new weasel.Server().listen(8080);
+
+/app/controllers/UserController.js
+
+ Controller('User', {
+
+ /**
+ * a simple chat command
+ *
+ * Can be called from the client with 'user/chat'
+ *
+ * @param {Server} server the weasel server instance
+ * @param {Client} client the current client who request this command
+ * @param {Object} requested params eg. params.message
+ */
+ chat: function(server, client, params) {
+
+ /**
+ * clientArray is a array of client who get the response
+ * responseParams are the response params
+ * this.response(clientArray, responseParams)
+ */
+ this.response(server.clients,{
+ message: params.message;
+ })
+ }
+ })
+
+/app/public/index.html
+ <html>
+ <head>
+ <!--
+ You dont have to include these files in the public folder.
+ -->
+ <script type="text/javascript" src="/server/vendor/socket.io/socket.io.js"> </script>
+ <script type="text/javascript" src="/server/weasel.client.js"> </script>
+ </head>
+ <body>
+
+ Weasel.subscribe('user/chat', function(params){
+ console.log('Called by another conected client:' +params.message);
+ })
+ Weasel.ready(function() {
+ Weasel.command('user/chat', {message: 'test'}, function(params) {
+ console.log(params.message);
+ })
+ })
+ </body>
+ </html>
ToDos
Please sign in to comment.
Something went wrong with that request. Please try again.