[Fix] Convert message from Buffer to String
Fixed the issue - https://github.com/javascript-tutorial/en.javascript.info/issues/2870
This commit is contained in:
parent
d7c8c7506e
commit
d5cce94650
1 changed files with 1 additions and 0 deletions
|
@ -21,6 +21,7 @@ function accept(req, res) {
|
||||||
|
|
||||||
function onConnect(ws) {
|
function onConnect(ws) {
|
||||||
ws.on('message', function (message) {
|
ws.on('message', function (message) {
|
||||||
|
message = message.toString();
|
||||||
let name = message.match(/([\p{Alpha}\p{M}\p{Nd}\p{Pc}\p{Join_C}]+)$/gu) || "Guest";
|
let name = message.match(/([\p{Alpha}\p{M}\p{Nd}\p{Pc}\p{Join_C}]+)$/gu) || "Guest";
|
||||||
ws.send(`Hello from server, ${name}!`);
|
ws.send(`Hello from server, ${name}!`);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue