Skip to content

Commit

Permalink
Added PalaceRoom.js and PalaceChatRecord.js
Browse files Browse the repository at this point in the history
started handling talk and xtalk packets
  • Loading branch information
mheiniger committed Apr 29, 2013
1 parent ea5cbf1 commit f6c59df
Show file tree
Hide file tree
Showing 5 changed files with 157 additions and 12 deletions.
25 changes: 13 additions & 12 deletions PalaceClient/PalaceClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ function PalaceClient() // extends EventDispatcher
//importClass("palace.model.PalaceLooseProp");
//importClass("palace.model.PalaceProp");
//importClass("palace.model.PalacePropStore");
//importClass("palace.model.PalaceRoom");
var PalaceRoom = require("./palace/model/PalaceRoom");
importClass("palace.model.PalaceServerInfo");

var PalaceUser = require("./palace/model/PalaceUser");
//importClass("palace.record.PalaceChatRecord");
var PalaceChatRecord = require("./palace/record/PalaceChatRecord");
//importClass("palace.record.PalaceDrawRecord");
//importClass("palace.view.PalaceSoundPlayer");
//
Expand Down Expand Up @@ -1030,9 +1030,10 @@ function PalaceClient() // extends EventDispatcher
case IncomingMessageTypes.USER_PROP:
handleUserProp(buffer, size, p);
break;
case IncomingMessageTypes.USER_DESCRIPTION: // (prop)
handleUserDescription(buffer, size, p);
break;
// todo mhe: later
// case IncomingMessageTypes.USER_DESCRIPTION: // (prop) usrD
// handleUserDescription(buffer, size, p);
// break;
//
// case IncomingMessage.USER_PROP:
// handleUserProp(buffer, size, p);
Expand Down Expand Up @@ -2010,7 +2011,7 @@ function PalaceClient() // extends EventDispatcher

// Unencrypted TALK message
function handleReceiveTalk(buffer, size, referenceId) {
var messageBytes = new ByteArray();
// var messageBytes = new ByteArray();
var message;
if (utf8) {
message = buffer.readUTFBytes(size-1);
Expand All @@ -2021,7 +2022,7 @@ function PalaceClient() // extends EventDispatcher
buffer.readByte();
if (referenceId == 0) {
currentRoom.roomMessage(message);
// trace("Got Room Message: " + message);
trace("Got Room Message: " + message);
}
else {
if (message.length > 0) {
Expand All @@ -2031,11 +2032,11 @@ function PalaceClient() // extends EventDispatcher
0,
message
);
chatRecord.eventHandlers = palaceController.getHotspotEvents(IptEventHandler.TYPE_INCHAT);
chatQueue.push(chatRecord);
//chatRecord.eventHandlers = palaceController.getHotspotEvents(IptEventHandler.TYPE_INCHAT);
//chatQueue.push(chatRecord);
processChatQueue();
}
// trace("Got talk from userID " + referenceId + ": " + message);
trace("Got talk from userID " + referenceId + ": " + message);
}
}

Expand Down Expand Up @@ -2072,8 +2073,8 @@ function PalaceClient() // extends EventDispatcher

function handleReceiveXTalk(buffer, size, referenceId) {
var length = buffer.readShort();
// trace("XTALK. Size: " + size + " Length: " + length);
var messageBytes = new ByteArray();
trace("XTALK. Size: " + size + " Length: " + length);
var messageBytes = new ByteArray(length-3);
buffer.readBytes(messageBytes, 0, length-3); // Length field lies
buffer.readByte(); // Last byte is unnecessary?
var message = PalaceEncryption.getInstance().decrypt(messageBytes, utf8);
Expand Down
33 changes: 33 additions & 0 deletions PalaceClient/palace/model/PalaceRoom.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
This file is part of OpenPalace.
OpenPalace is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenPalace is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenPalace. If not, see <http://www.gnu.org/licenses/>.
*/

package net.codecomposer.palace.model
{
[Bindable]
public class PalaceRoom
{
public var name:String;
public var id:int;
public var flags:int;
public var userCount:int;

public function PalaceRoom()
{
}

}
}
40 changes: 40 additions & 0 deletions PalaceClient/palace/model/PalaceRoom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
This file is part of OpenPalace.
OpenPalace is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenPalace is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenPalace. If not, see <http://www.gnu.org/licenses/>.
*/

//package net.codecomposer.palace.model
//{
/* \[Bindable\] */
function PalaceRoom()
{
this.constants = {};
var name = this.name/* :String */;
var id = this.id/* :int */;
var flags = this.flags/* :int */;
var userCount = this.userCount/* :int */;

var PalaceRoom = this.PalaceRoom = function()
{
}

}
//}

module.exports = PalaceRoom;
var PalaceRoomVar = new PalaceRoom();
for (name in PalaceRoomVar.constants) {
module.exports[name] = PalaceRoomVar.constants[name];
}
32 changes: 32 additions & 0 deletions PalaceClient/palace/record/PalaceChatRecord.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package net.codecomposer.palace.record
{
import org.openpalace.iptscrae.IptTokenList;

public class PalaceChatRecord
{
public static const INCHAT:int = 0;
public static const OUTCHAT:int = 1;

public var direction:int;
public var whochat:int;
public var whotarget:int;
public var chatstr:String;
public var whisper:Boolean;
public var eventHandlers:Vector.<IptTokenList>;
private var _originalChatstr:String;

public function PalaceChatRecord(direction:int = INCHAT, whochat:int = 0, whotarget:int = 0, chatstr:String = "", isWhisper:Boolean = false)
{
this.direction = direction;
this.whochat = whochat;
this.whotarget = whotarget;
this.chatstr = chatstr;
this.whisper = isWhisper;
this._originalChatstr = chatstr;
}

public function get originalChatstr():String {
return _originalChatstr;
}
}
}
39 changes: 39 additions & 0 deletions PalaceClient/palace/record/PalaceChatRecord.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//package net.codecomposer.palace.record
//{
// import org.openpalace.iptscrae.IptTokenList;

function PalaceChatRecord()
{
this.constants = {};
var INCHAT = this.constants.INCHAT/* :int */ = 0;
var OUTCHAT = this.constants.OUTCHAT/* :int */ = 1;

var direction = this.direction/* :int */;
var whochat = this.whochat/* :int */;
var whotarget = this.whotarget/* :int */;
var chatstr = this.chatstr/* :String */;
var whisper = this.whisper/* :Boolean */;
var eventHandlers = this.eventHandlers/* :Vector.<IptTokenList> */;
var _originalChatstr/* :String */;

var PalaceChatRecord = this.PalaceChatRecord = function(direction/* :int */ , whochat/* :int */ , whotarget/* :int */ , chatstr/* :String */, isWhisper/* :Boolean */)
{
this.direction = direction || INCHAT;
this.whochat = whochat || 0;
this.whotarget = whotarget || 0;
this.chatstr = chatstr || "";
this.whisper = isWhisper || false;
this._originalChatstr = chatstr;
}

var get_originalChatstr = this.get_originalChatstr = function()/* :String */ {
return _originalChatstr;
}
}
//}

module.exports = PalaceChatRecord;
var PalaceChatRecordVar = new PalaceChatRecord();
for (name in PalaceChatRecordVar.constants) {
module.exports[name] = PalaceChatRecordVar.constants[name];
}

0 comments on commit f6c59df

Please sign in to comment.