<commit_before>---
layout: post
title:  "A simple SocketIO chat with Angular"
date:   2016-4-01 10:51:11
categories: blog
---

In my recent programming adventures, I've noticed the increasing popularity of Websockets and real time data
display. So I decided to go learn SocketIO and with it, I built out a simple real time chat app utilizing
Angular for the front end.

* **Github Repository**: [AngularSocketChat](https://github.com/DeeHKim/angularSocketChat)

One interesting thing about websockets is that when emitting a broadcast to all other connected clients, the
data doesn't actually come back to your own client.
~~~~
io.on('connection', function(socket){

  socket.on('chat', function(message){
    console.log(message);
      socket.broadcast.emit('message', message);
  });

  socket.emit('message', 'HIIII');

});
~~~~

So once the server hears the incoming 'chat' from the client side, it broadcasts that information
to all other clients, but the sender actually doesn't receive back that information. Therefore I had to
update the client's chat display directly when a client was sending his own message.
<commit_msg>blog change<commit_after>---
layout: post
title:  "A simple SocketIO chat with Angular"
date:   2016-4-01 10:51:11
categories: blog
---

In my recent programming adventures, I've noticed the increasing popularity of Websockets and real time data
display. So I decided to go learn SocketIO and with it, I built out a simple real time chat app utilizing
Angular for the front end.

* **Github Repository**: [AngularSocketChat](https://github.com/DeeHKim/angularSocketChat)

One interesting thing about websockets is that when emitting a broadcast to all other connected clients, the
data doesn't actually come back to your own client.
~~~~
io.on('connection', function(socket){

  socket.on('chat', function(message){
    console.log(message);
      socket.broadcast.emit('message', message);
  });
  socket.emit('message', 'HIIII');
});

~~~~

So once the server hears the incoming 'chat' from the client side, it broadcasts that information
to all other clients, but the sender actually doesn't receive back that information. Therefore I had to
update the client's chat display directly when a client was sending his own message.

{'fraction_non_alphanumeric': 0.0901458241272647, 'fraction_numerical': 0.011489173663278833, 'mean_word_length': 4.702770780856423, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '404543', 'n_tokens_mistral': 625, 'n_tokens_neox': 587, 'n_words': 285}