title: WebSocket with Sockjs & Spring 4 but without Stomp
body: <p>Is there a way to use WebSockets with SockJS client and Spring 4 server but not using STOMP?</p>
  
  <p>Based on this tutorial from Spring's website, I know how to set up a WebSocket based application using Stomp and Spring 4. On the client side, we have:</p>
  
  <pre><code>     var socket = new SockJS('/hello');
          stompClient = Stomp.over(socket);
          stompClient.connect({}, function(frame) {
              setConnected(true);
              console.log('Connected: ' + frame);
              stompClient.subscribe('/topic/greetings', function(greeting){
                  showGreeting(JSON.parse(greeting.body).content);
              });
          });
  </code></pre>
  
  <p>And on the server side, we have the following in the controller:</p>
  
  <pre><code>@MessageMapping("/hello")
  @SendTo("/topic/greetings")
  public Greeting greeting(HelloMessage message) throws Exception {
      Thread.sleep(3000); // simulated delay
      return new Greeting("Hello, " + message.getName() + "!");
  }
  </code></pre>
  
  <p>Now, I understand that <code>@MessageMapping("/hello")</code> ensures that if a message is sent to a destination <code>"/hello"</code>, then the <code>greeting()</code> method will be called. And since the <code>stompClient</code> is subscribed to <code>"/topic/greetings"</code>, the <code>@SendTo("/topic/greetings")</code> will send the message back to the <code>stompClient</code>.</p>
  
  <p>But the problem with the above is that stompClient is a Stomp object. And I want to simply use <code>sock.send('test');</code> and have it delivered to my server's destination. And I want to do <code>@SendTo("myownclientdestinationmap")</code>, I can receive it by </p>
  
  <pre><code>sock.onmessage = function(e) {
       console.log('message', e.data);
   };
  </code></pre>
  
  <p>So, any way to do this with Spring 4, SockJS and without Stomp? Or does Spring 4 WebSocket only supports Stomp?</p>