Guest User

Untitled

a guest
Jan 19th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. public void sendReply(String message)
  2. {
  3.  
  4. db.open();
  5. long frmUserId=ConstantValues.myUserId;
  6. db.insertNewChat(thisPostId, message, frmUserId, ConstantValues.isWebsiteReachable);
  7. db.close();
  8. String frmUserName=ConstantValues.myUserName;
  9. chatAdapter.add(new ChatMessage(false, message, frmUserName, ConstantValues.isWebsiteReachable));
  10. chatAdapter.notifyDataSetChanged();
  11. if (ConstantValues.isWebsiteReachable) {
  12. sendPostReply(message);
  13. }
  14. }
  15.  
  16. private boolean sendPostReply(String textMessage){
  17. MyChat chat = new MyChat();
  18. chat.chatMessage=textMessage;
  19. chat.postedBy = ConstantValues.myUserId;
  20. chat.postId = thisPostId;
  21. chat.postedAt= Calendar.getInstance().getTime().toString();
  22.  
  23. Gson gson = new Gson();
  24. String chatBody = gson.toJson(chat);
  25. String node = "node_p_"+thisPostId;
  26. CharSequence sq ="<chat xmlns='pubsub:cues'>"+chatBody+"</chat>";
  27. ActivityHome.getmService().xmpp.publishToPubSubNode(node,sq);
  28. Log.i("send message ", ": message : " + textMessage+" char sequence =:: "+sq);
  29. return true;
  30. }
Add Comment
Please, Sign In to add comment