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. Hello, world.
<script src="//code.jquery.com/jquery-2.1.0.min.js"></script>
<script src="/socket.io/socket.io.js"></script> <script src="/socket.io/socket.io.js"></script>
<script src="/js/models.js"></script>
<script src="/js/client.js"></script> <script src="/js/client.js"></script>
<script> <script>

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