title: Passing data (other than payload) via websockets
body: <p>Once the websocket session has been established, is it possible to pass data other than using session.getAsyncRemote().sendText(**)) across the session?</p>
  
  <p>I am using 
   javax.websocket.* as ClientEndpoint
   and spring-websocket for server. </p>
  
  <p>I have tried using:</p>
  
  <pre><code>session.getRequestParameterMap().putAll(bMap); //This gives me exception 
  session.getPathParameters().putAll(aMap); //This gives me exception
  session.getUserProperties().put("dataE", "dataF");; //This goes through fine 
  </code></pre>
  
  <p>And I am not able to see the data on server side:</p>
  
  <pre><code>Map&lt;String, Object&gt; aMap = stStandard.getNativeSession().getUserProperties();
  </code></pre>
  
  <p>This map comes as blank on server side.Please let me know if more information is needed. Here is my code:       </p>
  
  <pre><code>import java.io.IOException;
  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.List;
  import java.util.Map;
  
  import javax.websocket.ClientEndpoint;
  import javax.websocket.OnClose;
  import javax.websocket.OnMessage;
  import javax.websocket.OnOpen;
  import javax.websocket.Session;
  
  @ClientEndpoint
  public class TestSpring {
              @OnMessage
              public void onMessage(String message, Session session) throws IOException,
                      InterruptedException {
                  Map aMap = new HashMap();
                  aMap.put("dataA", "dataB");
                  try {
                      session.getPathParameters().putAll(aMap);
                  } catch (Exception e) {
                      e.printStackTrace();
                  }           
                  Map bMap = new HashMap();
  
                  List&lt;String&gt; bList = new ArrayList&lt;String&gt;();
  
                  bList.add("dataC");
                  try {
                      bMap.put("dataD", bList);
                      session.getRequestParameterMap().putAll(bMap);
                  } catch (Exception e) {
                      e.printStackTrace();
                  }
                  try {
                      session.getUserProperties().put("dataE", "dataF");
                  } catch (Exception e) {
                      e.printStackTrace();
                  }            
                  session.getAsyncRemote().sendText("Data to be sent");
              }
  
              @OnOpen
              public void onOpen() {
                  System.out.println("Client connected");
              }            
              @OnClose
              public void onClose() {
                  System.out.println("Connection closed");
              }
  
          }
  
  
  
  
  import java.util.List;
  import java.util.Map;
  
  import org.springframework.web.socket.BinaryMessage;
  import org.springframework.web.socket.TextMessage;
  import org.springframework.web.socket.WebSocketExtension;
  import org.springframework.web.socket.WebSocketSession;
  import org.springframework.web.socket.adapter.standard.StandardWebSocketSession;
  import org.springframework.web.socket.handler.AbstractWebSocketHandler;
  
  import com.sap.websocket.inMemoryWebSockets.KeepInMemoryWebSockets;
  
  public class WebsocketEndPoint extends AbstractWebSocketHandler {   
  
      @Override
      protected void handleTextMessage(WebSocketSession session,
              TextMessage message) throws Exception {
          session.getHandshakeHeaders();
          StandardWebSocketSession stStandard = (StandardWebSocketSession) session;
          try {
              Map&lt;String, Object&gt; aMap = stStandard.getNativeSession()
                      .getUserProperties();
          } catch (Exception e) {
              e.printStackTrace();
          }   
  
          TextMessage binaryMessage = new TextMessage(new String(
                  "Hello Client. This is message sent from server"));
          session.sendMessage(binaryMessage);
      }
  
      @Override
      protected void handleBinaryMessage(WebSocketSession session,
              BinaryMessage message) throws Exception {           
      }    
  }
  </code></pre>