diff options
author | Kai Koehne <kai.koehne@qt.io> | 2017-08-28 16:31:05 +0200 |
---|---|---|
committer | Kai Koehne <kai.koehne@qt.io> | 2017-09-08 15:31:30 +0000 |
commit | dd04d74769e1859d571de7c4f2e88cb85a227ab9 (patch) | |
tree | eac49cc7c3b3cb0b2f47c0d0bccf4d1888fb4649 /examples/webchannel/chatclient-qml/qmlchatclient.qml | |
parent | 13294ce605751babad0687e63c033436d129e3d2 (diff) | |
download | qtwebchannel-dd04d74769e1859d571de7c4f2e88cb85a227ab9.tar.gz |
Examples: beautify JavaScript snippets
Change-Id: I3499bfa49e79ed3664d020f7de0e691afeb15a86
Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
Diffstat (limited to 'examples/webchannel/chatclient-qml/qmlchatclient.qml')
-rw-r--r-- | examples/webchannel/chatclient-qml/qmlchatclient.qml | 58 |
1 files changed, 30 insertions, 28 deletions
diff --git a/examples/webchannel/chatclient-qml/qmlchatclient.qml b/examples/webchannel/chatclient-qml/qmlchatclient.qml index abb0ea9..ebca1eb 100644 --- a/examples/webchannel/chatclient-qml/qmlchatclient.qml +++ b/examples/webchannel/chatclient-qml/qmlchatclient.qml @@ -80,34 +80,36 @@ ApplicationWindow { } property var onmessage; - onStatusChanged: if (socket.status == WebSocket.Error) { - console.error("Error: " + socket.errorString) - } else if (socket.status == WebSocket.Closed) { - messageBox.text += "\nSocket closed" - } else if (socket.status == WebSocket.Open) { - //open the webchannel with the socket as transport - new WebChannel.QWebChannel(socket, function(ch) { - root.channel = ch; - - //connect to the changed signal of the userList property - ch.objects.chatserver.userListChanged.connect(function(args) { - userlist.text = ''; - ch.objects.chatserver.userList.forEach(function(user) { - userlist.text += user + '\n'; - }); - }); - //connect to the newMessage signal - ch.objects.chatserver.newMessage.connect(function(time, user, message) { - chat.text = chat.text + "[" + time + "] " + user + ": " + message + '\n'; - }); - //connect to the keep alive signal - ch.objects.chatserver.keepAlive.connect(function(args) { - if (loginName.text !== '') - //and call the keep alive response method as an answer - ch.objects.chatserver.keepAliveResponse(loginName.text) - }); - }); - } + onStatusChanged: { + if (socket.status === WebSocket.Error) { + console.error("Error: " + socket.errorString); + } else if (socket.status === WebSocket.Closed) { + messageBox.text += "\nSocket closed"; + } else if (socket.status === WebSocket.Open) { + //open the webchannel with the socket as transport + new WebChannel.QWebChannel(socket, function(ch) { + root.channel = ch; + + //connect to the changed signal of the userList property + ch.objects.chatserver.userListChanged.connect(function(args) { + userlist.text = ''; + ch.objects.chatserver.userList.forEach(function(user) { + userlist.text += user + '\n'; + }); + }); + //connect to the newMessage signal + ch.objects.chatserver.newMessage.connect(function(time, user, message) { + chat.text = chat.text + "[" + time + "] " + user + ": " + message + '\n'; + }); + //connect to the keep alive signal + ch.objects.chatserver.keepAlive.connect(function(args) { + if (loginName.text !== '') + //and call the keep alive response method as an answer + ch.objects.chatserver.keepAliveResponse(loginName.text); + }); + }); + } + } } GridLayout { |