This commit is contained in:
Felix Niklas 2015-11-12 11:44:37 +01:00
parent 3602f4f0ea
commit 789cb15640
3 changed files with 22 additions and 35 deletions

View file

@ -34,6 +34,7 @@ do($ = window.jQuery, window) ->
'': ''
'': ''
'': ''
sessionId: undefined
T: (string, items...) =>
if !@strings[string]
@ -69,8 +70,6 @@ do($ = window.jQuery, window) ->
keydown: @checkForEnter
input: @onInput
@session_id = undefined
if !window.WebSocket
@log 'notice', 'Chat: Browser not supported!'
return
@ -104,16 +103,11 @@ do($ = window.jQuery, window) ->
return if pipe.data.self_written
@onAgentTypingStart()
when 'chat_session_start'
switch pipe.data.state
when 'ok'
@onConnectionEstablished pipe.data.agent
when 'chat_session_init'
switch pipe.data.state
when 'ok'
@onConnectionEstablished pipe.data.agent
when 'queue'
@onQueue pipe.data.position
@session_id = pipe.data.session_id
@onConnectionEstablished pipe.data.agent
@sessionId = pipe.data.session_id
when 'chat_session_queue'
@onQueue pipe.data.position
@sessionId = pipe.data.session_id
when 'chat_session_closed'
@onSessionClosed pipe.data
when 'chat_session_left'
@ -157,7 +151,7 @@ do($ = window.jQuery, window) ->
if !@isTyping
@isTyping = true
@send 'chat_session_typing',
session_id: @session_id
session_id: @sessionId
onTypingEnd: =>
@isTyping = false
@ -195,7 +189,7 @@ do($ = window.jQuery, window) ->
@send 'chat_session_message',
content: message
id: @_messageCount
session_id: @session_id
session_id: @sessionId
receiveMessage: (data) =>
# hide writing indicator
@ -240,7 +234,7 @@ do($ = window.jQuery, window) ->
@isOpen = false
@send 'chat_session_close',
session_id: @session_id
session_id: @sessionId
hide: ->
@el.removeClass('zammad-chat-is-visible')
@ -325,7 +319,7 @@ do($ = window.jQuery, window) ->
@ws.onopen = =>
@log 'debug', 'ws connected'
@send 'chat_status_customer',
session_id: @session_id
session_id: @sessionId
@setAgentOnlineState(true)
@ws.onmessage = @onWebSocketMessage

View file

@ -50,6 +50,8 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments);
'': ''
};
ZammadChat.prototype.sessionId = void 0;
ZammadChat.prototype.T = function() {
var i, item, items, len, string, translation;
string = arguments[0], items = 2 <= arguments.length ? slice.call(arguments, 1) : [];
@ -121,7 +123,6 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments);
keydown: this.checkForEnter,
input: this.onInput
});
this.session_id = void 0;
if (!window.WebSocket) {
this.log('notice', 'Chat: Browser not supported!');
return;
@ -167,20 +168,12 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments);
this.onAgentTypingStart();
break;
case 'chat_session_start':
switch (pipe.data.state) {
case 'ok':
this.onConnectionEstablished(pipe.data.agent);
}
this.onConnectionEstablished(pipe.data.agent);
this.sessionId = pipe.data.session_id;
break;
case 'chat_session_init':
switch (pipe.data.state) {
case 'ok':
this.onConnectionEstablished(pipe.data.agent);
break;
case 'queue':
this.onQueue(pipe.data.position);
this.session_id = pipe.data.session_id;
}
case 'chat_session_queue':
this.onQueue(pipe.data.position);
this.sessionId = pipe.data.session_id;
break;
case 'chat_session_closed':
this.onSessionClosed(pipe.data);
@ -232,7 +225,7 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments);
if (!this.isTyping) {
this.isTyping = true;
return this.send('chat_session_typing', {
session_id: this.session_id
session_id: this.sessionId
});
}
};
@ -271,7 +264,7 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments);
return this.send('chat_session_message', {
content: message,
id: this._messageCount,
session_id: this.session_id
session_id: this.sessionId
});
};
@ -322,7 +315,7 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments);
this.disconnect();
this.isOpen = false;
return this.send('chat_session_close', {
session_id: this.session_id
session_id: this.sessionId
});
};
@ -418,7 +411,7 @@ var bind = function(fn, me){ return function(){ return fn.apply(me, arguments);
return function() {
_this.log('debug', 'ws connected');
_this.send('chat_status_customer', {
session_id: _this.session_id
session_id: _this.sessionId
});
return _this.setAgentOnlineState(true);
};

File diff suppressed because one or more lines are too long