search

Home  >  Q&A  >  body text

angular.js - angularjs uses websocket for chat function but cannot send messages

Click the send button to trigger, the message cannot be sent
controller:

var ws = new WebSocket("ws://121.43.160.149:8890/ws/phone/message");
        var chatMessage = {
            messagetxt : $scope.mmm,
            touserid : thisId
        }
        var sMsg = {
            messageContext : chatMessage,
            messageType : "friendChat"
        }
        console.log(sMsg);
        ws.onopen = function(e){
            ws.send(JSON.stringify(sMsg));
        }

How should I use webSocket in angularjs?

仅有的幸福仅有的幸福2810 days ago592

reply all(1)I'll reply

  • 为情所困

    为情所困2017-05-15 17:07:37

    Just look at the information on github, it has detailed instructions
    https://github.com/AngularCla...

    reply
    0
  • Cancelreply