Create JavaScript's Thread class

This commit is contained in:
Dmitriy Simushev 2012-10-05 11:29:00 +00:00
parent 5ff3a7656d
commit ec5ba068bb
2 changed files with 83 additions and 0 deletions

View File

@ -0,0 +1,8 @@
/*
This file is part of Mibew Messenger project.
http://mibew.org
Copyright (c) 2005-2011 Mibew Messenger Community
License: http://mibew.org/license.php
*/
var Thread=function(a){this.threadid=a.threadid||0;this.token=a.token||0;this.lastid=a.lastid||0;this.user=a.user||!1};Thread.prototype.KIND_USER=1;Thread.prototype.KIND_AGENT=2;Thread.prototype.KIND_FOR_AGENT=3;Thread.prototype.KIND_INFO=4;Thread.prototype.KIND_CONN=5;Thread.prototype.KIND_EVENTS=6;Thread.prototype.KIND_AVATAR=7;

View File

@ -0,0 +1,75 @@
/**
* @preserve This file is part of Mibew Messenger project.
* http://mibew.org
*
* Copyright (c) 2005-2011 Mibew Messenger Community
* License: http://mibew.org/license.php
*/
/**
* Create an instance of thread
* @constructor
*/
var Thread = function(options) {
/**
* Id of the thread
* @type Number
*/
this.threadid = options.threadid || 0;
/**
* Thread's token. Uses for verify thread
* @type Number
*/
this.token = options.token || 0;
/**
* Last message id received by the thread
* @type Number
*/
this.lastid = options.lastid || 0;
/**
* Indicates if thread dispalys for user or for agent.
*
* Boolean true stands for user and boolean false stands for agent.
* @type Boolean
*/
this.user = options.user || false;
}
/** Message kinds section */
/**
* Message sent by user
*/
Thread.prototype.KIND_USER = 1;
/**
* Message sent by operator
*/
Thread.prototype.KIND_AGENT = 2;
/**
* Hidden system message to operator
*/
Thread.prototype.KIND_FOR_AGENT = 3;
/**
* System messages for user and operator
*/
Thread.prototype.KIND_INFO = 4;
/**
* Message for user if operator have connection problems
*/
Thread.prototype.KIND_CONN = 5;
/**
* System message about some events (like rename).
*/
Thread.prototype.KIND_EVENTS = 6;
/**
* Message with operators avatar
*
* This kind of message leaved only for compatibility with core
*/
Thread.prototype.KIND_AVATAR = 7;
/** End of Message kinds section */