Added models

This commit is contained in:
Mattias Erming 2014-03-04 11:40:27 -08:00
parent 9cdcfdefd2
commit 156a8748ef
4 changed files with 151 additions and 3 deletions

View file

@ -5,7 +5,10 @@
Hello, world.
<script src="//code.jquery.com/jquery-2.1.0.min.js"></script>
<script src="/socket.io/socket.io.js"></script>
<script src="/js/models.js"></script>
<script src="/js/client.js"></script>
<script>

View file

@ -24,7 +24,7 @@ function Client() {
.on("init", function(data) { self.init(data); });
/**
* Setup new socket connections.
* Set up new socket connections.
*
* @param {String} data
* @public

142
client/js/models.js Normal file
View file

@ -0,0 +1,142 @@
(function(exports) {
/**
* Declare the namespaces.
*
* @namespace
*/
var models =
typeof window === "undefined" ? exports
: window.models = {};
/**
* Network model.
*
* @public
*/
models.Network = function() {
/**
* The network address.
*
* @type {String}
* @public
*/
this.address = "";
/**
* List of channels.
*
* @type {Array<Channel>}
* @public
*/
this.channels = [];
};
/**
* Channel model.
*
* @public
*/
models.Channel = function() {
/**
* The channel name.
*
* @type {String}
* @public
*/
this.name = "";
/**
* The current channel topic.
*
* @type {String}
* @public
*/
this.topic = "";
/**
* List of users.
*
* @type {Array<User>}
* @public
*/
this.users = [];
/**
* List of messages.
*
* @type {Array<Message>}
* @public
*/
this.messages = [];
};
/**
* User model.
*
* @public
*/
models.User = function() {
/**
* The user name.
*
* @type {String}
* @public
*/
this.name = "";
};
/**
* Message model.
*
* @public
*/
models.Message = function() {
/**
* The timestamp.
*
* @type {String}
* @public
*/
this.time = "";
/**
* The content of the message.
*
* @type {String}
* @public
*/
this.text = "";
/**
* The author of the message.
*
* @type {String}
* @public
*/
this.user = "";
};
})(this);

View file

@ -5,6 +5,9 @@
var connect = require("connect");
var io = require("socket.io");
// Local library.
var models = require("../client/js/models.js");
/**
* Export module.
*/
@ -30,7 +33,7 @@ function Server() {
/**
* Start the server and listen to the specified port.
*
* @param {Number} port
* @param {Int} port
* @public
*/
@ -51,7 +54,7 @@ function Server() {
*/
this.init = function(socket) {
socket.emit("init", "Hello, world.");
// ..
};
};