Using subprotocols (its more websockety) in example instead
This commit is contained in:
parent
3fa029ed88
commit
c114e925ef
|
@ -37,11 +37,21 @@ public class MyAdvancedEchoCreator implements WebSocketCreator
|
|||
@Override
|
||||
public Object createWebSocket(UpgradeRequest req, UpgradeResponse resp)
|
||||
{
|
||||
String[] type = req.getParameterMap().get("type");
|
||||
if ((type != null) && (type.length >= 1) && ("binary".equals(type[0])))
|
||||
for (String subprotocol : req.getSubProtocols())
|
||||
{
|
||||
return binaryEcho;
|
||||
if ("binary".equals(subprotocol))
|
||||
{
|
||||
resp.setAcceptedSubProtocol(subprotocol);
|
||||
return binaryEcho;
|
||||
}
|
||||
if ("text".equals(subprotocol))
|
||||
{
|
||||
resp.setAcceptedSubProtocol(subprotocol);
|
||||
return textEcho;
|
||||
}
|
||||
}
|
||||
return textEcho;
|
||||
|
||||
// No valid subprotocol in request, ignore the request
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue