biflora
v0.2.0
Published
Web application framework on WebSocket.
Downloads
1
Readme
biflora
Install
$ npm install --save biflora
Usage
Server Side
var express = require('express'),
app = express();
var server = require('http').Server(app);
var biflora = require('biflora');
var main = new yourMainObjectClass();
var backendApis = {
// custom API
'api1': function( data, callback, main, biflora ){
callback('result1');
} ,
// custom API
'api2': function( data, callback, main, biflora ){
callback('result2');
} ,
// API name "disconnect" has been reserved.
// Fired on user disconnection.
'disconnect': function( data, callback, main, biflora ){
console.log('USER DISCONNECT');
console.log('-- disconnected user info:', data);
}
};
// middleware - biflora resources
app.use( biflora.clientLibs() );
biflora.setupWebSocket(server, backendApis, main);
// middleware
app.use( function(req, res, next){
/* your application here */
} );
server.listen( 3000, function(){
console.log('message: server-standby');
} );
Client Side
<!-- socket.io -->
<script src="/socket.io/socket.io.js" type="text/javascript"></script>
<!-- biflora -->
<script src="/biflora/biflora.js" type="text/javascript"></script>
<script type="text/javascript">
var socket = this.socket = window.biflora
.createSocket(
new yourMainObjectClass(),
io,
{
// custom API
'api1': function( data, callback, main, biflora ){
callback('result1');
},
// custom API
'api2': function( data, callback, main, biflora ){
callback('result2');
}
}
)
;
</script>
ライセンス - License
Copyright (c)2016 Tomoya Koyanagi, and Passiful Project MIT License https://opensource.org/licenses/mit-license.php
作者 - Author
- Tomoya Koyanagi [email protected]
- website: http://www.pxt.jp/
- Twitter: @tomk79 http://twitter.com/tomk79/