chat_session_typing.rb 874 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. class Sessions::Event::ChatSessionTyping < Sessions::Event::ChatBase
  2. =begin
  3. a agent or customer is typing a chat session message
  4. payload
  5. {
  6. event: 'chat_session_typing',
  7. data: {},
  8. }
  9. return is sent as message back to peer
  10. =end
  11. def run
  12. return super if super
  13. return if !check_chat_session_exists
  14. chat_session = current_chat_session
  15. user_id = nil
  16. if @session
  17. user_id = @session['id']
  18. end
  19. message = {
  20. event: 'chat_session_typing',
  21. data: {
  22. session_id: chat_session.session_id,
  23. user_id: user_id,
  24. },
  25. }
  26. # send to participents
  27. chat_session.send_to_recipients(message, @client_id)
  28. # send chat_session_init to agent
  29. {
  30. event: 'chat_session_typing',
  31. data: {
  32. session_id: chat_session.session_id,
  33. self_written: true,
  34. },
  35. }
  36. end
  37. end