title: throws ERROR TypeError: Cannot read property 'emit' of undefined, has deprecated this is happening in my chat socket application
body: <p>this is my Service file code where i am getting error</p>
  <pre><code> public sendMessage(msg: SocketMessage) {
  this.socket.emit('check-message', msg);
  </code></pre>
  <p>}</p>
  <pre><code>checkNewMessages(): Observable&lt;SocketMessage&gt; {
      return Observable.create((observer) =&gt; {
        if (environment.production)
          this.socket.on('check-message', (message) =&gt; {
            observer.next(message);
          });
  
      })
    }
  </code></pre>