服务器是否可以使用Socket.IO连接到另一个服务器并被视为客户端?
并让它加入房间,收到io.sockets.in('lobby').emit().和更多?
第一台服务器也在监听连接/消息.
嘿布拉德,这是我下面的完整.js应用程序供参考:
var io = require("socket.io").listen(8099);
io.set('log level', 1);
io.sockets.on("connection", function (socket) {
console.log('A Client has Connected to this Server');
//Let Everyone Know I just Joined
socket.broadcast.to('lobby').emit("message",'UC,' + socket.id); // Send to everyone in Room but NOT me
socket.on("message", function (data) {
//Missing code
socket2.send('message,' + data); //Forward Message to Second Server
});
socket.on("disconnect", function (data) {
//Send Notification to Second Server
//Need to figure out later
//Send Notification to Everyone
socket.broadcast.emit("message",'UD,' + socket.id ); //Send to Everyone …Run Code Online (Sandbox Code Playgroud) 我正在尝试将UDP多播数据包发送到:230.185.192.108,以便所有订阅者都会收到.有点卡住了.我相信它正确播放,但似乎无法与任何客户端进行任何选择.
服务器:
var news = [
"Borussia Dortmund wins German championship",
"Tornado warning for the Bay Area",
"More rain for the weekend",
"Android tablets take over the world",
"iPad2 sold out",
"Nation's rappers down to last two samples"
];
var dgram = require('dgram');
var server = dgram.createSocket("udp4");
server.bind();
server.setBroadcast(true)
server.setMulticastTTL(128);
server.addMembership('230.185.192.108');
setInterval(broadcastNew, 3000);
function broadcastNew() {
var message = new Buffer(news[Math.floor(Math.random()*news.length)]);
server.send(message, 0, message.length, 8088, "230.185.192.108");
console.log("Sent " + message + " to the wire...");
//server.close();
}
Run Code Online (Sandbox Code Playgroud)
客户
var PORT …Run Code Online (Sandbox Code Playgroud) 我正在尝试在特定房间中显示客户列表.我只想显示他们的用户名,而不是他们的套接字ID.
我在这里:
socket.set('nickname', "Earl");
socket.join('chatroom1');
console.log('User joined chat room 1);
var roster = io.sockets.clients('chatroom1');
for ( i in roster )
{
console.log('Username: ' + roster[i]);
}
Run Code Online (Sandbox Code Playgroud)
没有任何运气让它列出套接字ID或任何东西.希望它能够返回昵称.
是否可以从另一台服务器连接到NodeJS服务器?两个NodeJS服务器相互通信?
//Server Code
var io = require('socket.io').listen(8090);
io.sockets.on('connection', function (socket) {
io.sockets.emit('this', { will: 'be received by everyone'});
socket.on('private message', function (from, msg) {
console.log('I received a private message by ', from, ' saying ', msg);
});
socket.on('disconnect', function () {
io.sockets.emit('user disconnected');
});
});
//Client Code in Server Code. Connecting to another server.
io.connect( "http://192.168.0.104:8091" ); //Connect to another server from this one.
//ETC...
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用C#和winmm.dll将此录制设置为可能的最低设置.我已经设置了下面的设置,但我没有听到任何差异.有谁知道我错过了什么?
我正在努力获得最低的音频设置.就像你从对讲机里听到的那样.
我对采样率所做的任何更改似乎都没有生效.
谢谢,
record("open new Type waveaudio Alias recsound", "", 0, 0);
record("set recsound time format ms bitspersample 8 samplespersec 8000 channels 1", "", 0, 0);
record("record recsound", "", 0, 0);
Run Code Online (Sandbox Code Playgroud) 我正在使用这个代码项目:http://www.codeproject.com/Articles/10138/Voice-Recording-Playing-back-using-simple-classes
void CFisterDlg::OnRecord()
{
CString string;
m_RecButton.GetWindowText(string);
if(string == "Record")
{
StartRecordingToFile();
m_RecButton.SetWindowText("Stop");
}
else
{
StopRecordingToFile();
m_RecButton.SetWindowText("Record");
}
}
Run Code Online (Sandbox Code Playgroud)
但是我在很多地方都遇到了这个错误:
error C2664: 'void CWnd::SetWindowTextW(LPCTSTR)' : cannot convert argument 1 from 'const char [5]' to 'LPCTSTR'
Run Code Online (Sandbox Code Playgroud)
我认为这与我使用最新版本的visual studio(2013)有关.