chat_session_typing.rb 700 B

12345678910111213141516171819202122232425262728293031323334
  1. class Sessions::Event::ChatSessionTyping < Sessions::Event::ChatBase
  2. def run
  3. return super if super
  4. return if !check_chat_session_exists
  5. chat_session = current_chat_session
  6. user_id = nil
  7. if @session
  8. user_id = @session['id']
  9. end
  10. message = {
  11. event: 'chat_session_typing',
  12. data: {
  13. session_id: chat_session.session_id,
  14. user_id: user_id,
  15. },
  16. }
  17. # send to participents
  18. chat_session.send_to_recipients(message, @client_id)
  19. # send chat_session_init to agent
  20. {
  21. event: 'chat_session_typing',
  22. data: {
  23. session_id: chat_session.session_id,
  24. self_written: true,
  25. },
  26. }
  27. end
  28. end