0

我正在尝试在 nodejs 中制作某种“teamspeak3 服务器库”,但我不明白客户端如何与服务器通信。

以下是我在连接时收到的消息: 连接上的消息

我不明白如何翻译这些消息。

我的代码:

const udp = require('dgram');

const server = udp.createSocket('udp4');

server.on('error',function(error){
    console.log('Error: ' + error);
});

server.on('message',function(msg,info){
    console.log('Data received from client : ' + msg.toString());
    console.log('Received %d bytes from %s:%d\n',msg.length, info.address, info.port);
});

//emits when socket is ready and listening for datagram msgs
server.on('listening',function(){
    var address = server.address();
    var port = address.port;
    var family = address.family;
    var ipaddr = address.address;
    console.log('Server is listening at port' + port);
    console.log('Server ip :' + ipaddr);
    console.log('Server is IP4/IP6 : ' + family);
});

server.on('close',function(){
    console.log('Socket is closed !');
});

server.bind(2048);

在此先感谢您的帮助!

更新:我仍然没有找到任何解决方案。

4

0 回答 0