chat.js 951 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /* Chat plugin for collaboration, need to list available users.
  2. , and notify when the message comes in by flashing chat "Open" link*/
  3. {
  4. 'interfaces' : [{'method':'POST', 'url=':'/chat'}],
  5. 'localcontext' : {'messages':[]},
  6. 'csworker' :
  7. function(resp,method,uri,reqData,wcontext)
  8. {
  9. var self = this;
  10. _do.chain(
  11. [__wHttpReq(method, uri+'?wid='+wcontext.__aswid, reqData)])(
  12. function()
  13. {
  14. self.localcontext.messages.push(reqData);
  15. __postMessage(
  16. {'statusCode':200,
  17. 'changelog':
  18. [{'op':'CHAT',
  19. 'text':self.localcontext.messages.pop()}],
  20. 'sequence#':__sequenceNumber(),
  21. 'respIndex':resp});
  22. },
  23. function(err) {__postInternalErrorMsg(resp,err);}
  24. );
  25. },
  26. 'asworker' :
  27. function(resp,method,uri,reqData,wcontext)
  28. {
  29. __postMessage(
  30. {'statusCode':200,
  31. 'changelog':
  32. [],
  33. 'sequence#':__sequenceNumber(),
  34. 'respIndex':resp});
  35. }
  36. }