-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClient.js
41 lines (34 loc) · 1.18 KB
/
Client.js
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
/*
#Programmer: Matt /AuthoredEntropy
im pretty sure this isnt used anywhere, but just incase it is I will leave this file here
*/
// creating a custom socket client and connecting it....
/**@deprecated this was added in early development, i don't think it is used */
module.exports = function ClientConnect(player) {
var net = require('net');
const prompt = require('prompt-sync')();
var client = new net.Socket();
const IpAdress = prompt('What Ipv4 address do you want to connect to? (\"localhost\" if you are on a lan server): ');
const port = prompt('What port do you want to connect to? ');
client.connect({
port:port,
host:IpAdress
});
client.on('connect',function(){
console.log('Client: connection established with server');
console.log('---------client details -----------------');
var address = client.address();
var port = address.port;
var family = address.family;
var ipaddr = address.address;
// writing data to server
client.write('newPlayer: ' + JSON.stringify(player));
});
client.setEncoding('utf8');
// client.on('data',function(data){
// //console.log('Data from server:' + data);
// });
setTimeout(function(){
client.end('Bye bye server');
},5000);
}