formatting
This commit is contained in:
parent
b146e93a3a
commit
c14a4c0e3e
@ -33,45 +33,44 @@ namespace ix
|
|||||||
};
|
};
|
||||||
server.setConnectionStateFactory(factory);
|
server.setConnectionStateFactory(factory);
|
||||||
|
|
||||||
server.setOnClientMessageCallback([&server, &connectionId
|
server.setOnClientMessageCallback(
|
||||||
|
[&server, &connectionId](std::shared_ptr<ConnectionState> connectionState,
|
||||||
](std::shared_ptr<ConnectionState> connectionState,
|
ConnectionInfo& connectionInfo,
|
||||||
ConnectionInfo& connectionInfo,
|
WebSocket& webSocket,
|
||||||
WebSocket& webSocket,
|
const ix::WebSocketMessagePtr& msg) {
|
||||||
const ix::WebSocketMessagePtr& msg) {
|
auto remoteIp = connectionInfo.remoteIp;
|
||||||
auto remoteIp = connectionInfo.remoteIp;
|
|
||||||
|
|
||||||
|
|
||||||
if (msg->type == ix::WebSocketMessageType::Open)
|
if (msg->type == ix::WebSocketMessageType::Open)
|
||||||
{
|
|
||||||
TLogger() << "New connection";
|
|
||||||
connectionState->computeId();
|
|
||||||
TLogger() << "remote ip: " << remoteIp;
|
|
||||||
TLogger() << "id: " << connectionState->getId();
|
|
||||||
TLogger() << "Uri: " << msg->openInfo.uri;
|
|
||||||
TLogger() << "Headers:";
|
|
||||||
for (auto it : msg->openInfo.headers)
|
|
||||||
{
|
{
|
||||||
TLogger() << it.first << ": " << it.second;
|
TLogger() << "New connection";
|
||||||
}
|
connectionState->computeId();
|
||||||
|
TLogger() << "remote ip: " << remoteIp;
|
||||||
connectionId = connectionState->getId();
|
TLogger() << "id: " << connectionState->getId();
|
||||||
}
|
TLogger() << "Uri: " << msg->openInfo.uri;
|
||||||
else if (msg->type == ix::WebSocketMessageType::Close)
|
TLogger() << "Headers:";
|
||||||
{
|
for (auto it : msg->openInfo.headers)
|
||||||
TLogger() << "Closed connection";
|
|
||||||
}
|
|
||||||
else if (msg->type == ix::WebSocketMessageType::Message)
|
|
||||||
{
|
|
||||||
for (auto&& client : server.getClients())
|
|
||||||
{
|
|
||||||
if (client.get() != &webSocket)
|
|
||||||
{
|
{
|
||||||
client->send(msg->str, msg->binary);
|
TLogger() << it.first << ": " << it.second;
|
||||||
|
}
|
||||||
|
|
||||||
|
connectionId = connectionState->getId();
|
||||||
|
}
|
||||||
|
else if (msg->type == ix::WebSocketMessageType::Close)
|
||||||
|
{
|
||||||
|
TLogger() << "Closed connection";
|
||||||
|
}
|
||||||
|
else if (msg->type == ix::WebSocketMessageType::Message)
|
||||||
|
{
|
||||||
|
for (auto&& client : server.getClients())
|
||||||
|
{
|
||||||
|
if (client.get() != &webSocket)
|
||||||
|
{
|
||||||
|
client->send(msg->str, msg->binary);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
|
|
||||||
auto res = server.listen();
|
auto res = server.listen();
|
||||||
if (!res.first)
|
if (!res.first)
|
||||||
|
Loading…
Reference in New Issue
Block a user