S
S
Space2014-03-05 10:35:40
JavaScript
Space, 2014-03-05 10:35:40

How to do processing in node.js?

Hello!
Here is the nodeJS code
Here is the server itself:

var socket = require( 'socket.io' );
var express = require( 'express' );
var http = require( 'http' );

var app = express();
var server = http.createServer( app );

var io = socket.listen( server );

io.sockets.on( 'connection', function( client ) {
  console.log( "New client !" );
  
  client.on( 'message', function( data ) {
    console.log( 'Message received ' + data.name + "1" + data.message + data.canal );
    
    //client.broadcast.emit( 'message', { name: data.name, message: data.message } );
    io.sockets.emit( 'message', { name: data.name, message: data.message, canal: data.canal } );
  });
});

server.listen( 8080 );

and this is the client:
var socket = io.connect( 'http://localhost:8080' );
$( "#messageForm" ).submit( function() {
  var nameVal = $( "#nameInput" ).val();
  var msg = $( "#messageInput" ).val();
  var canalVal = $( "#canalInput" ).val();
  if((nameVal) && (msg)){
  
  socket.emit( 'message', { name: nameVal, message: msg, canal: canalVal } )};
  
  // Ajax call for saving datas
  $.ajax({
    url: "./ajax/insertNewMessage.php",
    type: "POST",
    data: { name: nameVal, message: msg, canal: canalVal },
    success: function(data) {
      
    }
  });
  
  return false;
});

socket.on( 'message', function( data ) {
  var actualContent = $( "#messages" ).html();
  var newMsgContent = '<li> <strong>' + data.name + '</strong> : ' + data.message + '</li>';
  var content = newMsgContent + actualContent;
  
  $( "#messages" ).html( content );
});

How can I make sure that there are ODA characters in the incoming message (for example, blabla) and replace them with an image? I ask for help

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Space, 2014-03-06
@ruslite

I don't understand where the comments went! !! The question
is str.replace(new RegExp("blabla",'gi'),"bloblo") is this construction very heavy?

J
jslby, 2014-03-09
@jslby

https://github.com/ednapiranha/node-webremix

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question