var onMessage = {
initMessage: function(data, socket) {
if (data.status !== 1) {
views.disableSend();
return views.appendError({msg: data.message ? data.message : data.msg});
}
$.each(data.message_info, function() {
var dt = $.parseJSON(this);
if (dt.message_type === 1) {
$.extend(dt, {role: 'other'});
views.appendPriceResult(dt);
} else {
$.extend(dt, {role: 'me'});
views.appendMsg(dt);
}
});
},
join: function(data, socket) {
if (data.status !== 1) {
this.appendError({msg: data.msg});
} else {
views.on('sendMsgCb', function(price, reason) {
socket.send(JSON.stringify({
typ: 'price',
price: price,
message: ' + price + ' + reason
}));
});
views.on('createOrderCb', function() {
socket.send(JSON.stringify({
typ: 'createOrder'
}));
});
views.on('cancelOrderCb', function() {
socket.send(JSON.stringify({
typ: 'cancelOrder'
}));
});
initMessage: function(data, socket) {
if (data.status !== 1) {
views.disableSend();
return views.appendError({msg: data.message ? data.message : data.msg});
}
$.each(data.message_info, function() {
var dt = $.parseJSON(this);
if (dt.message_type === 1) {
$.extend(dt, {role: 'other'});
views.appendPriceResult(dt);
} else {
$.extend(dt, {role: 'me'});
views.appendMsg(dt);
}
});
},
join: function(data, socket) {
if (data.status !== 1) {
this.appendError({msg: data.msg});
} else {
views.on('sendMsgCb', function(price, reason) {
socket.send(JSON.stringify({
typ: 'price',
price: price,
message: ' + price + ' + reason
}));
});
views.on('createOrderCb', function() {
socket.send(JSON.stringify({
typ: 'createOrder'
}));
});
views.on('cancelOrderCb', function() {
socket.send(JSON.stringify({
typ: 'cancelOrder'
}));
});