This repository was archived by the owner on May 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.js
More file actions
55 lines (49 loc) · 1.21 KB
/
client.js
File metadata and controls
55 lines (49 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Connect to aardmud by default.
var tcpClient;
var reader;
function starRuntime(){
var host = '127.0.0.1';
var port = 2000;
connect(host, port);
}
/**
* Connects to a host and port
*
* @param {String} host The remote host to connect to
* @param {Number} port The port to connect to at the remote host
*/
function connect(host, port) {
tcpClient = new TcpClient(host, port);
tcpClient.connect(function() {
console.log('Connected to ' + host + ':' + port );
tcpClient.addResponseListener(function(data) {
console.log(data);
});
});
}
/**
* Send message
* @param {[type]} msg [description]
* @return {[type]} [description]
*/
function sendMsg(msg){
tcpClient.sendMessage(msg, function() {
tcpClient.addResponseListener(function(data) {
reader = data;
console.log(reader);
});
});
}
//
//jquery boy
//
$(document).on("click", "#login", function(){
var username = $('#username').val();
var pwd = $('#password').val();
console.log(username+pwd);
starRuntime();
sendMsg('AUTHCONN');
sendMsg('USER:'+username);
sendMsg('PASSWORD:'+pwd);
$('#status').text(reader);
})