Real-time multiplayer game framework for Node.js
To get started using Tycho:
var tycho = require('tycho'),
server = tycho.createServer();
server.listen(3000);
Create a new .html page and add the following to the header:
<script type="text/javascript" src="/socket.io/socket.io.js"></script>
<script type="text/javascript" src="/tycho/tycho.js"></script>
<script type="text/javascript" src="/tycho/message.js"></script>
<script type="text/javascript">
tycho.connect();
</script>
Open a browser and navigate to http://localhost:3000. Your page should load and connect to the tycho server.
Listed below is the full documenation for Tycho.
tycho.createServer([config]) : tycho
Sets the directory that the server will serve files from. Defaults to: The current directory
Sets the maximum number of concurrent connections allowed. Defaults to: 100
Sets the maximum number of concurrent instances allowed. Defaults to: 10
True to specify the names of instances when they are created. If using namedInstances, autoCreateInstances must be set to false. Defaults to: false
True to have the server automatically create new instances. See loadBalance to set the conditions for when a new instance should be created. Defaults to: true
True to have the server automatically assign a new connection to an instance. Defaults to: true
True to have users reconnect to their last instance if they disconnect. Defaults to: true
Set the user-specific objects that should represent instances and connections in an application. The object should be of the form
Defaults to: {}{ connection: [Function], instance: [Function] }
The messaging system that tycho should use internally. A user-defined messaging interface must define a send method with the following signature:
This method must callfunction send(message, connection) { }connection.send(name, data, callback)with the appropriate message name and data when finished. Additionally, a receive method can be defined which will be passed every message sent from the client. The receive method should have the signature:Defaults to: tycho.messagesfunction receive(message, connection) { }
Specify the messages and associated handlers that the server accepts from the client. This can be done in two forms:
In the first case, each route will receive// Basic route setup, all routes defined on connection { route1: function (message, connection) { }, route2: function (message) { }, ... } // Break routes down by destination { connection: { ... }, instance: { ... }, server: { ... } }(message, connection), withthisbeing bound to the connection binding specified in the config. In the second case, each route will receive(message, target), where target is one of server, instance, or connection, depending on where the route was defined.thiswill be bound to the binding specified in the config, or the server object, if the destination is the server. Defaults to: {}
Tycho is licensed under the MIT license. You are free to use Tycho without restriction for both open-source and closed-source applications. See the repository for the full license.